inAApplyExp(node); if(node.getType() != null && !_visitedNodes.contains(node.getType())) node.getType().apply(this); if(node.getRoot() != null && !_visitedNodes.contains(node.getRoot())) node.getRoot().apply(this); List<PExp> copy = new ArrayList<PExp>(node.getArgs()); for( PExp e : copy) List<PType> copy = new ArrayList<PType>(node.getArgtypes()); for( PType e : copy) if(node.getRecursive() != null && !_visitedNodes.contains(node.getRecursive())) node.getRecursive().apply(this);
public PType sequenceApply(AApplyExp node, boolean isSimple, SSeqType seq, TypeCheckInfo question) { if (node.getArgs().size() != 1) { TypeCheckerErrors.concern(isSimple, 3055, "Sequence selector must have one argument", node.getLocation(), node); } else if (!question.assistantFactory.createPTypeAssistant().isNumeric(node.getArgtypes().get(0))) { TypeCheckerErrors.concern(isSimple, 3056, "Sequence application argument must be numeric", node.getLocation(), node); } else if (seq.getEmpty()) { TypeCheckerErrors.concern(isSimple, 3268, "Empty sequence cannot be applied", node.getLocation(), node); } return seq.getSeqof(); }
/** * Creates a new tree field only constructor {@code AApplyExp TAG=apply} 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 root_ the {@link PExp} node for the {@code root} child of this {@link AApplyExp} node * @param args_ the {@link NodeList} node for the {@code args} child of this {@link AApplyExp} node */ public AApplyExp(ILexLocation location_, PExp root_, List<? extends PExp> args_) { super(null,location_); this.setRoot(root_); this.setArgs(args_); }
/** * Creates a new complete constructor {@code AApplyExp} 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 root_ the {@link PExp} node for the {@code root} child of this {@link AApplyExp} node * @param args_ the {@link NodeList} node for the {@code args} child of this {@link AApplyExp} node * @param argtypes_ the {@link GraphNodeList} <b>graph</a> node for the {@code argtypes} child of this {@link AApplyExp} node. * <i>The parent of this {@code argtypes } will not be changed by adding it to this node.</i> * @param recursive_ the {@link PDefinition} <b>graph</a> node for the {@code recursive} child of this {@link AApplyExp} node. * <i>The parent of this {@code recursive } will not be changed by adding it to this node.</i> */ public AApplyExp(PType type_, ILexLocation location_, PExp root_, List<? extends PExp> args_, List<? extends PType> argtypes_, PDefinition recursive_) { super(type_,location_); this.setRoot(root_); this.setArgs(args_); this.setArgtypes(argtypes_); this.setRecursive(recursive_); }
node.setArgtypes(new ArrayList<PType>()); for (PExp a : node.getArgs()) node.getArgtypes().add(a.apply(THIS, noConstraint)); node.setType(node.getRoot().apply(THIS, new TypeCheckInfo(question.assistantFactory, question.env, question.scope, node.getArgtypes()))); if (question.assistantFactory.createPTypeAssistant().isUnknown(node.getType())) return node.getType(); if (node.getType() instanceof AFunctionType && ((AFunctionType) node.getType()).getResult() instanceof AFunctionType) node.setRecursive(def); def.setRecursive(true); node.setRecursive(def); def.setRecursive(true); boolean isSimple = !question.assistantFactory.createPTypeAssistant().isUnion(node.getType()); PTypeSet results = new PTypeSet(question.assistantFactory); if (question.assistantFactory.createPTypeAssistant().isFunction(node.getType())) AFunctionType ft = question.assistantFactory.createPTypeAssistant().getFunction(node.getType()); TypeCheckerErrors.report(3350, "Polymorphic function has not been instantiated", node.getRoot().getLocation(), node);
throws AnalysisException AApplyExp apply_exp = new AApplyExp(); if (apply.getRoot() instanceof AFuncInstatiationExp) AFuncInstatiationExp func_exp = (AFuncInstatiationExp) apply.getRoot().clone(); func_exp.setFunction(wrapName(measure.clone())); apply_exp.setRoot(func_exp); func_exp.setActualTypes(cloneListType(apply.getArgtypes())); // Not sure about this? func_exp.setFunction(wrapName(measure.clone())); apply_exp.setRoot(func_exp); apply_exp.setRoot(wrapName(measure.clone())); apply_exp.setType(actualResult.clone()); apply_exp.setArgs(args); return apply_exp;
PExp root = node.getRoot(); obligations.add(new MapApplyObligation(node.getRoot(), node.getArgs().get(0), question, aF)); PType aType = question.checkType(node.getArgs().get(0), node.getArgtypes().get(0)); TypeCompatibilityObligation sto = TypeCompatibilityObligation.newInstance(node.getArgs().get(0), mapType.getFrom(), aType, question, aF); if (sto != null) || !prename.equals(NO_PRECONDITION)) obligations.add(new FunctionApplyObligation(node.getRoot(), node.getArgs(), prename, question, aF)); List<PType> argTypes = node.getArgtypes(); List<PExp> argList = node.getArgs(); for (PType argType : argTypes) PDefinition recursive = node.getRecursive(); if (recursive != null) obligations.add(new SeqApplyObligation(node.getRoot(), node.getArgs().get(0), question, aF)); obligations.addAll(node.getRoot().apply(mainVisitor, question)); for (PExp arg : node.getArgs()) SOperationDefinitionBase calledOp = node.apply(new GetOpCallVisitor()); if (calledOp != null)
@Override public SExpIR caseAApplyExp(AApplyExp node, IRInfo question) throws AnalysisException { PType type = node.getType(); PExp root = node.getRoot(); STypeIR typeCg = type.apply(question.getTypeVisitor(), question); SExpIR rootCg = root.apply(question.getExpVisitor(), question); AApplyExpIR applyExp = new AApplyExpIR(); applyExp.setType(typeCg); applyExp.setRoot(rootCg); for (PExp arg : node.getArgs()) { SExpIR argCg = arg.apply(question.getExpVisitor(), question); if (argCg != null) { applyExp.getArgs().add(argCg); } else { return null; } } return applyExp; }
breakpoint.check(node.getLocation(), ctxt); node.getLocation().setHits(node.getLocation().getHits() / 1); // This is counted below when root is evaluated boolean endstop = breakpoint.catchReturn(ctxt); Value object = node.getRoot().apply(VdmRuntime.getExpressionEvaluator(), ctxt).deref(); for (PExp arg : node.getArgs()) Value rv = fv.eval(node.getLocation(), argvals, ctxt); for (PExp arg : node.getArgs()) Value rv = ov.eval(node.getLocation(), argvals, ctxt); Value arg = node.getArgs().get(0).apply(VdmRuntime.getExpressionEvaluator(), ctxt); SeqValue sv = (SeqValue) object; return sv.get(arg, ctxt); } else if (object instanceof MapValue) Value arg = node.getArgs().get(0).apply(VdmRuntime.getExpressionEvaluator(), ctxt); MapValue mv = (MapValue) object; return mv.lookup(arg, ctxt); } else return VdmRuntimeError.abort(node.getLocation(), 4003, "Value " + object + " cannot be applied", ctxt); return VdmRuntimeError.abort(node.getLocation(), e);
@Override public SOperationDefinitionBase caseAApplyExp(AApplyExp node) throws AnalysisException { return node.getRoot().apply(this); }
private PExp generateBody(AExplicitFunctionDefinition postdef, List<PExp> params, PExp body) { // post(params, body) AApplyExp applyExp = new AApplyExp(); applyExp.setType(new ABooleanBasicType()); AVariableExp varExp = getVarExp(postdef.getName()); varExp.setType(postdef.getType().clone()); applyExp.setRoot(varExp); List<PExp> args = params; args.add(body.clone()); applyExp.setArgs(args); return applyExp; }
public static PExp newAApplyExp(PExp root, List<PExp> args) { AApplyExp result = new AApplyExp(); result.setLocation(root.getLocation()); result.setRoot(root); result.setArgs(args); return result; }
public OpPostConditionContext(AExplicitFunctionDefinition postDef, AApplyExp exp, SOperationDefinitionBase calledOp, IPogAssistantFactory af, IPOContextStack ctxt) { super(ctxt); this.visitor = af.getVarSubVisitor(); this.gen = ctxt.getGenerator(); this.subs = new LinkedList<Substitution>(); this.forall_exp = getChangedVarsExp(postDef, calledOp); PExp inv = buildInvExp(calledOp, af); this.pred = spellCondition(postDef, af, exp.getArgs(), inv); }
public RecursiveObligation(AExplicitFunctionDefinition def, AApplyExp apply, IPOContextStack ctxt, IPogAssistantFactory af) throws AnalysisException { super(apply, POType.RECURSIVE, ctxt, apply.getLocation(), af); PExp measureLeft_exp = buildMeasureLeft(def, apply); PExp measureRight_exp = buildMeasureRight(def, apply); PExp lt_exp = buildStructuralComparison(measureLeft_exp, measureRight_exp, getLex(def.getMeasureDef())); stitch = lt_exp; valuetree.setPredicate(ctxt.getPredWithContext(lt_exp)); }