Commit 96fead85 authored by Miklos Magyari's avatar Miklos Magyari
Browse files

OOP: added support for nested classes


Signed-off-by: Miklos Magyari's avatarMiklos Magyari <miklos.magyari@sigmatechnology.se>
parent fba4f2e5
......@@ -53,6 +53,19 @@ type class BaseFunctionClass {
}
}
type class OuterClass {
private var integer m_int := 0;
class NestedClass {
const charstring c_text := "abc";
class InnerClass {
private template MyUnion t_union;
public var integer badInteger := "xyz";
}
}
}
const integer cg_uninitConst1;
type class SubFunctionClass extends BaseFunctionClass {
......
......@@ -88,13 +88,7 @@ type class VariousMembers {
public var charstring m_var1 := "abc";
public template MyUnion t_union := { choice1 := 12 }
template MyUnion t_union2;
private type class NestedClass {
private function f_dummy(in integer x) return integer {
return 1;
}
}
create (charstring p1, charstring p2) {
m_var1 := p2;
t_union := { choice2 := "abc" };
......@@ -107,6 +101,21 @@ type class @trait AbstractMembersClass {
function @abstract f3(in integer p_int) return charstring;
}
// nested classes
type class OuterClass {
private var integer m_int := 0;
private class NestedClass {
private function f_dummy(in integer pl_param) return integer {
return 1;
}
class DeeplyNested {
const integer m_const := 0;
}
}
}
// `this` reference
type class ClassWithThis {
public var integer vl_a;
......
......@@ -9091,7 +9091,12 @@ pr_ClassMember returns[List<Definition> definitions]
}
}
| c = pr_ClassConstructorDef
| pr_TypeDef
| cl = pr_ClassTypeDef {
if ($cl.def_type != null) {
$definitions = new ArrayList<Definition>();
$definitions.add( $cl.def_type );
}
}
| pr_PropertyDef
)
)
......
......@@ -41,14 +41,16 @@ public class OOP_Semantic_tests {
private ArrayList<MarkerToCheck> oopNegative_ttcn_initializer() {
//oopNegativeSemanticTest.ttcn
ArrayList<MarkerToCheck> markersToCheck = new ArrayList<MarkerToCheck>(6);
ArrayList<MarkerToCheck> markersToCheck = new ArrayList<MarkerToCheck>(7);
int lineNum = 28;
markersToCheck.add(new MarkerToCheck("class type expected", lineNum, IMarker.SEVERITY_ERROR));
lineNum += 15;
markersToCheck.add(new MarkerToCheck("Reference to non-existent field `nonexist' in union template for type `@classesNegativeSemantic.MyUnion'", lineNum, IMarker.SEVERITY_ERROR));
lineNum += 4;
markersToCheck.add(new MarkerToCheck("Local Definiton `vl_b' collides with definition inherited from class type `@classesNegativeSemantic.SubClass'", lineNum, IMarker.SEVERITY_ERROR));
lineNum += 9;
lineNum += 17;
markersToCheck.add(new MarkerToCheck("integer value was expected", lineNum, IMarker.SEVERITY_ERROR));
lineNum += 5;
markersToCheck.add(new MarkerToCheck("Constant must be initialized", lineNum, IMarker.SEVERITY_ERROR));
lineNum += 17;
markersToCheck.add(new MarkerToCheck("There is no visible definition with name `vl_gsc' in module `classesNegativeSemantic'", lineNum, IMarker.SEVERITY_ERROR));
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment