use of org.eclipse.titan.designer.AST.TTCN3.definitions.FormalParameterList in project titan.EclipsePlug-ins by eclipse.
the class Activate_Referenced_Statement method check.
@Override
public /**
* {@inheritDoc}
*/
void check(final CompilationTimeStamp timestamp) {
if (lastTimeChecked != null && !lastTimeChecked.isLess(timestamp)) {
return;
}
isErroneous = false;
lastTimeChecked = timestamp;
if (dereferredValue == null) {
setIsErroneous();
return;
}
dereferredValue.setLoweridToReference(timestamp);
IType type = dereferredValue.getExpressionGovernor(timestamp, Expected_Value_type.EXPECTED_DYNAMIC_VALUE);
if (type != null) {
type = type.getTypeRefdLast(timestamp);
}
if (type == null || type.getIsErroneous(timestamp)) {
setIsErroneous();
return;
}
if (!Type_type.TYPE_ALTSTEP.equals(type.getTypetype())) {
dereferredValue.getLocation().reportSemanticError(MessageFormat.format(ALTSTEPEXPECTED, type.getTypename()));
setIsErroneous();
return;
}
if (((Altstep_Type) type).isRunsOnSelf()) {
dereferredValue.getLocation().reportSemanticError(RUNONSELFERROR);
setIsErroneous();
return;
}
if (myStatementBlock != null) {
myStatementBlock.checkRunsOnScope(timestamp, type, this, STATEMENT_NAME);
}
actualParameterList2 = new ActualParameterList();
final FormalParameterList formalParameterList = ((Altstep_Type) type).getFormalParameters();
if (formalParameterList.checkActualParameterList(timestamp, actualParameterList, actualParameterList2)) {
setIsErroneous();
return;
}
actualParameterList2.setFullNameParent(this);
actualParameterList2.setMyScope(getMyScope());
if (!formalParameterList.checkActivateArgument(timestamp, actualParameterList2, getFullName())) {
setIsErroneous();
}
}
use of org.eclipse.titan.designer.AST.TTCN3.definitions.FormalParameterList in project titan.EclipsePlug-ins by eclipse.
the class Invoke_Template method checkInvoke.
public void checkInvoke(final CompilationTimeStamp timestamp) {
if (getIsErroneous(timestamp) || actualParameterList == null || value == null) {
return;
}
value.setLoweridToReference(timestamp);
IType type = value.getExpressionGovernor(timestamp, Expected_Value_type.EXPECTED_DYNAMIC_VALUE);
if (type != null) {
type = type.getTypeRefdLast(timestamp);
}
if (type == null) {
if (!value.getIsErroneous(timestamp)) {
value.getLocation().reportSemanticError("A value of type function was expected in the argument");
}
setIsErroneous(true);
return;
}
if (!Type_type.TYPE_FUNCTION.equals(type.getTypetype())) {
value.getLocation().reportSemanticError(MessageFormat.format("A value of type function was expected in the argument instead of `{0}''", type.getTypename()));
setIsErroneous(true);
return;
}
if (myScope == null) {
return;
}
myScope.checkRunsOnScope(timestamp, type, this, "call");
final FormalParameterList formalParameterList = ((Function_Type) type).getFormalParameters();
actualParameter_list = new ActualParameterList();
if (!formalParameterList.checkActualParameterList(timestamp, actualParameterList, actualParameter_list)) {
actualParameter_list.setFullNameParent(this);
actualParameter_list.setMyScope(getMyScope());
}
}
use of org.eclipse.titan.designer.AST.TTCN3.definitions.FormalParameterList in project titan.EclipsePlug-ins by eclipse.
the class Referenced_Template method reArrangeInitCode.
@Override
public /**
* {@inheritDoc}
*/
void reArrangeInitCode(final JavaGenData aData, final StringBuilder source, final Module usageModule) {
final ISubReference tempSubreference = reference.getSubreferences().get(0);
if (tempSubreference instanceof ParameterisedSubReference) {
// generate code for the templates that are used in the actual parameter
// list of the reference
final ActualParameterList actualParameterList = ((ParameterisedSubReference) tempSubreference).getActualParameters();
if (actualParameterList != null) {
actualParameterList.reArrangeInitCode(aData, source, usageModule);
}
}
final Assignment assignment = reference.getRefdAssignment(CompilationTimeStamp.getBaseTimestamp(), false);
if (assignment.getAssignmentType() != Assignment_type.A_TEMPLATE) {
return;
}
ITTCN3Template template = ((Def_Template) assignment).getTemplate(CompilationTimeStamp.getBaseTimestamp());
final FormalParameterList formalParameterList = ((Def_Template) assignment).getFormalParameterList();
if (formalParameterList != null) {
// the reference points to a parameterized template
// we must perform the rearrangement for all non-parameterized templates
// that are referred by the parameterized template regardless of the
// sub-references of reference
template.reArrangeInitCode(aData, source, usageModule);
// be generated when the template's definition is reached)
if (assignment.getMyScope().getModuleScope() == usageModule) {
formalParameterList.generateCodeDefaultValues(aData, source);
}
} else {
// the reference points to a non-parameterized template
final List<ISubReference> subReferences = reference.getSubreferences();
if (subReferences != null && subReferences.size() > 1) {
// and perform the rearrangement for the referred field only
for (int i = 1; i < subReferences.size(); i++) {
final ISubReference subReference = subReferences.get(i);
if (subReference instanceof FieldSubReference) {
// stop if the body does not have fields
if (template.getTemplatetype() != Template_type.NAMED_TEMPLATE_LIST) {
break;
}
// the field reference can be followed
final Identifier fieldId = ((FieldSubReference) subReference).getId();
template = ((Named_Template_List) template).getNamedTemplate(fieldId).getTemplate();
} else {
// stop if the body is not a list
if (template.getTemplatetype() != Template_type.TEMPLATE_LIST) {
break;
}
IValue arrayIndex = ((ArraySubReference) subReference).getValue();
final IReferenceChain referenceChain = ReferenceChain.getInstance(IReferenceChain.CIRCULARREFERENCE, true);
arrayIndex = arrayIndex.getValueRefdLast(CompilationTimeStamp.getBaseTimestamp(), referenceChain);
referenceChain.release();
if (arrayIndex.getValuetype() != Value_type.INTEGER_VALUE) {
break;
}
// the index is available at compilation time
long index = ((Integer_Value) arrayIndex).getValue();
// index transformation in case of arrays
if (template.getMyGovernor().getTypetype() == Type_type.TYPE_ARRAY) {
index = index - ((Array_Type) template.getMyGovernor()).getDimension().getOffset();
}
template = ((Template_List) template).getTemplateByIndex((int) index);
}
}
}
// we should initialize its entire body
if (assignment.getMyScope().getModuleScope() == usageModule) {
template.generateCodeInit(aData, source, template.get_lhs_name());
}
}
if (lengthRestriction != null) {
lengthRestriction.reArrangeInitCode(aData, source, usageModule);
}
}
use of org.eclipse.titan.designer.AST.TTCN3.definitions.FormalParameterList in project titan.EclipsePlug-ins by eclipse.
the class Referenced_Testcase_Instance_Statement method check.
@Override
public /**
* {@inheritDoc}
*/
void check(final CompilationTimeStamp timestamp) {
if (lastTimeChecked != null && !lastTimeChecked.isLess(timestamp)) {
return;
}
lastTimeChecked = timestamp;
if (dereferredValue == null) {
return;
}
final IValue temporalValue = dereferredValue.setLoweridToReference(timestamp);
IType type = temporalValue.getExpressionGovernor(timestamp, Expected_Value_type.EXPECTED_TEMPLATE);
if (type != null) {
type = type.getTypeRefdLast(timestamp);
}
if (type == null) {
return;
}
if (!Type_type.TYPE_TESTCASE.equals(type.getTypetype())) {
dereferredValue.getLocation().reportSemanticError(MessageFormat.format("A value of type testcase was expected in the argument of `derefers()'' instead of `{0}''", type.getTypename()));
return;
}
if (myStatementBlock.getScopeRunsOn() != null) {
dereferredValue.getLocation().reportSemanticError(DEFINITIONWITHOUTRUNSONEXPECTED);
return;
}
actualParameterList2 = new ActualParameterList();
final FormalParameterList formalParameterList = ((Testcase_Type) type).getFormalParameters();
formalParameterList.checkActualParameterList(timestamp, actualParameterList, actualParameterList2);
if (timerValue != null) {
timerValue.setLoweridToReference(timestamp);
final Type_type temporalType = timerValue.getExpressionReturntype(timestamp, Expected_Value_type.EXPECTED_DYNAMIC_VALUE);
switch(temporalType) {
case TYPE_REAL:
final IValue last = timerValue.getValueRefdLast(timestamp, Expected_Value_type.EXPECTED_DYNAMIC_VALUE, null);
if (!last.isUnfoldable(timestamp)) {
final Real_Value real = (Real_Value) last;
final double i = real.getValue();
if (i < 0.0) {
timerValue.getLocation().reportSemanticError(MessageFormat.format(NEGATIVEDURATION, real.createStringRepresentation()));
} else if (real.isPositiveInfinity()) {
timerValue.getLocation().reportSemanticError(MessageFormat.format(FLOATEXPECTED2, real.createStringRepresentation()));
}
}
break;
default:
timerValue.getLocation().reportSemanticError(FLOATEXPECTED);
break;
}
}
}
use of org.eclipse.titan.designer.AST.TTCN3.definitions.FormalParameterList in project titan.EclipsePlug-ins by eclipse.
the class Start_Component_Statement method generateCode.
@Override
public /**
* {@inheritDoc}
*/
void generateCode(final JavaGenData aData, final StringBuilder source) {
final ExpressionStruct expression = new ExpressionStruct();
final Assignment func = functionInstanceReference.getRefdAssignment(CompilationTimeStamp.getBaseTimestamp(), false);
final Def_Function function = (Def_Function) func;
expression.expression.append(MessageFormat.format("{0}(", func.getGenNameFromScope(aData, source, myScope, "start_")));
componentReference.generateCodeExpression(aData, expression, false);
FormalParameterList formalParameterList = function.getFormalParameterList();
if (formalParameterList.getNofParameters() > 0) {
expression.expression.append(',');
ISubReference subReference = functionInstanceReference.getSubreferences().get(0);
((ParameterisedSubReference) subReference).getActualParameters().generateCodeNoAlias(aData, expression);
}
expression.expression.append(')');
expression.mergeExpression(source);
}
Aggregations