Commit 42c055a1 authored by Miklos Magyari's avatar Miklos Magyari
Browse files

OOP: reworked constructor parsing


Signed-off-by: Miklos Magyari's avatarMiklos Magyari <miklos.magyari@sigmatechnology.se>
parent 80e7de16
......@@ -15,8 +15,10 @@ import org.eclipse.titan.designer.AST.Identifier;
import org.eclipse.titan.designer.AST.Identifier.Identifier_type;
import org.eclipse.titan.designer.AST.Location;
import org.eclipse.titan.designer.AST.Reference;
import org.eclipse.titan.designer.AST.Type;
import org.eclipse.titan.designer.AST.TTCN3.definitions.FormalParameterList.IsIdenticalResult;
import org.eclipse.titan.designer.AST.TTCN3.statements.StatementBlock;
import org.eclipse.titan.designer.AST.TTCN3.types.Referenced_Type;
import org.eclipse.titan.designer.compiler.JavaGenData;
import org.eclipse.titan.designer.parsers.CompilationTimeStamp;
import org.eclipse.titan.designer.parsers.ttcn3parser.ReParseException;
......@@ -33,12 +35,21 @@ public class Def_Constructor extends Definition implements IParameterisedAssignm
private Map<Identifier,Boolean> uninitializedMembers = new HashMap<>();
private FormalParameterList formalParameterList;
private Assignment_type assignmentType;
private Reference baseRef;
public Def_Constructor(FormalParameterList fpl, Reference baseCall, StatementBlock sb) {
super(new Identifier(Identifier_type.ID_TTCN, "create"));
formalParameterList = fpl;
statementBlock = sb;
baseRef = baseCall;
}
public Def_Constructor(FormalParameterList fpl, Type baseCall, StatementBlock sb) {
this(fpl,
baseCall != null && baseCall instanceof Referenced_Type ?
((Referenced_Type)baseCall).getReference() : null,
sb);
}
public synchronized void addUninitializedMember(Identifier identifier, boolean isTemplate) {
......
......@@ -9507,9 +9507,9 @@ pr_ClassMember returns[List<Definition> definitions]
}
}
| c = pr_ClassConstructorDef {
if ($c.def_func != null) {
if ($c.def_constr != null) {
$definitions = new ArrayList<Definition>();
$definitions.add($c.def_func);
$definitions.add($c.def_constr);
}
}
| cl = pr_ClassTypeDef {
......@@ -9636,40 +9636,42 @@ pr_ClassFunctionModifier returns[boolean isAbstract, boolean isFinal, boolean is
)*
;
pr_ClassConstructorDef returns[Def_Function def_func]
pr_ClassConstructorDef returns[Def_Constructor def_constr]
@init {
FormalParameterList parameters = null;
StatementBlock statementBlock = null;
StatementBlock statementBlock = null;
Type baseType = null;
Token endcol = null;
}:
( id = pr_CreateKeyword
pstart = pr_LParen
( pl = pr_FunctionFormalParList {
parameters = $pl.parList;
})?
pstop = pr_RParen
pstop = pr_RParen { endcol = $pstop.stop; }
(
pr_ExtKeyword pr_LParen
pr_FunctionFormalParList
pr_RParen
rp = pr_RParen
{ endcol = $rp.stop; }
)?
(
COLON
sc = pr_Identifier
pr_LParen
sp = pr_FunctionActualParList
endparen = pr_RParen
{
ref = pr_ReferencedType {
baseType = $ref.type;
endcol = $ref.stop;
}
)?
( sb=pr_StatementBlock { statementBlock = $sb.statementblock; } )?
( sb = pr_StatementBlock {
statementBlock = $sb.statementblock;
endcol = $sb.stop;
} )?
)
{
if(parameters == null) { parameters = new FormalParameterList(new ArrayList<FormalParameter>()); }
parameters.setLocation(getLocation( $pstart.start, $pstop.stop));
Identifier id = new Identifier( Identifier_type.ID_TTCN, "create", getLocation($id.start, $id.stop ) );
$def_func = new Def_Function(id, parameters, null, null, null, null, null, false, null, null, statementBlock, null, false, false, null, true);
$def_func.setLocation(getLocation( $id.start, $sb.stop));
$def_constr = new Def_Constructor(parameters, baseType, statementBlock);
$def_constr.setLocation(getLocation( $id.start, endcol));
};
pr_SingleClassConstDef[Type type] returns[Def_Const def_const]
......
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