/** * Creates a new tree field only constructor {@code AInstanceVariableDefinition TAG=instanceVariable} 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 expression_ the {@link PExp} node for the {@code expression} child of this {@link AInstanceVariableDefinition} node * @param initialized_ the {@link Boolean} node for the {@code initialized} child of this {@link AInstanceVariableDefinition} node * @param oldname_ the {@link ILexNameToken} node for the {@code oldname} child of this {@link AInstanceVariableDefinition} node */ public AInstanceVariableDefinition(ILexLocation location_, NameScope nameScope_, Boolean used_, AAccessSpecifierAccessSpecifier access_, Pass pass_, PExp expression_, Boolean initialized_, ILexNameToken oldname_) { super(location_,null,nameScope_,used_,null,access_,null,pass_); this.setExpression(expression_); this.setInitialized(initialized_); this.setOldname(oldname_); }
/** * Creates a new complete constructor {@code AInstanceVariableDefinition} 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 expression_ the {@link PExp} node for the {@code expression} child of this {@link AInstanceVariableDefinition} node * @param expType_ the {@link PType} <b>graph</a> node for the {@code expType} child of this {@link AInstanceVariableDefinition} node. * <i>The parent of this {@code expType } will not be changed by adding it to this node.</i> * @param initialized_ the {@link Boolean} node for the {@code initialized} child of this {@link AInstanceVariableDefinition} node * @param oldname_ the {@link ILexNameToken} node for the {@code oldname} child of this {@link AInstanceVariableDefinition} node */ public AInstanceVariableDefinition(ILexLocation location_, ILexNameToken name_, NameScope nameScope_, Boolean used_, SClassDefinition classDefinition_, AAccessSpecifierAccessSpecifier access_, PType type_, Pass pass_, PExp expression_, PType expType_, Boolean initialized_, ILexNameToken oldname_) { super(location_,name_,nameScope_,used_,classDefinition_,access_,type_,pass_); this.setExpression(expression_); this.setExpType(expType_); this.setInitialized(initialized_); this.setOldname(oldname_); }
public static AInstanceVariableDefinition newAInstanceVariableDefinition( ILexNameToken name, PType type, PExp expression) { AInstanceVariableDefinition result = new AInstanceVariableDefinition(); // Definition initialization initDefinition(result, Pass.VALUES, name.getLocation(), name, NameScope.VARSANDSTATE); result.setType(type); result.setExpression(expression); if (result.getLocation() != null) { result.getLocation().executable(false); } result.setOldname(name.getOldName()); result.setInitialized(!(expression instanceof AUndefinedExp)); return result; }
@Override public PType caseAAssignmentStm(AAssignmentStm node, TypeCheckInfo question) throws AnalysisException { node.setTargetType(node.getTarget().apply(THIS, new TypeCheckInfo(question.assistantFactory, question.env))); node.setExpType(node.getExp().apply(THIS, new TypeCheckInfo(question.assistantFactory, question.env, question.scope, null, node.getTargetType(), null))); if (!question.assistantFactory.getTypeComparator().compatible(node.getTargetType(), node.getExpType())) { TypeCheckerErrors.report(3239, "Incompatible types in assignment", node.getLocation(), node); TypeCheckerErrors.detail2("Target", node.getTarget().getType(), "Expression", node.getExp().getType()); } node.setClassDefinition(question.env.findClassDefinition()); node.setStateDefinition(question.env.findStateDefinition()); AClassTypeAssistantTC assist = question.assistantFactory.createAClassTypeAssistant(); node.setInConstructor(assist.inConstructor(question.env)); if (node.getInConstructor()) { // Mark assignment target as initialized (so no warnings) PDefinition state; state = targetDefinition(node.getTarget(), question); if (state instanceof AInstanceVariableDefinition) { AInstanceVariableDefinition iv = (AInstanceVariableDefinition) state; iv.setInitialized(true); } } node.setType(AstFactory.newAVoidType(node.getLocation())); return node.getType(); }