use of org.eclipse.titan.designer.AST.TTCN3.definitions.Def_Altstep in project titan.EclipsePlug-ins by eclipse.
the class Invoke_Altguard method generateCodeInvokeInstance.
/**
* Generate code for an alt guard
*
* @param aData the structure to put imports into and get temporal variable names from.
* @param expression the expression to generate the source to
*/
public void generateCodeInvokeInstance(final JavaGenData aData, final ExpressionStruct expression) {
final IReferenceChain referenceChain = ReferenceChain.getInstance(IReferenceChain.CIRCULARREFERENCE, true);
final IValue last = value.getValueRefdLast(CompilationTimeStamp.getBaseTimestamp(), referenceChain);
referenceChain.release();
if (last.getValuetype() == Value_type.ALTSTEP_REFERENCE_VALUE) {
Def_Altstep altstep = ((Altstep_Reference_Value) last).getReferredAltstep();
expression.expression.append(MessageFormat.format("{0}_instance(", altstep.getGenNameFromScope(aData, expression.expression, myScope, "")));
actualParameterList.generateCodeAlias(aData, expression);
} else {
value.generateCodeExpressionMandatory(aData, expression, true);
expression.expression.append(".invoke(");
IType governor = value.getExpressionGovernor(CompilationTimeStamp.getBaseTimestamp(), Expected_Value_type.EXPECTED_TEMPLATE);
governor = governor.getTypeRefdLast(CompilationTimeStamp.getBaseTimestamp());
actualParameterList.generateCodeAlias(aData, expression);
}
expression.expression.append(')');
}
use of org.eclipse.titan.designer.AST.TTCN3.definitions.Def_Altstep in project titan.EclipsePlug-ins by eclipse.
the class Scope method checkRunsOnScope.
/**
* Checks that operations that can only be executed in definitions that
* have a runs on scope, are really executed in such a definition. And
* that the required runs on component is compatible with the runs on
* component of the definition.
*
* @param timestamp
* the timestamp of the actual semantic check cycle.
* @param assignment
* the assignment to check (used or referred to by the
* statement).
* @param errorLocation
* the location to report the error to.
* @param operation
* the name of the operation.
*/
public void checkRunsOnScope(final CompilationTimeStamp timestamp, final Assignment assignment, final ILocateableNode errorLocation, final String operation) {
Component_Type referencedComponent;
switch(assignment.getAssignmentType()) {
case A_ALTSTEP:
referencedComponent = ((Def_Altstep) assignment).getRunsOnType(timestamp);
break;
case A_FUNCTION:
case A_FUNCTION_RVAL:
case A_FUNCTION_RTEMP:
referencedComponent = ((Def_Function) assignment).getRunsOnType(timestamp);
break;
case A_TESTCASE:
referencedComponent = ((Def_Testcase) assignment).getRunsOnType(timestamp);
break;
default:
return;
}
if (referencedComponent == null) {
return;
}
final RunsOnScope runsOnScope = getScopeRunsOn();
if (runsOnScope == null) {
errorLocation.getLocation().reportSemanticError(MessageFormat.format(RUNSONREQUIRED, operation, assignment.getDescription(), referencedComponent.getTypename()));
} else {
final Component_Type localType = runsOnScope.getComponentType();
if (!referencedComponent.isCompatible(timestamp, localType, null, null, null)) {
errorLocation.getLocation().reportSemanticError(MessageFormat.format(RUNSONMISSMATCH, localType.getTypename(), operation, assignment.getDescription(), referencedComponent.getTypename()));
}
}
}
use of org.eclipse.titan.designer.AST.TTCN3.definitions.Def_Altstep in project titan.EclipsePlug-ins by eclipse.
the class Shorthand method check.
protected void check(final Statement s, final Problems problems) {
if (s == null) {
return;
}
// shorthand statements are ignored inside alt statements
INamedNode curr = s;
while (curr != null) {
if (curr instanceof Alt_Statement || curr instanceof Call_Statement) {
return;
}
curr = curr.getNameParent();
}
final StatementBlock sb = s.getMyStatementBlock();
if (sb == null) {
return;
}
final Definition d = sb.getMyDefinition();
if (d == null) {
return;
}
// shorthand statements are marked in functions, test cases and altsteps that have a 'runs on' clause
if (d instanceof Def_Function && ((Def_Function) d).getRunsOnType(timestamp) != null) {
problems.report(s.getLocation(), ERROR_MESSAGE_PREFIX + typename + ERROR_MESSAGE_SUFFIX);
return;
}
if (d instanceof Def_Altstep || d instanceof Def_Testcase) {
problems.report(s.getLocation(), ERROR_MESSAGE_PREFIX + typename + ERROR_MESSAGE_SUFFIX);
}
}
use of org.eclipse.titan.designer.AST.TTCN3.definitions.Def_Altstep in project titan.EclipsePlug-ins by eclipse.
the class Reference method checkActivateArgument.
/**
* Checks whether this is a correct altstep activation reference.
*
* @param timestamp
* the timestamp of the actual semantic check cycle.
*
* @return true if the altstep reference is correct, false otherwise.
*/
public final boolean checkActivateArgument(final CompilationTimeStamp timestamp) {
final Assignment assignment = getRefdAssignment(timestamp, true);
if (assignment == null) {
return false;
}
if (!Assignment_type.A_ALTSTEP.semanticallyEquals(assignment.getAssignmentType())) {
getLocation().reportSemanticError(MessageFormat.format(ALTSTEPEXPECTED, assignment.getDescription()));
setIsErroneous(true);
return false;
}
if (myScope != null) {
myScope.checkRunsOnScope(timestamp, assignment, this, "activate");
}
if (!subReferences.isEmpty()) {
if (Subreference_type.parameterisedSubReference.equals(subReferences.get(0).getReferenceType())) {
final ActualParameterList actualParameters = ((ParameterisedSubReference) subReferences.get(0)).getActualParameters();
final FormalParameterList formalParameterList = ((Def_Altstep) assignment).getFormalParameterList();
if (formalParameterList != null) {
return formalParameterList.checkActivateArgument(timestamp, actualParameters, assignment.getDescription());
}
}
}
return false;
}
use of org.eclipse.titan.designer.AST.TTCN3.definitions.Def_Altstep in project titan.EclipsePlug-ins by eclipse.
the class ReferenceFinder method detectSmallestScope.
/**
* Detect the smallest scope where the references should be searched
*
* @param assignment
* The assignment
* @return The detected scope
*/
private Scope detectSmallestScope(final Assignment assignment) {
Scope localScope = assignment.getMyScope();
final Module module = localScope.getModuleScope();
if (localScope instanceof StatementBlock) {
final StatementBlock statementBlock = (StatementBlock) localScope;
if (statementBlock.getMyDefinition() instanceof Def_Altstep) {
localScope = localScope.getParentScope();
}
if (statementBlock.hasEnclosingLoopOrAltguard()) {
localScope = localScope.getParentScope();
}
}
if (localScope instanceof NamedBridgeScope) {
localScope = localScope.getParentScope();
}
// control,function,testcase,altstep then it is global
if (localScope instanceof Assignments && localScope.getParentScope() == module) {
localScope = module;
} else // treat it as global definition
if (localScope instanceof ComponentTypeBody) {
// FIXME this still does not make them global, that is something completely different.
localScope = module;
} else // search for actual named parameters everywhere
if (localScope instanceof FormalParameterList || localScope instanceof RunsOnScope) {
localScope = module;
} else // For_Statement that must be searched
if (localScope instanceof For_Loop_Definitions) {
localScope = localScope.getParentScope();
}
return localScope;
}
Aggregations