Commit 22a0a62c authored by Miklos Magyari's avatar Miklos Magyari
Browse files

OOP: synch with titan core (9) (issue #487)


Signed-off-by: Miklos Magyari's avatarMiklos Magyari <miklos.magyari@sigmatechnology.se>
parent 997e4db1
......@@ -74,7 +74,7 @@ public final class Def_Var extends Definition {
private static final String KIND = " variable definition";
private final Type type;
private final Value initialValue;
private Value initialValue;
private boolean wasAssigned;
......@@ -610,4 +610,10 @@ public final class Def_Var extends Definition {
.append(indentation).append(ICommentable.COMMENT_END).append(indentation);
return sb.toString();
}
public Value stealValue() {
final Value retval = initialValue;
initialValue = null;
return retval;
}
}
......@@ -22,6 +22,7 @@ import org.eclipse.titan.designer.AST.ISubReference.Subreference_type;
import org.eclipse.titan.designer.AST.IType;
import org.eclipse.titan.designer.AST.IType.TypeOwner_type;
import org.eclipse.titan.designer.AST.IType.Type_type;
import org.eclipse.titan.designer.AST.IValue;
import org.eclipse.titan.designer.AST.Identifier;
import org.eclipse.titan.designer.AST.Location;
import org.eclipse.titan.designer.AST.NamingConventionHelper;
......@@ -74,7 +75,7 @@ public final class Def_Var_Template extends Definition {
* NOTE: It is not yet supported, so semantic error must be marked if not null
*/
private final FormalParameterList mFormalParList;
private final TTCN3Template initialValue;
private TTCN3Template initialValue;
private final TemplateRestriction.Restriction_type templateRestriction;
private boolean generateRestrictionCheck = false;
......@@ -611,4 +612,10 @@ public final class Def_Var_Template extends Definition {
.append(indentation).append(ICommentable.COMMENT_END).append(indentation);
return sb.toString();
}
public TTCN3Template stealValue() {
TTCN3Template retval = initialValue;
initialValue = null;
return retval;
}
}
......@@ -37,13 +37,18 @@ import org.eclipse.titan.designer.AST.TTCN3.Expected_Value_type;
import org.eclipse.titan.designer.AST.TTCN3.TemplateRestriction.Restriction_type;
import org.eclipse.titan.designer.AST.TTCN3.attributes.Types;
import org.eclipse.titan.designer.AST.TTCN3.definitions.Def_AbsFunction;
import org.eclipse.titan.designer.AST.TTCN3.definitions.Def_Const;
import org.eclipse.titan.designer.AST.TTCN3.definitions.Def_Constructor;
import org.eclipse.titan.designer.AST.TTCN3.definitions.Def_Function;
import org.eclipse.titan.designer.AST.TTCN3.definitions.Def_Template;
import org.eclipse.titan.designer.AST.TTCN3.definitions.Def_Timer;
import org.eclipse.titan.designer.AST.TTCN3.definitions.Def_Type;
import org.eclipse.titan.designer.AST.TTCN3.definitions.Def_Var;
import org.eclipse.titan.designer.AST.TTCN3.definitions.Def_Var_Template;
import org.eclipse.titan.designer.AST.TTCN3.definitions.Definition;
import org.eclipse.titan.designer.AST.TTCN3.definitions.Definitions;
import org.eclipse.titan.designer.AST.TTCN3.definitions.FormalParameter;
import org.eclipse.titan.designer.AST.TTCN3.definitions.FormalParameter.parameterEvaluationType;
import org.eclipse.titan.designer.AST.TTCN3.definitions.FormalParameterList;
import org.eclipse.titan.designer.AST.TTCN3.definitions.FormalParameterList.IsIdenticalResult;
import org.eclipse.titan.designer.AST.TTCN3.definitions.IFunctionBase;
......@@ -606,8 +611,58 @@ public final class Class_Type extends Type implements ITypeWithComponents {
addDefaultParameter(fp);
}
}
//baseCall = new Reference(baseClass.getMyScope().getParentScope().getModuleScope().getIdentifier().newInstance(),)
final ParameterisedSubReference paramSubRef = new ParameterisedSubReference(classId, parsedApList);
final List<ISubReference> subrefs = new ArrayList<>();
subrefs.add(paramSubRef);
baseCall = new Reference(baseClass.getMyScope().getParentScope().getModuleScope().getIdentifier().newInstance(),
subrefs);
}
}
if (fpl == null) {
fpl = new FormalParameterList(new ArrayList<FormalParameter>());
}
StatementBlock block = null;
if (! isExternal) {
block = new StatementBlock();
for (int i = 0; i < members.getNofAssignments(); i++) {
final Assignment member = members.getAssignmentByIndex(i);
boolean isTemplate = false;
TemplateInstance defVal = null;
switch(member.getAssignmentType()) {
case A_CONST:
if (((Def_Const)member).getValue() != null) {
continue; // the constant has already been initialized at its definition
}
break;
case A_TEMPLATE:
if (((Def_Template)member).getTemplate(timestamp) != null) {
continue; // the template has already been initialized at its definition
}
isTemplate = true;
break;
case A_VAR:
if (((Def_Var)member).getInitialValue() != null) {
// set the variable's initial value as the constructor parameter's default value
final Def_Var varMember = (Def_Var)member;
defVal = new TemplateInstance(null, null, new SpecificValue_Template(varMember.stealValue()));
}
break;
case A_VAR_TEMPLATE:
isTemplate = true;
if (((Def_Var_Template)member).getInitialValue() != null) {
// set the template variable's initial value as the constructor parameter's default value
final Def_Var_Template varTemplateMember = (Def_Var_Template)member;
defVal = new TemplateInstance(null, null, varTemplateMember.stealValue());
}
break;
default:
continue;
}
// add a formal parameter for this member if we've gotten this far
final Identifier id = member.getIdentifier().newInstance();
FormalParameter fp = new FormalParameter(
Restriction_type.TR_NONE, isTemplate ? Assignment_type.A_PAR_TEMP_IN : Assignment_type.A_PAR_VAL_IN,
(Type)member.getType(timestamp), id, defVal, parameterEvaluationType.NORMAL_EVAL);
}
}
}
......@@ -927,8 +982,7 @@ public final class Class_Type extends Type implements ITypeWithComponents {
@Override
/** {@inheritDoc} */
public Object[] getOutlineChildren() {
//return getDefinitions().toArray();
return null;
return getDefinitions().toArray();
}
@Override
......
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