use of org.eclipse.titan.designer.AST.TTCN3.definitions.FormalParameterList in project titan.EclipsePlug-ins by eclipse.
the class TooManyParameters method process.
@Override
public void process(final IVisitableNode node, final Problems problems) {
if (node instanceof FormalParameterList) {
final FormalParameterList s = (FormalParameterList) node;
if (s.getNofParameters() > reportTooManyParametersSize) {
final String msg = MessageFormat.format(TOOMANYPARAMETERS, reportTooManyParametersSize, s.getNofParameters());
problems.report(s.getLocation(), msg);
}
}
}
use of org.eclipse.titan.designer.AST.TTCN3.definitions.FormalParameterList in project titan.EclipsePlug-ins by eclipse.
the class TemplateParser method process.
@Override
public Scope process(IVisitableNode node) {
if (node instanceof Identifier) {
name = node.toString();
// TODO : find a more sophisticated way of storing symbols (e.g. SymbolTable)
myASTVisitor.nodeNameNodeTypeHashMap.put(name, "template");
}
if (node instanceof Type) {
type = Util.getTypeName((Type) node);
template = new Template(name, type);
return Action.skip(Type.class, this);
}
if (node instanceof FormalParameterList) {
return new FormalParameterParser(this, template);
}
// is a modification
if (node instanceof Reference) {
Reference reference = (Reference) node;
String basename = reference.getId().toString();
Template base = registry.find(basename);
// TODO : templates need a base value as a fallback
// TODO : this base value should be used as a reference, to diff against
// TODO : this was a hotfix for the union types to work
String type = base.getValue().getType();
template.setValue(new Value(type, (code, indent) -> code.append("(", type, ") ").append(basename, "()")));
isModification = true;
return Action.skip(Reference.class, this);
}
if (node instanceof TTCN3Template) {
if (isModification) {
return ModificationParser.getScope(this, template, "", type, node);
}
return TemplateValueParser.getScope(this, template, type, node);
}
return this;
}
use of org.eclipse.titan.designer.AST.TTCN3.definitions.FormalParameterList in project titan.EclipsePlug-ins by eclipse.
the class Reference method getRefdAssignment.
public Assignment getRefdAssignment(final CompilationTimeStamp timestamp, final boolean checkParameterList, final IReferenceChain referenceChain) {
if (myScope == null || getId() == null) {
return null;
}
if (lastTimeChecked != null && !lastTimeChecked.isLess(timestamp) && !checkParameterList) {
return referredAssignment;
}
lastTimeChecked = timestamp;
final boolean newChain = null == referenceChain;
IReferenceChain tempReferenceChain;
if (newChain) {
tempReferenceChain = ReferenceChain.getInstance(IReferenceChain.CIRCULARREFERENCE, true);
} else {
tempReferenceChain = referenceChain;
}
isErroneous = false;
detectedModuleId = false;
detectModid();
referredAssignment = myScope.getAssBySRef(timestamp, this, referenceChain);
if (referredAssignment == null) {
isErroneous = true;
return referredAssignment;
}
referredAssignment.check(timestamp, tempReferenceChain);
referredAssignment.setUsed();
if (referredAssignment instanceof Definition) {
final String referingModuleName = getMyScope().getModuleScope().getName();
if (!((Definition) referredAssignment).referingHere.contains(referingModuleName)) {
((Definition) referredAssignment).referingHere.add(referingModuleName);
}
}
if (checkParameterList) {
FormalParameterList formalParameterList = null;
if (referredAssignment instanceof IParameterisedAssignment) {
formalParameterList = ((IParameterisedAssignment) referredAssignment).getFormalParameterList();
}
if (formalParameterList == null) {
if (!subReferences.isEmpty() && subReferences.get(0) instanceof ParameterisedSubReference) {
final String message = MessageFormat.format("The referenced {0} cannot have actual parameters", referredAssignment.getDescription());
getLocation().reportSemanticError(message);
setIsErroneous(true);
}
} else if (!subReferences.isEmpty()) {
final ISubReference firstSubReference = subReferences.get(0);
if (firstSubReference instanceof ParameterisedSubReference) {
formalParameterList.check(timestamp, referredAssignment.getAssignmentType());
isErroneous = ((ParameterisedSubReference) firstSubReference).checkParameters(timestamp, formalParameterList);
} else {
// default values
if (!Assignment.Assignment_type.A_TEMPLATE.semanticallyEquals(referredAssignment.getAssignmentType()) || !formalParameterList.hasOnlyDefaultValues()) {
final String message = MessageFormat.format("Reference to parameterized definition `{0}'' without actual parameter list", referredAssignment.getIdentifier().getDisplayName());
getLocation().reportSemanticError(message);
setIsErroneous(true);
}
}
}
}
return referredAssignment;
}
use of org.eclipse.titan.designer.AST.TTCN3.definitions.FormalParameterList 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.FormalParameterList 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