@Override public PDefinitionSet createPDefinitionSet() { return new PDefinitionSet(this); }
@Override public boolean add(PDefinition e) { if (!contains(e)) { return super.add(e); } return false; }
public void create(String var, String exp) throws Exception { PExp expr = parseExpression(exp, getDefaultName()); Environment env = getGlobalEnvironment(); Environment created = new FlatCheckedEnvironment(assistantFactory, createdDefinitions.asList(), env, NameScope.NAMESANDSTATE); PType type = typeCheck(expr, created); Value v = execute(exp, null); ILexLocation location = defaultClass.getLocation(); LexNameToken n = new LexNameToken(defaultClass.getName().getName(), var, location); createdValues.put(n, v); createdDefinitions.add(AstFactory.newALocalDefinition(location, n, NameScope.LOCAL, type)); }
/** * Get a set of definitions for the pattern's variables. Note that if the pattern includes duplicate variable names, * these are collapse into one. * * @param rp * @param ptype * @param scope * @return */ public List<PDefinition> getDefinitions(PPattern rp, PType ptype, NameScope scope) { PDefinitionSet set = af.createPDefinitionSet(); set.addAll(af.createPPatternAssistant().getAllDefinitions(rp, ptype, scope)); List<PDefinition> result = new Vector<PDefinition>(set); return result; }
/** * Parse the line passed, type check it and evaluate it as an expression in the initial context. * * @param line * A VDM expression. * @return The value of the expression. * @throws Exception * Parser, type checking or runtime errors. */ @Override public Value execute(String line, DBGPReader dbgp) throws Exception { PExp expr = parseExpression(line, getDefaultName()); Environment env = getGlobalEnvironment(); Environment created = new FlatCheckedEnvironment(assistantFactory, createdDefinitions.asList(), env, NameScope.NAMESANDSTATE); typeCheck(expr, created); return execute(expr, dbgp); }