/** * Creates a new tree field only constructor {@code AValueDefinition TAG=value} node with the given nodes as children. * @deprecated This method should not be used, use AstFactory instead. * The basic child nodes are removed from their previous parents. * @param pattern_ the {@link PPattern} node for the {@code pattern} child of this {@link AValueDefinition} node * @param expression_ the {@link PExp} node for the {@code expression} child of this {@link AValueDefinition} node * @param defs_ the {@link NodeList} node for the {@code defs} child of this {@link AValueDefinition} node */ public AValueDefinition(ILexLocation location_, NameScope nameScope_, Boolean used_, AAccessSpecifierAccessSpecifier access_, Pass pass_, PPattern pattern_, PExp expression_, List<? extends PDefinition> defs_) { super(location_,null,nameScope_,used_,null,access_,null,pass_); this.setPattern(pattern_); this.setExpression(expression_); this.setDefs(defs_); }
/** * Creates a new complete constructor {@code AValueDefinition} node with the given nodes as children. * @deprecated This method should not be used, use AstFactory instead. * The basic child nodes are removed from their previous parents. * @param pattern_ the {@link PPattern} node for the {@code pattern} child of this {@link AValueDefinition} node * @param expression_ the {@link PExp} node for the {@code expression} child of this {@link AValueDefinition} node * @param defs_ the {@link NodeList} node for the {@code defs} child of this {@link AValueDefinition} node * @param expType_ the {@link PType} <b>graph</a> node for the {@code expType} child of this {@link AValueDefinition} node. * <i>The parent of this {@code expType } will not be changed by adding it to this node.</i> */ public AValueDefinition(ILexLocation location_, ILexNameToken name_, NameScope nameScope_, Boolean used_, SClassDefinition classDefinition_, AAccessSpecifierAccessSpecifier access_, PType type_, Pass pass_, PPattern pattern_, PExp expression_, List<? extends PDefinition> defs_, PType expType_) { super(location_,name_,nameScope_,used_,classDefinition_,access_,type_,pass_); this.setPattern(pattern_); this.setExpression(expression_); this.setDefs(defs_); this.setExpType(expType_); }
public static AValueDefinition newAValueDefinition(PPattern p, NameScope scope, PType type, PExp readExpression) { AValueDefinition result = new AValueDefinition(); // Definition initialization initDefinition(result, Pass.VALUES, p.getLocation(), null, scope); result.setPattern(p); result.setType(type); result.setExpression(readExpression); List<PDefinition> defs = new Vector<PDefinition>(); for (ILexNameToken var : af.createPPatternAssistant().getVariableNames(p)) { defs.add(AstFactory.newAUntypedDefinition(result.getLocation(), var, scope)); } result.setDefs(defs); return result; }
public void updateDefs(AValueDefinition node, TypeCheckInfo question) { PType type = node.getType(); PPattern pattern = node.getPattern(); List<PDefinition> newdefs = af.createPPatternAssistant().getDefinitions(pattern, type, node.getNameScope()); // The untyped definitions may have had "used" markers, so we copy // those into the new typed definitions, lest we get warnings. We // also mark the local definitions as "ValueDefintions" (proxies), // so that classes can be constructed correctly (values are statics). for (PDefinition d : newdefs) { for (PDefinition u : node.getDefs()) { if (u.getName().equals(d.getName())) { if (af.createPDefinitionAssistant().isUsed(u)) { af.createPDefinitionAssistant().markUsed(d); } break; } } ALocalDefinition ld = (ALocalDefinition) d; ld.setValueDefinition(node.clone()); } node.setDefs(newdefs); List<PDefinition> defs = node.getDefs(); af.createPDefinitionListAssistant().setAccessibility(defs, node.getAccess().clone()); af.createPDefinitionListAssistant().setClassDefinition(defs, node.getClassDefinition()); }