/** * Called by the {@link AIsOfClassExp} node from {@link AIsOfClassExp#apply(IAnalysis)}. * @param node the calling {@link AIsOfClassExp} node */ public void caseAIsOfClassExp(AIsOfClassExp node) throws AnalysisException { _visitedNodes.add(node); inAIsOfClassExp(node); if(node.getType() != null && !_visitedNodes.contains(node.getType())) { node.getType().apply(this); } if(node.getClassName() != null ) { node.getClassName().apply(this); } if(node.getClassType() != null && !_visitedNodes.contains(node.getClassType())) { node.getClassType().apply(this); } if(node.getExp() != null && !_visitedNodes.contains(node.getExp())) { node.getExp().apply(this); } outAIsOfClassExp(node); }
/** * Creates a new complete constructor {@code AIsOfClassExp} 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 className_ the {@link ILexNameToken} node for the {@code className} child of this {@link AIsOfClassExp} node * @param classType_ the {@link AClassType} <b>graph</a> node for the {@code classType} child of this {@link AIsOfClassExp} node. * <i>The parent of this {@code classType } will not be changed by adding it to this node.</i> * @param exp_ the {@link PExp} node for the {@code exp} child of this {@link AIsOfClassExp} node */ public AIsOfClassExp(PType type_, ILexLocation location_, ILexNameToken className_, AClassType classType_, PExp exp_) { super(type_,location_); this.setClassName(className_); this.setClassType(classType_); this.setExp(exp_); }
@Override // RWL See [1] pg. 64-65 public IProofObligationList caseAIsOfClassExp(AIsOfClassExp node, IPOContextStack question) throws AnalysisException { question.noteType(node.getExp(), node.getClassType()); return node.getExp().apply(mainVisitor, question); }
@Override public PType caseAIsOfClassExp(AIsOfClassExp node, TypeCheckInfo question) throws AnalysisException { ILexNameToken classname = node.getClassName(); PDefinition cls = question.env.findType(classname, null); if (cls == null || !(cls instanceof SClassDefinition)) { TypeCheckerErrors.report(3115, "Undefined class type: " + classname.getName(), node.getLocation(), node); } else { node.setClassType((AClassType) cls.getType()); } question.qualifiers = null; PType rt = node.getExp().apply(THIS, question.newConstraint(null)); if (!question.assistantFactory.createPTypeAssistant().isClass(rt, question.env)) { TypeCheckerErrors.report(3266, "Argument is not an object", node.getExp().getLocation(), node.getExp()); } node.setType(AstFactory.newABooleanBasicType(node.getLocation())); return question.assistantFactory.createPTypeAssistant().checkConstraint(question.constraint, node.getType(), node.getLocation()); }
@Override public SExpIR caseAIsOfClassExp(AIsOfClassExp node, IRInfo question) throws AnalysisException { PType type = node.getType(); AClassType classType = node.getClassType(); PExp objRef = node.getExp(); STypeIR typeCg = type.apply(question.getTypeVisitor(), question); STypeIR classTypeCg = classType.apply(question.getTypeVisitor(), question); if (!(classTypeCg instanceof AClassTypeIR)) { log.error("Unexpected class type encountered for " + AIsOfClassExp.class.getName() + ". Expected class type: " + AClassTypeIR.class.getName() + ". Got: " + typeCg.getClass().getName() + " at " + node.getLocation()); } SExpIR objRefCg = objRef.apply(question.getExpVisitor(), question); AIsOfClassExpIR instanceOfExp = new AIsOfClassExpIR(); instanceOfExp.setType(typeCg); instanceOfExp.setCheckedType(classTypeCg); instanceOfExp.setExp(objRefCg); return instanceOfExp; }
@Override public Value caseAIsOfClassExp(AIsOfClassExp node, Context ctxt) throws AnalysisException { BreakpointManager.getBreakpoint(node).check(node.getLocation(), ctxt); node.getClassName().getLocation().hit(); try { Value v = node.getExp().apply(VdmRuntime.getExpressionEvaluator(), ctxt).deref(); if (!(v instanceof ObjectValue)) { return new BooleanValue(false); } ObjectValue ov = v.objectValue(ctxt); return new BooleanValue(isOfClass(ov, node.getClassName().getName())); } catch (ValueException e) { return VdmRuntimeError.abort(node.getLocation(), e); } }
@Override public ValueList caseAIsOfClassExp(AIsOfClassExp exp, ObjectContext ctxt) throws AnalysisException { return exp.getExp().apply(THIS, ctxt); }
@Override public PExp caseAIsOfClassExp(AIsOfClassExp exp, Integer lineno) throws AnalysisException { PExp found = findExpressionBaseCase(exp, lineno); if (found != null) { return found; } return exp.getExp().apply(THIS, lineno); }
/** * Called by the {@link AIsOfClassExp} node from {@link AIsOfClassExp#apply(IAnalysis)}. * @param node the calling {@link AIsOfClassExp} node */ public void caseAIsOfClassExp(AIsOfClassExp node, Q question) throws AnalysisException { _visitedNodes.add(node); inAIsOfClassExp(node, question); if(node.getType() != null && !_visitedNodes.contains(node.getType())) { node.getType().apply(this, question); } if(node.getClassName() != null ) { node.getClassName().apply(this, question); } if(node.getClassType() != null && !_visitedNodes.contains(node.getClassType())) { node.getClassType().apply(this, question); } if(node.getExp() != null && !_visitedNodes.contains(node.getExp())) { node.getExp().apply(this, question); } outAIsOfClassExp(node, question); }
public LexNameList caseAIsOfClassExp(AIsOfClassExp expression) throws org.overture.ast.analysis.AnalysisException { return af.createPExpAssistant().getOldNames(expression.getExp()); }
/** * Called by the {@link AIsOfClassExp} node from {@link AIsOfClassExp#apply(IPOFAnalysis)}. * @param node the calling {@link AIsOfClassExp} node */ public void caseAIsOfClassExp(AIsOfClassExp node) throws AnalysisException { _visitedNodes.add(node); inAIsOfClassExp(node); if(node.getType() != null && !_visitedNodes.contains(node.getType())) { node.getType().apply(this); } if(node.getClassName() != null ) { node.getClassName().apply(this); } if(node.getClassType() != null && !_visitedNodes.contains(node.getClassType())) { node.getClassType().apply(this); } if(node.getExp() != null && !_visitedNodes.contains(node.getExp())) { node.getExp().apply(this); } outAIsOfClassExp(node); }
/** * Called by the {@link AIsOfClassExp} node from {@link AIsOfClassExp#apply(IAnalysis)}. * @param node the calling {@link AIsOfClassExp} node */ public A caseAIsOfClassExp(AIsOfClassExp node) throws AnalysisException { _visitedNodes.add(node); A retVal = createNewReturnValue(node); mergeReturns(retVal,inAIsOfClassExp(node)); if(node.getType() != null && !_visitedNodes.contains(node.getType())) { mergeReturns(retVal,node.getType().apply(this)); } if(node.getClassName() != null ) { mergeReturns(retVal,node.getClassName().apply(this)); } if(node.getClassType() != null && !_visitedNodes.contains(node.getClassType())) { mergeReturns(retVal,node.getClassType().apply(this)); } if(node.getExp() != null && !_visitedNodes.contains(node.getExp())) { mergeReturns(retVal,node.getExp().apply(this)); } mergeReturns(retVal,outAIsOfClassExp(node)); return retVal; }
/** * Called by the {@link AIsOfClassExp} node from {@link AIsOfClassExp#apply(IAnalysis)}. * @param node the calling {@link AIsOfClassExp} node */ public A caseAIsOfClassExp(AIsOfClassExp node, Q question) throws AnalysisException { _visitedNodes.add(node); A retVal = createNewReturnValue(node, question); mergeReturns(retVal,inAIsOfClassExp(node, question)); if(node.getType() != null && !_visitedNodes.contains(node.getType())) { mergeReturns(retVal,node.getType().apply(this, question)); } if(node.getClassName() != null ) { mergeReturns(retVal,node.getClassName().apply(this, question)); } if(node.getClassType() != null && !_visitedNodes.contains(node.getClassType())) { mergeReturns(retVal,node.getClassType().apply(this, question)); } if(node.getExp() != null && !_visitedNodes.contains(node.getExp())) { mergeReturns(retVal,node.getExp().apply(this, question)); } mergeReturns(retVal,outAIsOfClassExp(node, question)); return retVal; }