/** * Called by the {@link AFieldExp} node from {@link AFieldExp#apply(IAnalysis)}. * @param node the calling {@link AFieldExp} node */ public void caseAFieldExp(AFieldExp node, Q question) throws AnalysisException { _visitedNodes.add(node); inAFieldExp(node, question); if(node.getType() != null && !_visitedNodes.contains(node.getType())) { node.getType().apply(this, question); } if(node.getObject() != null && !_visitedNodes.contains(node.getObject())) { node.getObject().apply(this, question); } if(node.getMemberName() != null ) { node.getMemberName().apply(this, question); } if(node.getField() != null ) { node.getField().apply(this, question); } outAFieldExp(node, question); }
public static AFieldExp newAFieldExp(PExp object, ILexNameToken field) { AFieldExp result = new AFieldExp(); result.setLocation(object.getLocation()); result.setObject(object); result.setField(new LexIdentifierToken(field.getName(), field.getOld(), field.getLocation())); result.setMemberName(field); result.getField().getLocation().executable(true); return result; }
/** * Creates a new tree field only constructor {@code AFieldExp TAG=field} 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 object_ the {@link PExp} node for the {@code object} child of this {@link AFieldExp} node * @param memberName_ the {@link ILexNameToken} node for the {@code memberName} child of this {@link AFieldExp} node * @param field_ the {@link ILexIdentifierToken} node for the {@code field} child of this {@link AFieldExp} node */ public AFieldExp(ILexLocation location_, PExp object_, ILexNameToken memberName_, ILexIdentifierToken field_) { super(null,location_); this.setObject(object_); this.setMemberName(memberName_); this.setField(field_); }
public static PExp newAFieldExp(PExp object, ILexIdentifierToken field) { AFieldExp result = new AFieldExp(); result.setLocation(object.getLocation()); result.setObject(object); result.setField(field); result.getField().getLocation().executable(true); return result; }
PType root = node.getObject().apply(THIS, new TypeCheckInfo(question.assistantFactory, question.env, question.scope)); node.setMemberName(new LexNameToken("?", node.getField())); node.setType(root); return root; AFieldField cf = question.assistantFactory.createARecordInvariantTypeAssistant().findField(rec, node.getField().getName()); LexNameToken sname = new LexNameToken(rec.getName().getModule(), node.getField().getName(), node.getLocation()); "Unknown field " + node.getField().getName() + " in record " + rec.getName(), node.getField().getLocation(), node.getField()); ILexNameToken memberName = node.getMemberName(); memberName = question.assistantFactory.createAClassTypeAssistant().getMemberName(cls, node.getField()); node.setMemberName(memberName); + cls.getName().getName(), node.getField().getLocation(), node.getField()); + cls.getName().getName(), node.getField().getLocation(), node.getField()); "Field '" + node.getField().getName() + "' applied to non-aggregate type", node.getObject().getLocation(), node.getObject()); node.setType(AstFactory.newAUnknownType(node.getLocation())); return node.getType();
public Value evaluate(AFieldExp node, Context ctxt) throws AnalysisException { Value v = node.getObject().apply(VdmRuntime.getExpressionEvaluator(), ctxt); PType objtype = null; Value r = null; if (v.isType(ObjectValue.class)) { ObjectValue ov = v.objectValue(ctxt); objtype = ov.type; r = ov.get(node.getMemberName(), node.getMemberName().getExplicit()); } else { RecordValue rv = v.recordValue(ctxt); objtype = rv.type; FieldMap fields = rv.fieldmap; r = fields.get(node.getField().getName()); } if (r == null) { VdmRuntimeError.abort(node.getLocation(), 4006, "Type " + objtype + " has no field " + node.getField().getName(), ctxt); } return r; }
@Override public PExp caseAFieldStateDesignator(AFieldStateDesignator node) throws AnalysisException { // pack this with the output of the visitor recursive calls. PExp value = node.getObject().apply(this); AFieldExp fieldExp = new AFieldExp(); fieldExp.setObject(value.clone()); fieldExp.setField(node.getField().clone()); // Not 100% sure these 2 match fieldExp.setMemberName(node.getObjectfield().clone()); fieldExp.setType(node.getType().clone()); return fieldExp; }
@Override public LexNameSet caseAFieldExp(AFieldExp node, FreeVarInfo info) throws AnalysisException { return node.getObject().apply(this, info); }
@Override public Value caseAFieldExp(AFieldExp node, Context ctxt) throws AnalysisException { BreakpointManager.getBreakpoint(node).check(node.getLocation(), ctxt); node.getField().getLocation().hit(); try { return ctxt.assistantFactory.createAFieldExpAssistant().evaluate(node, ctxt); } catch (ValueException e) { return VdmRuntimeError.abort(node.getLocation(), e); } }
throws AnalysisException ValueList values = exp.getObject().apply(THIS, ctxt); VdmRuntimeError.abort(exp.getLocation(), e); return null; } catch (AnalysisException e)
@Override public IProofObligationList caseAFieldExp(AFieldExp node, IPOContextStack question) throws AnalysisException { return node.getObject().apply(mainVisitor, question); }
/** * Creates a new complete constructor {@code AFieldExp} 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 object_ the {@link PExp} node for the {@code object} child of this {@link AFieldExp} node * @param memberName_ the {@link ILexNameToken} node for the {@code memberName} child of this {@link AFieldExp} node * @param field_ the {@link ILexIdentifierToken} node for the {@code field} child of this {@link AFieldExp} node */ public AFieldExp(PType type_, ILexLocation location_, PExp object_, ILexNameToken memberName_, ILexIdentifierToken field_) { super(type_,location_); this.setObject(object_); this.setMemberName(memberName_); this.setField(field_); }
/** * Creates a deep clone of this {@link AFieldExp} node while putting all * old node-new node relations in the map {@code oldToNewMap}. * @param oldToNewMap the map filled with the old node-new node relation * @return a deep clone of this {@link AFieldExp} node */ public AFieldExp clone(Map<INode,INode> oldToNewMap) { AFieldExp node = new AFieldExp( _type, _location, cloneNode(_object, oldToNewMap), cloneNode(_memberName, oldToNewMap), cloneNode(_field, oldToNewMap) ); oldToNewMap.put(this, node); return node; }
/** * Called by the {@link AFieldExp} node from {@link AFieldExp#apply(IAnalysis)}. * @param node the calling {@link AFieldExp} node */ public void caseAFieldExp(AFieldExp node) throws AnalysisException { _visitedNodes.add(node); inAFieldExp(node); if(node.getType() != null && !_visitedNodes.contains(node.getType())) { node.getType().apply(this); } if(node.getObject() != null && !_visitedNodes.contains(node.getObject())) { node.getObject().apply(this); } if(node.getMemberName() != null ) { node.getMemberName().apply(this); } if(node.getField() != null ) { node.getField().apply(this); } outAFieldExp(node); }
public LexNameList caseAFieldExp(AFieldExp expression) throws org.overture.ast.analysis.AnalysisException { return af.createPExpAssistant().getOldNames(expression.getObject()); }
/** * Called by the {@link AFieldExp} node from {@link AFieldExp#apply(IPOFAnalysis)}. * @param node the calling {@link AFieldExp} node */ public void caseAFieldExp(AFieldExp node) throws AnalysisException { _visitedNodes.add(node); inAFieldExp(node); if(node.getType() != null && !_visitedNodes.contains(node.getType())) { node.getType().apply(this); } if(node.getObject() != null && !_visitedNodes.contains(node.getObject())) { node.getObject().apply(this); } if(node.getMemberName() != null ) { node.getMemberName().apply(this); } if(node.getField() != null ) { node.getField().apply(this); } outAFieldExp(node); }
@Override public PExp caseAFieldExp(AFieldExp exp, Integer lineno) throws AnalysisException { PExp found = findExpressionBaseCase(exp, lineno); if (found != null) { return found; } return exp.getObject().apply(THIS, lineno);// PExpAssistantInterpreter.findExpression(exp.getObject(), lineno); }
/** * Called by the {@link AFieldExp} node from {@link AFieldExp#apply(IAnalysis)}. * @param node the calling {@link AFieldExp} node */ public A caseAFieldExp(AFieldExp node) throws AnalysisException { _visitedNodes.add(node); A retVal = createNewReturnValue(node); mergeReturns(retVal,inAFieldExp(node)); if(node.getType() != null && !_visitedNodes.contains(node.getType())) { mergeReturns(retVal,node.getType().apply(this)); } if(node.getObject() != null && !_visitedNodes.contains(node.getObject())) { mergeReturns(retVal,node.getObject().apply(this)); } if(node.getMemberName() != null ) { mergeReturns(retVal,node.getMemberName().apply(this)); } if(node.getField() != null ) { mergeReturns(retVal,node.getField().apply(this)); } mergeReturns(retVal,outAFieldExp(node)); return retVal; }