/** * 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); }
/** * 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); }
/** * 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; }
@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 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()); }