@Override public PType caseAExplicitOperationDefinition( AExplicitOperationDefinition node) throws AnalysisException { return node.getType(); }
public List<? extends PDefinition> getParamDefinitions( AExplicitOperationDefinition node) { List<PDefinition> defs = new Vector<PDefinition>(); Iterator<PType> titer = ((AOperationType) node.getType()).getParameters().iterator(); for (PPattern p : node.getParameterPatterns()) { defs.addAll(af.createPPatternAssistant().getDefinitions(p, titer.next(), NameScope.LOCAL)); } return af.createPDefinitionAssistant().checkDuplicatePatterns(node, defs); }
public POOperationDefinitionContext( AExplicitOperationDefinition definition, boolean precond, PDefinition stateDefinition) { this.name = definition.getName(); this.deftype = (AOperationType) definition.getType(); this.addPrecond = precond; this.paramPatternList = cloneList(definition.getParameterPatterns()); this.precondition = definition.getPrecondition(); this.stateDefinition = stateDefinition; this.opDef = definition; }
&& ((AOperationType) op.expldef.getType()).getParameters().isEmpty()) } else if (((AOperationType) op.expldef.getType()).getParameters().size() == 1 && Interpreter.getInstance().getAssistantFactory().createPTypeAssistant().isType(((AOperationType) op.expldef.getType()).getParameters().get(0), typeName) != null && op.expldef.getName().equals(instance.type.getName().getName()))
private OperationValue(AExplicitOperationDefinition def, FunctionValue precondition, FunctionValue postcondition, AStateDefinition state, boolean async) { this.expldef = def; this.impldef = null; this.name = def.getName(); this.type = (AOperationType) def.getType(); this.paramPatterns = def.getParameterPatterns(); this.body = def.getBody(); this.precondition = precondition; this.postcondition = postcondition; this.state = state; this.classdef = def.getClassDefinition(); this.isAsync = async; traceRT = Settings.dialect == Dialect.VDM_RT && classdef != null && !(classdef instanceof ASystemClassDefinition) && !classdef.getName().getName().equals("CPU") && !classdef.getName().getName().equals("BUS") && !name.getName().equals("thread") && !name.getName().startsWith("inv_"); }
public ParameterPatternObligation(AExplicitOperationDefinition def, IPOContextStack ctxt, IPogAssistantFactory af) throws AnalysisException { super(def, POType.OPERATION_PATTERNS, ctxt, def.getLocation(), af); this.assistantFactory = af; stitch = generate(def.getPredef(), cloneListPatternList(assistantFactory.createAExplicitOperationDefinitionAssistant().getParamPatternList(def)), cloneListType(((AOperationType) def.getType()).getParameters()), ((AOperationType) def.getType()).getResult().clone()); valuetree.setPredicate(ctxt.getPredWithContext(stitch)); }
String type = ": "; AOperationType optype = (AOperationType) d.getType();
public static String getExplicitOperationString( AExplicitOperationDefinition d) { return d.getName() + " " + d.getType() + "\n\t" + d.getName() + "(" + Utils.listToString(d.getParameterPatterns()) + ")" + (d.getBody() == null ? "" : " ==\n" + d.getBody()) + (d.getPrecondition() == null ? "" : "\n\tpre " + d.getPrecondition()) + (d.getPostcondition() == null ? "" : "\n\tpost " + d.getPostcondition()); }
private TypeCompatibilityObligation(AExplicitOperationDefinition def, PType actualResult, IPOContextStack ctxt, IPogAssistantFactory assistantFactory) throws AnalysisException { super(def, POType.TYPE_COMP, ctxt, def.getLocation(), assistantFactory); this.assistantFactory = assistantFactory; AVariableExp result = AstFactory.newAVariableExp(new LexNameToken(def.getName().getModule(), "RESULT", def.getLocation())); stitch = oneType(false, result, ((AOperationType) def.getType()).getResult().clone(), actualResult.clone()); valuetree.setPredicate(ctxt.getPredWithContext(stitch)); }
plist.addAll((List<PPattern>) d.getParameterPatterns().clone()); if (!(((AOperationType) d.getType()).getResult() instanceof AVoidType)) APostOpExp postop = AstFactory.newAPostOpExp(d.getName().clone(), d.getPrecondition(), d.getPostcondition(), null, d.getState()); AExplicitFunctionDefinition def = AstFactory.newAExplicitFunctionDefinition(d.getName().getPostName(d.getPostcondition().getLocation()), NameScope.GLOBAL, null, af.createAOperationTypeAssistant().getPostType((AOperationType) d.getType(), state, d.getClassDefinition(), af.createPAccessSpecifierAssistant().isStatic(d.getAccess())), parameters, postop, null, null, false, null);
@SuppressWarnings("unchecked") public AExplicitFunctionDefinition getPreDefinition( AExplicitOperationDefinition d, Environment base) { List<List<PPattern>> parameters = new Vector<List<PPattern>>(); List<PPattern> plist = new Vector<PPattern>(); plist.addAll((List<PPattern>) d.getParameterPatterns().clone()); if (d.getState() != null) { plist.add(AstFactory.newAIdentifierPattern(d.getState().getName().clone())); } else if (base.isVDMPP() && !af.createPAccessSpecifierAssistant().isStatic(d.getAccess())) { plist.add(AstFactory.newAIdentifierPattern(d.getName().getSelfName())); } parameters.add(plist); APreOpExp preop = AstFactory.newAPreOpExp(d.getName().clone(), d.getPrecondition(), null, d.getState()); AExplicitFunctionDefinition def = AstFactory.newAExplicitFunctionDefinition(d.getName().getPreName(d.getPrecondition().getLocation()), NameScope.GLOBAL, null, af.createAOperationTypeAssistant().getPreType((AOperationType) d.getType(), d.getState(), d.getClassDefinition(), af.createPAccessSpecifierAssistant().isStatic(d.getAccess())), parameters, preop, null, null, false, null); // Operation precondition functions are effectively not static as // their expression can directly refer to instance variables, even // though at runtime these are passed via a "self" parameter. def.setAccess(af.createPAccessSpecifierAssistant().getStatic(def, false)); def.setClassDefinition(d.getClassDefinition()); return def; }
@Override public void caseAExplicitOperationDefinition( AExplicitOperationDefinition node, NewQuestion question) throws AnalysisException { node.setType(af.createPTypeAssistant().typeResolve(node.getType(), null, question.rootVisitor, question.question)); if (question.question.env.isVDMPP()) { node.getName().setTypeQualifier(((AOperationType) node.getType()).getParameters()); if (node.getName().getName().equals(node.getClassDefinition().getName().getName())) { node.setIsConstructor(true); node.getClassDefinition().setHasContructors(true); } } if (node.getPrecondition() != null) { node.getPredef().apply(this, question); } if (node.getPostcondition() != null) { node.getPostdef().apply(this, question); } for (PPattern p : node.getParameterPatterns()) { af.createPPatternAssistant().typeResolve(p, question.rootVisitor, question.question); } }
if (((AOperationType) ctor.getType()).getParameters().size() == 1)