@Override public PType caseANewObjectDesignator(ANewObjectDesignator node, TypeCheckInfo question) throws AnalysisException { return node.getExpression().apply(THIS, new TypeCheckInfo(question.assistantFactory, question.env, NameScope.NAMESANDSTATE, question.qualifiers)); }
inANewExp(node); if(node.getType() != null && !_visitedNodes.contains(node.getType())) node.getType().apply(this); if(node.getClassName() != null ) node.getClassName().apply(this); List<PExp> copy = new ArrayList<PExp>(node.getArgs()); for( PExp e : copy) if(node.getClassdef() != null && !_visitedNodes.contains(node.getClassdef())) node.getClassdef().apply(this); if(node.getCtorDefinition() != null && !_visitedNodes.contains(node.getCtorDefinition())) node.getCtorDefinition().apply(this);
/** * Creates a new complete constructor {@code ANewExp} 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 ILexIdentifierToken} node for the {@code className} child of this {@link ANewExp} node * @param args_ the {@link NodeList} node for the {@code args} child of this {@link ANewExp} node * @param classdef_ the {@link SClassDefinition} <b>graph</a> node for the {@code classdef} child of this {@link ANewExp} node. * <i>The parent of this {@code classdef } will not be changed by adding it to this node.</i> * @param ctorDefinition_ the {@link PDefinition} <b>graph</a> node for the {@code ctorDefinition} child of this {@link ANewExp} node. * <i>The parent of this {@code ctorDefinition } will not be changed by adding it to this node.</i> */ public ANewExp(PType type_, ILexLocation location_, ILexIdentifierToken className_, List<? extends PExp> args_, SClassDefinition classdef_, PDefinition ctorDefinition_) { super(type_,location_); this.setClassName(className_); this.setArgs(args_); this.setClassdef(classdef_); this.setCtorDefinition(ctorDefinition_); }
PDefinition cdef = question.env.findType(node.getClassName().getClassName(), null); TypeCheckerErrors.report(3133, "Class name " + node.getClassName() + " not in scope", node.getLocation(), node); node.setType(AstFactory.newAUnknownType(node.getLocation())); return node.getType(); TypeCheckerErrors.report(3348, "Cannot use 'new' in a functional context", node.getLocation(), node); node.setClassdef((SClassDefinition) cdef); SClassDefinition classdef = node.getClassdef(); + classdef.getName(), node.getLocation(), node); + classdef.getName(), node.getLocation(), node); for (PExp a : node.getArgs()) if (!node.getArgs().isEmpty()) // Not having a default ctor is OK TypeCheckerErrors.report(3134, "Class has no constructor with these parameter types", node.getLocation(), node); question.assistantFactory.createSClassDefinitionAssistant(); TypeCheckerErrors.detail("Called", SClassDefinitionAssistantTC.getCtorName(classdef, argtypes)); TypeCheckerErrors.report(3297, "Cannot use default constructor for this class", node.getLocation(), node); TypeCheckerErrors.report(3135, "Class has no constructor with these parameter types", node.getLocation(), node); question.assistantFactory.createSClassDefinitionAssistant();
@Override public Value caseANewExp(ANewExp node, Context ctxt) throws AnalysisException { BreakpointManager.getBreakpoint(node).check(node.getLocation(), ctxt); node.getClassName().getLocation().hit(); try { ValueList argvals = new ValueList(); for (PExp arg : node.getArgs()) { argvals.add(arg.apply(VdmRuntime.getExpressionEvaluator(), ctxt)); } ObjectValue objval = ctxt.assistantFactory.createSClassDefinitionAssistant().newInstance(node.getClassdef(), node.getCtorDefinition(), argvals, ctxt); if (objval.invlistener != null) { // Check the initial values of the object's fields objval.invlistener.doInvariantChecks = true; objval.invlistener.changedValue(node.getLocation(), objval, ctxt); } return objval; } catch (ValueException e) { return VdmRuntimeError.abort(node.getLocation(), e); } }
@Override public SExpIR caseANewExp(ANewExp node, IRInfo question) throws AnalysisException { String className = node.getClassdef().getName().getName(); ATypeNameIR typeName = new ATypeNameIR(); typeName.setDefiningClass(null); typeName.setName(className); PType type = node.getType(); LinkedList<PExp> nodeArgs = node.getArgs(); ANewExpIR newExp = new ANewExpIR(); STypeIR typeCg = type.apply(question.getTypeVisitor(), question); newExp.setType(typeCg); newExp.setName(typeName); LinkedList<SExpIR> newExpArgs = newExp.getArgs(); for (PExp arg : nodeArgs) { SExpIR argCg = arg.apply(question.getExpVisitor(), question); if (argCg != null) { newExpArgs.add(argCg); } else { return null; } } return newExp; }
@Override public ValueList caseANewExp(ANewExp exp, ObjectContext ctxt) throws AnalysisException { return af.createPExpAssistant().getValues(exp.getArgs(), ctxt); }
@Override public void caseANewExp(ANewExp node) throws AnalysisException { super.caseANewExp(node); instantiatedClasses.add(node.getClassName().getName()); } });
public LexNameList caseANewExp(ANewExp expression) throws org.overture.ast.analysis.AnalysisException { return af.createPExpAssistant().getOldNames(expression.getArgs()); }
inANewExp(node); if(node.getType() != null && !_visitedNodes.contains(node.getType())) node.getType().apply(this); if(node.getClassName() != null ) node.getClassName().apply(this); List<PExp> copy = new ArrayList<PExp>(node.getArgs()); for( PExp e : copy) if(node.getClassdef() != null && !_visitedNodes.contains(node.getClassdef())) node.getClassdef().apply(this); if(node.getCtorDefinition() != null && !_visitedNodes.contains(node.getCtorDefinition())) node.getCtorDefinition().apply(this);
@Override public Value caseANewObjectDesignator(ANewObjectDesignator node, Context ctxt) throws AnalysisException { return node.getExpression().apply(VdmRuntime.getExpressionEvaluator(), ctxt); }
@Override public IProofObligationList caseANewExp(ANewExp node, IPOContextStack question) throws AnalysisException { IProofObligationList obligations = new ProofObligationList(); for (PExp exp : node.getArgs()) { obligations.addAll(exp.apply(mainVisitor, question)); } return obligations; }
inANewExp(node, question); if(node.getType() != null && !_visitedNodes.contains(node.getType())) node.getType().apply(this, question); if(node.getClassName() != null ) node.getClassName().apply(this, question); List<PExp> copy = new ArrayList<PExp>(node.getArgs()); for( PExp e : copy) if(node.getClassdef() != null && !_visitedNodes.contains(node.getClassdef())) node.getClassdef().apply(this, question); if(node.getCtorDefinition() != null && !_visitedNodes.contains(node.getCtorDefinition())) node.getCtorDefinition().apply(this, question);
/** * Called by the {@link ANewObjectDesignator} node from {@link ANewObjectDesignator#apply(IPOFAnalysis)}. * @param node the calling {@link ANewObjectDesignator} node */ public void caseANewObjectDesignator(ANewObjectDesignator node) throws AnalysisException { _visitedNodes.add(node); inANewObjectDesignator(node); if(node.getExpression() != null && !_visitedNodes.contains(node.getExpression())) { node.getExpression().apply(this); } outANewObjectDesignator(node); }
@Override public PExp caseANewExp(ANewExp exp, Integer lineno) throws AnalysisException { PExp found = findExpressionBaseCase(exp, lineno); if (found != null) { return found; } return af.createPExpAssistant().findExpression(exp.getArgs(), lineno); }
mergeReturns(retVal,inANewExp(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)); List<PExp> copy = new ArrayList<PExp>(node.getArgs()); for( PExp e : copy) if(node.getClassdef() != null && !_visitedNodes.contains(node.getClassdef())) mergeReturns(retVal,node.getClassdef().apply(this)); if(node.getCtorDefinition() != null && !_visitedNodes.contains(node.getCtorDefinition())) mergeReturns(retVal,node.getCtorDefinition().apply(this));
/** * Called by the {@link ANewObjectDesignator} node from {@link ANewObjectDesignator#apply(IAnalysis)}. * @param node the calling {@link ANewObjectDesignator} node */ public void caseANewObjectDesignator(ANewObjectDesignator node, Q question) throws AnalysisException { _visitedNodes.add(node); inANewObjectDesignator(node, question); if(node.getExpression() != null && !_visitedNodes.contains(node.getExpression())) { node.getExpression().apply(this, question); } outANewObjectDesignator(node, question); }
PExp exp = newExp.getArgs().size() > 0 ? newExp.getArgs().get(1) : null; double speed = 0; if (exp instanceof AIntLiteralExp) AIntLiteralExp frequencyExp = (AIntLiteralExp) newExp.getArgs().get(1); speed = frequencyExp.getValue().getValue(); } else if (exp instanceof ARealLiteralExp) ARealLiteralExp frequencyExp = (ARealLiteralExp) newExp.getArgs().get(1); speed = frequencyExp.getValue().getValue();
mergeReturns(retVal,inANewExp(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)); List<PExp> copy = new ArrayList<PExp>(node.getArgs()); for( PExp e : copy) if(node.getClassdef() != null && !_visitedNodes.contains(node.getClassdef())) mergeReturns(retVal,node.getClassdef().apply(this, question)); if(node.getCtorDefinition() != null && !_visitedNodes.contains(node.getCtorDefinition())) mergeReturns(retVal,node.getCtorDefinition().apply(this, question));
/** * Called by the {@link ANewObjectDesignator} node from {@link ANewObjectDesignator#apply(IAnalysis)}. * @param node the calling {@link ANewObjectDesignator} node */ public void caseANewObjectDesignator(ANewObjectDesignator node) throws AnalysisException { _visitedNodes.add(node); inANewObjectDesignator(node); if(node.getExpression() != null && !_visitedNodes.contains(node.getExpression())) { node.getExpression().apply(this); } outANewObjectDesignator(node); }