/** * Creates a new complete constructor {@code AAssignmentStm} 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 target_ the {@link PStateDesignator} node for the {@code target} child of this {@link AAssignmentStm} node * @param exp_ the {@link PExp} node for the {@code exp} child of this {@link AAssignmentStm} node * @param targetType_ the {@link PType} <b>graph</a> node for the {@code targetType} child of this {@link AAssignmentStm} node. * <i>The parent of this {@code targetType } will not be changed by adding it to this node.</i> * @param expType_ the {@link PType} <b>graph</a> node for the {@code expType} child of this {@link AAssignmentStm} node. * <i>The parent of this {@code expType } will not be changed by adding it to this node.</i> * @param classDefinition_ the {@link SClassDefinition} <b>graph</a> node for the {@code classDefinition} child of this {@link AAssignmentStm} node. * <i>The parent of this {@code classDefinition } will not be changed by adding it to this node.</i> * @param stateDefinition_ the {@link AStateDefinition} <b>graph</a> node for the {@code stateDefinition} child of this {@link AAssignmentStm} node. * <i>The parent of this {@code stateDefinition } will not be changed by adding it to this node.</i> * @param inConstructor_ the {@link Boolean} <b>graph</a> node for the {@code inConstructor} child of this {@link AAssignmentStm} node. * <i>The parent of this {@code inConstructor } will not be changed by adding it to this node.</i> */ public AAssignmentStm(ILexLocation location_, PType type_, PStateDesignator target_, PExp exp_, PType targetType_, PType expType_, SClassDefinition classDefinition_, AStateDefinition stateDefinition_, Boolean inConstructor_) { super(location_,type_); this.setTarget(target_); this.setExp(exp_); this.setTargetType(targetType_); this.setExpType(expType_); this.setClassDefinition(classDefinition_); this.setStateDefinition(stateDefinition_); this.setInConstructor(inConstructor_); }
@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(); }