public static AApplyObjectDesignator newAApplyObjectDesignator( PObjectDesignator object, List<PExp> args) { AApplyObjectDesignator result = new AApplyObjectDesignator(); result.setLocation(object.getLocation()); result.setObject(object); result.setArgs(args); return result; }
/** * Returns a deep clone of this {@link AApplyObjectDesignator} node. * @return a deep clone of this {@link AApplyObjectDesignator} node */ public AApplyObjectDesignator clone() { return new AApplyObjectDesignator( _location, cloneNode(_object), cloneList(_args) ); }
/** * Called by the {@link AApplyObjectDesignator} node from {@link AApplyObjectDesignator#apply(IAnalysis)}. * @param node the calling {@link AApplyObjectDesignator} node */ public void caseAApplyObjectDesignator(AApplyObjectDesignator node) throws AnalysisException { _visitedNodes.add(node); inAApplyObjectDesignator(node); if(node.getObject() != null && !_visitedNodes.contains(node.getObject())) { node.getObject().apply(this); } { List<PExp> copy = new ArrayList<PExp>(node.getArgs()); for( PExp e : copy) { if(!_visitedNodes.contains(e)) { e.apply(this); } } } outAApplyObjectDesignator(node); }
Value uv = node.getObject().apply(VdmRuntime.getStatementEvaluator(), ctxt); Value v = uv.deref(); Value a = node.getArgs().get(0).apply(VdmRuntime.getExpressionEvaluator(), ctxt); Value rv = mv.get(a); Value a = node.getArgs().get(0).apply(VdmRuntime.getExpressionEvaluator(), ctxt); int i = (int) a.intValue(ctxt) - 1; VdmRuntimeError.abort(node.getLocation(), 4042, "Sequence does not contain key: " + a, ctxt); for (PExp arg : node.getArgs()) return fv.eval(node.getLocation(), argvals, ctxt); } else if (v instanceof OperationValue) for (PExp arg : node.getArgs()) return ov.eval(node.getLocation(), argvals, ctxt); } else return VdmRuntimeError.abort(node.getLocation(), 4043, "Object designator is not a map, sequence, operation or function", ctxt); return VdmRuntimeError.abort(node.getLocation(), e);
public PType seqApply(AApplyObjectDesignator node, SSeqType seq, Environment env, NameScope scope, boolean unique, IQuestionAnswer<TypeCheckInfo, PType> rootVisitor, TypeCheckInfo question) throws AnalysisException { if (node.getArgs().size() != 1) { TypeCheckerErrors.concern(unique, 3252, "Sequence application must have one argument", node.getLocation(), node); return AstFactory.newAUnknownType(node.getLocation()); } PType argtype = node.getArgs().get(0).apply(rootVisitor, new TypeCheckInfo(question.assistantFactory, env, scope)); if (!env.af.createPTypeAssistant().isNumeric(argtype)) { TypeCheckerErrors.concern(unique, 3253, "Sequence argument is not numeric", node.getLocation(), node); TypeCheckerErrors.detail(unique, "Type", argtype); } return seq.getSeqof(); }
/** * Called by the {@link AApplyObjectDesignator} node from {@link AApplyObjectDesignator#apply(IPOFAnalysis)}. * @param node the calling {@link AApplyObjectDesignator} node */ public void caseAApplyObjectDesignator(AApplyObjectDesignator node) throws AnalysisException { _visitedNodes.add(node); inAApplyObjectDesignator(node); if(node.getObject() != null && !_visitedNodes.contains(node.getObject())) { node.getObject().apply(this); } { List<PExp> copy = new ArrayList<PExp>(node.getArgs()); for( PExp e : copy) { if(!_visitedNodes.contains(e)) { e.apply(this); } } } outAApplyObjectDesignator(node); }
for (PExp a : node.getArgs()) PType type = node.getObject().apply(THIS, new TypeCheckInfo(question.assistantFactory, question.env, null, argtypes)); boolean unique = !question.assistantFactory.createPTypeAssistant().isUnion(type); PTypeSet result = new PTypeSet(question.assistantFactory); TypeCheckerErrors.report(3249, "Object designator is not a map, sequence, function or operation", node.getLocation(), node); TypeCheckerErrors.detail2("Designator", node.getObject(), "Type", type); return AstFactory.newAUnknownType(node.getLocation()); return result.getType(node.getLocation());
public PType mapApply(AApplyObjectDesignator node, SMapType map, Environment env, NameScope scope, boolean unique, IQuestionAnswer<TypeCheckInfo, PType> rootVisitor) throws AnalysisException { if (node.getArgs().size() != 1) { TypeCheckerErrors.concern(unique, 3250, "Map application must have one argument", node.getLocation(), node); return AstFactory.newAUnknownType(node.getLocation()); } PType argtype = node.getArgs().get(0).apply(rootVisitor, new TypeCheckInfo(env.af, env, scope)); if (!env.af.getTypeComparator().compatible(map.getFrom(), argtype)) { TypeCheckerErrors.concern(unique, 3251, "Map application argument is incompatible type", node.getLocation(), node); TypeCheckerErrors.detail2(unique, "Map domain", map.getFrom(), "Argument", argtype); } return map.getTo(); }
/** * Called by the {@link AApplyObjectDesignator} node from {@link AApplyObjectDesignator#apply(IAnalysis)}. * @param node the calling {@link AApplyObjectDesignator} node */ public void caseAApplyObjectDesignator(AApplyObjectDesignator node, Q question) throws AnalysisException { _visitedNodes.add(node); inAApplyObjectDesignator(node, question); if(node.getObject() != null && !_visitedNodes.contains(node.getObject())) { node.getObject().apply(this, question); } { List<PExp> copy = new ArrayList<PExp>(node.getArgs()); for( PExp e : copy) { if(!_visitedNodes.contains(e)) { e.apply(this, question); } } } outAApplyObjectDesignator(node, question); }
if (node.getArgs().size() > ptypes.size()) TypeCheckerErrors.concern(unique, 3257, "Too many arguments", node.getLocation(), node); TypeCheckerErrors.detail2(unique, "Args", node.getArgs(), "Params", ptypes); return optype.getResult(); } else if (node.getArgs().size() < ptypes.size()) TypeCheckerErrors.concern(unique, 3258, "Too few arguments", node.getLocation(), node); TypeCheckerErrors.detail2(unique, "Args", node.getArgs(), "Params", ptypes); return optype.getResult(); for (PExp a : node.getArgs()) + i, node.getLocation(), node); TypeCheckerErrors.detail2(unique, "Expect", pt, "Actual", at);
/** * Creates a deep clone of this {@link AApplyObjectDesignator} 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 AApplyObjectDesignator} node */ public AApplyObjectDesignator clone(Map<INode,INode> oldToNewMap) { AApplyObjectDesignator node = new AApplyObjectDesignator( _location, cloneNode(_object, oldToNewMap), cloneList(_args, oldToNewMap) ); oldToNewMap.put(this, node); return node; }
/** * Called by the {@link AApplyObjectDesignator} node from {@link AApplyObjectDesignator#apply(IAnalysis)}. * @param node the calling {@link AApplyObjectDesignator} node */ public A caseAApplyObjectDesignator(AApplyObjectDesignator node) throws AnalysisException { _visitedNodes.add(node); A retVal = createNewReturnValue(node); mergeReturns(retVal,inAApplyObjectDesignator(node)); if(node.getObject() != null && !_visitedNodes.contains(node.getObject())) { mergeReturns(retVal,node.getObject().apply(this)); } { List<PExp> copy = new ArrayList<PExp>(node.getArgs()); for( PExp e : copy) { if(!_visitedNodes.contains(e)) { mergeReturns(retVal,e.apply(this)); } } } mergeReturns(retVal,outAApplyObjectDesignator(node)); return retVal; }
if (node.getArgs().size() > ptypes.size()) TypeCheckerErrors.concern(unique, 3254, "Too many arguments", node.getLocation(), node); TypeCheckerErrors.detail2(unique, "Args", node.getArgs(), "Params", ptypes); return ftype.getResult(); } else if (node.getArgs().size() < ptypes.size()) TypeCheckerErrors.concern(unique, 3255, "Too few arguments", node.getLocation(), node); TypeCheckerErrors.detail2(unique, "Args", node.getArgs(), "Params", ptypes); return ftype.getResult(); for (PExp a : node.getArgs()) + i, node.getLocation(), node); TypeCheckerErrors.detail2(unique, "Expect", pt, "Actual", at);
/** * Called by the {@link AApplyObjectDesignator} node from {@link AApplyObjectDesignator#apply(IAnalysis)}. * @param node the calling {@link AApplyObjectDesignator} node */ public A caseAApplyObjectDesignator(AApplyObjectDesignator node, Q question) throws AnalysisException { _visitedNodes.add(node); A retVal = createNewReturnValue(node, question); mergeReturns(retVal,inAApplyObjectDesignator(node, question)); if(node.getObject() != null && !_visitedNodes.contains(node.getObject())) { mergeReturns(retVal,node.getObject().apply(this, question)); } { List<PExp> copy = new ArrayList<PExp>(node.getArgs()); for( PExp e : copy) { if(!_visitedNodes.contains(e)) { mergeReturns(retVal,e.apply(this, question)); } } } mergeReturns(retVal,outAApplyObjectDesignator(node, question)); return retVal; }
@Override public SObjectDesignatorIR caseAApplyObjectDesignator( AApplyObjectDesignator node, IRInfo question) throws AnalysisException { PObjectDesignator obj = node.getObject(); SObjectDesignatorIR objCg = obj.apply(question.getObjectDesignatorVisitor(), question); AApplyObjectDesignatorIR applyObjDesignator = new AApplyObjectDesignatorIR(); applyObjDesignator.setObject(objCg); LinkedList<SExpIR> newExpArgs = applyObjDesignator.getArgs(); for (PExp arg : node.getArgs()) { SExpIR argCg = arg.apply(question.getExpVisitor(), question); if (argCg != null) { newExpArgs.add(argCg); } else { return null; } } return applyObjDesignator; }
List<PExp> args = oad.getArgs(); if (oad.getObject() instanceof AFieldObjectDesignator) AFieldObjectDesignator ofd = (AFieldObjectDesignator) oad.getObject(); } else if (oad.getObject() instanceof AIdentifierObjectDesignator) AIdentifierObjectDesignator oid = (AIdentifierObjectDesignator) oad.getObject(); return AstFactory.newACallStm(oid.getName(), args); } else