use of org.eclipse.titan.codegenerator.Scope in project titan.EclipsePlug-ins by eclipse.
the class ConstantParser method process.
@Override
public Scope process(IVisitableNode node) {
if (node instanceof Identifier) {
name = node.toString();
}
if (node instanceof Type) {
type = Util.getTypeName((Type) node);
value = new Value(type, Writable.NULL);
return Action.skip(Type.class, this);
}
if (node instanceof org.eclipse.titan.designer.AST.Value) {
ValueHolder holder = v -> value = v;
return dispatch(this, type, holder, node);
}
return this;
}
use of org.eclipse.titan.codegenerator.Scope 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;
}
Aggregations