File |
Line |
org\overturetool\vdmj\statements\ObjectDesignator.java |
60
|
org\overturetool\vdmj\statements\StateDesignator.java |
59
|
public void abort(int number, String msg, Context ctxt)
{
throw new ContextException(number, msg, location, ctxt);
}
public Value abort(ValueException ve)
{
throw new ContextException(ve, location);
}
public void report(int number, String msg)
{
TypeChecker.report(number, msg, location);
}
public void concern(boolean serious, int number, String msg)
{
if (serious)
{
TypeChecker.report(number, msg, location);
}
else
{
TypeChecker.warning(number, msg, location);
}
}
public void detail(String tag, Object obj)
{
TypeChecker.detail(tag, obj);
}
public void detail2(String tag1, Object obj1, String tag2, Object obj2)
|
File |
Line |
org\overturetool\vdmj\definitions\ExplicitFunctionDefinition.java |
287
|
org\overturetool\vdmj\definitions\ImplicitFunctionDefinition.java |
281
|
else if (mdef == null)
{
measure.report(3270, "Measure " + mname + " is not in scope");
}
else if (!(mdef instanceof ExplicitFunctionDefinition))
{
measure.report(3271, "Measure " + mname + " is not an explicit function");
}
else
{
FunctionType mtype = (FunctionType)mdef.getType();
if (!(mtype.result instanceof NaturalType))
{
if (mtype.result.isProduct())
{
ProductType pt = mtype.result.getProduct();
for (Type t: pt.types)
{
if (!(t instanceof NaturalType))
{
measure.report(3272,
"Measure range is not a nat, or a nat tuple");
measure.detail("Actual", mtype.result);
|
File |
Line |
org\overturetool\vdmj\runtime\ClassInterpreter.java |
181
|
org\overturetool\vdmj\runtime\ModuleInterpreter.java |
186
|
sr.setCurrentModule(getDefaultName());
return sr.readStatement();
}
@Override
public Type typeCheck(Expression expr, Environment env)
throws Exception
{
TypeChecker.clearErrors();
Type type = expr.typeCheck(env, null, NameScope.NAMESANDSTATE);
if (TypeChecker.getErrorCount() > 0)
{
// TypeChecker.printErrors(Console.out);
throw new VDMErrorsException(TypeChecker.getErrors());
}
return type;
}
@Override
public Type typeCheck(Statement stmt, Environment env)
throws Exception
{
TypeChecker.clearErrors();
Type type = stmt.typeCheck(env, NameScope.NAMESANDSTATE);
if (TypeChecker.getErrorCount() > 0)
{
// TypeChecker.printErrors(Console.out);
throw new VDMErrorsException(TypeChecker.getErrors());
}
return type;
}
|
File |
Line |
org\overturetool\vdmj\expressions\Expression.java |
222
|
org\overturetool\vdmj\statements\ObjectDesignator.java |
85
|
}
public void detail(String tag, Object obj)
{
TypeChecker.detail(tag, obj);
}
public void detail(boolean serious, String tag, Object obj)
{
if (serious)
{
TypeChecker.detail(tag, obj);
}
}
public void detail2(String tag1, Object obj1, String tag2, Object obj2)
{
TypeChecker.detail2(tag1, obj1, tag2, obj2);
}
public void detail2(
boolean serious, String tag1, Object obj1, String tag2, Object obj2)
{
if (serious)
{
TypeChecker.detail2(tag1, obj1, tag2, obj2);
}
}
}
|
File |
Line |
org\overturetool\vdmj\expressions\SameBaseClassExpression.java |
82
|
org\overturetool\vdmj\expressions\SameClassExpression.java |
71
|
return new BooleanValue(lv.type.equals(rv.type));
}
catch (ValueException e)
{
return abort(e);
}
}
@Override
public Expression findExpression(int lineno)
{
Expression found = super.findExpression(lineno);
if (found != null) return found;
found = left.findExpression(lineno);
if (found != null) return found;
found = right.findExpression(lineno);
if (found != null) return found;
return null;
}
@Override
public ProofObligationList getProofObligations(POContextStack ctxt)
{
ProofObligationList list = left.getProofObligations(ctxt);
list.addAll(right.getProofObligations(ctxt));
return list;
}
@Override
public String kind()
{
return "sameclass";
|
File |
Line |
org\overturetool\vdmj\patterns\Bind.java |
75
|
org\overturetool\vdmj\types\Type.java |
340
|
public void report(int number, String msg)
{
TypeChecker.report(number, msg, location);
}
public void abort(int number, String msg, Context ctxt)
{
throw new ContextException(number, msg, location, ctxt);
}
public void abort(ValueException ve)
{
throw new ContextException(ve, location);
}
public void detail(String tag, Object obj)
{
TypeChecker.detail(tag, obj);
}
public void detail2(String tag1, Object obj1, String tag2, Object obj2)
{
TypeChecker.detail2(tag1, obj1, tag2, obj2);
}
}
|
File |
Line |
org\overturetool\vdmj\types\UnionType.java |
527
|
org\overturetool\vdmj\types\UnionType.java |
588
|
Type pt = op.parameters.get(p);
TypeSet pset = params.get(p);
if (pset == null)
{
pset = new TypeSet(pt);
params.put(p, pset);
}
else
{
pset.add(pt);
}
}
}
}
if (!result.isEmpty())
{
Type rtype = result.getType(location);
TypeList plist = new TypeList();
for (int i=0; i<params.size(); i++)
{
Type pt = params.get(i).getType(location);
plist.add(pt);
}
|
File |
Line |
org\overturetool\vdmj\definitions\StateDefinition.java |
334
|
org\overturetool\vdmj\definitions\TypeDefinition.java |
226
|
}
private ExplicitFunctionDefinition getInvDefinition()
{
LexLocation loc = invPattern.location;
PatternList params = new PatternList();
params.add(invPattern);
List<PatternList> parameters = new Vector<PatternList>();
parameters.add(params);
TypeList ptypes = new TypeList();
ptypes.add(new UnresolvedType(name));
FunctionType ftype =
new FunctionType(loc, false, ptypes, new BooleanType(loc));
ExplicitFunctionDefinition def = new ExplicitFunctionDefinition(
name.getInvName(loc),
NameScope.GLOBAL, null, ftype, parameters, invExpression,
null, null, true, false, null);
|
File |
Line |
org\overturetool\vdmj\VDMPP.java |
216
|
org\overturetool\vdmj\VDMSL.java |
242
|
info("Type checked " + plural(n, "module", "s") +
" in " + (double)(after-before)/1000 + " secs. ");
info(terrs == 0 ? "No type errors" :
"Found " + plural(terrs, "type error", "s"));
infoln(twarn == 0 ? "" : " and " +
(warnings ? "" : "suppressed ") + plural(twarn, "warning", "s"));
}
if (outfile != null && terrs == 0)
{
try
{
before = System.currentTimeMillis();
FileOutputStream fos = new FileOutputStream(outfile);
GZIPOutputStream gos = new GZIPOutputStream(fos);
ObjectOutputStream oos = new ObjectOutputStream(gos);
oos.writeObject(modules);
|
File |
Line |
org\overturetool\vdmj\patterns\ConcatenationPattern.java |
59
|
org\overturetool\vdmj\patterns\UnionPattern.java |
60
|
public UnionPattern(Pattern left, LexLocation location, Pattern right)
{
super(location);
this.left = left;
this.right = right;
}
@Override
public void unResolve()
{
left.unResolve();
right.unResolve();
resolved = false;
}
@Override
public void typeResolve(Environment env)
{
if (resolved) return; else { resolved = true; }
try
{
left.typeResolve(env);
right.typeResolve(env);
}
catch (TypeCheckException e)
{
unResolve();
throw e;
}
}
@Override
public String toString()
{
return left + " union " + right;
|
File |
Line |
org\overturetool\vdmj\expressions\SameBaseClassExpression.java |
46
|
org\overturetool\vdmj\expressions\SameClassExpression.java |
46
|
public SameClassExpression(LexLocation start, ExpressionList args)
{
super(start);
left = args.get(0);
right = args.get(1);
}
@Override
public Value eval(Context ctxt)
{
try
{
Value l = left.eval(ctxt);
Value r = right.eval(ctxt);
if (!l.isType(ObjectValue.class) ||
!r.isType(ObjectValue.class))
{
return new BooleanValue(false);
}
ObjectValue lv = l.objectValue(ctxt);
ObjectValue rv = r.objectValue(ctxt);
|
File |
Line |
org\overturetool\vdmj\debug\DBGPReader.java |
169
|
org\overturetool\vdmj\VDMJ.java |
67
|
for (Iterator<String> i = largs.iterator(); i.hasNext();)
{
String arg = i.next();
if (arg.equals("-vdmsl"))
{
controller = new VDMSL();
}
else if (arg.equals("-vdmpp"))
{
controller = new VDMPP();
}
else if (arg.equals("-vdmrt"))
{
controller = new VDMRT();
}
else if (arg.equals("-overture"))
{
controller = new VDMOV();
}
else if (arg.equals("-w"))
|
File |
Line |
org\overturetool\vdmj\ast\ASTConverter.java |
2037
|
org\overturetool\vdmj\ast\ASTConverter.java |
2066
|
for (IOmlPatternBindExpression pbe: pbelist)
{
IOmlPatternBind pb = pbe.getPatternBind();
Expression e = convertExpression(pbe.getExpression());
if (pb instanceof IOmlPattern)
{
Pattern p = convertPattern((IOmlPattern)pb);
defs.add(new EqualsDefinition(getLocation(pb), p, e));
}
else if (pb instanceof IOmlBind)
{
MultipleBind mb = convertMultiBind((IOmlBind)pb);
defs.add(new EqualsDefinition(getLocation(pb), mb.plist.get(0), e));
}
else
{
throw new InternalException(37, "Unexpected pattern/bind type");
|
File |
Line |
org\overturetool\vdmj\expressions\SeqCompExpression.java |
142
|
org\overturetool\vdmj\expressions\SetCompExpression.java |
162
|
return new SetValue(set);
}
@Override
public Expression findExpression(int lineno)
{
Expression found = super.findExpression(lineno);
if (found != null) return found;
found = first.findExpression(lineno);
if (found != null) return found;
return predicate == null ? null : predicate.findExpression(lineno);
}
@Override
public ProofObligationList getProofObligations(POContextStack ctxt)
{
ProofObligationList obligations = new ProofObligationList();
ctxt.push(new POForAllPredicateContext(this));
obligations.addAll(first.getProofObligations(ctxt));
ctxt.pop();
|
File |
Line |
org\overturetool\vdmj\VDMPP.java |
283
|
org\overturetool\vdmj\VDMSL.java |
309
|
infoln("Initialized " + plural(modules.size(), "module", "s") + " in " +
(double)(after-before)/1000 + " secs. ");
}
catch (ContextException e)
{
println("Initialization: " + e);
e.ctxt.printStackTrace(Console.out, true);
return ExitStatus.EXIT_ERRORS;
}
catch (Exception e)
{
println("Initialization: " + e);
return ExitStatus.EXIT_ERRORS;
}
try
{
if (script != null)
{
println(interpreter.execute(script, null).toString());
return ExitStatus.EXIT_OK;
}
else
{
infoln("Interpreter started");
CommandReader reader = new ModuleCommandReader(interpreter, "> ");
|
File |
Line |
org\overturetool\vdmj\expressions\LetBeStExpression.java |
101
|
org\overturetool\vdmj\statements\LetBeStStatement.java |
115
|
return statement.findExpression(lineno);
}
@Override
public Value eval(Context ctxt)
{
breakpoint.check(location, ctxt);
QuantifierList quantifiers = new QuantifierList();
for (MultipleBind mb: def.bindings)
{
ValueList bvals = mb.getBindValues(ctxt);
for (Pattern p: mb.plist)
{
Quantifier q = new Quantifier(p, bvals);
quantifiers.add(q);
}
}
quantifiers.init();
try
{
while (quantifiers.hasNext(ctxt))
{
Context evalContext = new Context(location, "let be st statement", ctxt);
|
File |
Line |
org\overturetool\vdmj\definitions\ExplicitOperationDefinition.java |
192
|
org\overturetool\vdmj\definitions\ImplicitOperationDefinition.java |
261
|
if (name.name.equals(classDefinition.name.name))
{
isConstructor = true;
if (accessSpecifier.isAsync)
{
report(3286, "Constructor cannot be 'async'");
}
if (type.result.isClass())
{
ClassType ctype = type.result.getClassType();
if (ctype.classdef != classDefinition)
{
type.result.report(3025,
"Constructor operation must have return type " + classDefinition.name.name);
}
}
else
{
type.result.report(3026,
"Constructor operation must have return type " + classDefinition.name.name);
}
}
}
|
File |
Line |
org\overturetool\vdmj\debug\DBGPReader.java |
1493
|
org\overturetool\vdmj\debug\DBGPReader.java |
1535
|
if (c.data != null || c.options.size() > 4)
{
throw new DBGPException(DBGPErrorCode.INVALID_OPTIONS, c.toString());
}
if (status != DBGPStatus.BREAK && status != DBGPStatus.STOPPING)
{
throw new DBGPException(DBGPErrorCode.NOT_AVAILABLE, c.toString());
}
DBGPOption option = c.getOption(DBGPOptionType.C);
int type = 0;
if (option != null)
{
type = Integer.parseInt(option.value);
}
DBGPContextType context = DBGPContextType.lookup(type);
option = c.getOption(DBGPOptionType.D);
int depth = -1;
|
File |
Line |
org\overturetool\vdmj\statements\CallObjectStatement.java |
205
|
org\overturetool\vdmj\statements\CallStatement.java |
138
|
report(3210, "Name is neither a function nor an operation");
return new UnknownType(location);
}
}
@Override
public TypeSet exitCheck()
{
// TODO We don't know what an operation call will raise
return new TypeSet(new UnknownType(location));
}
private TypeList getArgTypes(Environment env, NameScope scope)
{
TypeList types = new TypeList();
for (Expression a: args)
{
types.add(a.typeCheck(env, null, scope));
}
return types;
}
private void checkArgTypes(TypeList ptypes, TypeList atypes)
{
if (ptypes.size() != atypes.size())
{
report(3216, "Expecting " + ptypes.size() + " arguments");
|
File |
Line |
org\overturetool\vdmj\expressions\RangeResByExpression.java |
71
|
org\overturetool\vdmj\expressions\RangeResToExpression.java |
71
|
report(3153, "Restriction of map should be set of " + map.to);
}
}
return ltype;
}
@Override
public Value eval(Context ctxt)
{
breakpoint.check(location, ctxt);
ValueSet set = null;
ValueMap map = null;
try
{
set = right.eval(ctxt).setValue(ctxt);
map = left.eval(ctxt).mapValue(ctxt);
}
catch (ValueException e)
{
return abort(e);
}
ValueMap modified = new ValueMap(map);
for (Value k: map.keySet())
{
if (!set.contains(map.get(k)))
|
File |
Line |
org\overturetool\vdmj\expressions\GreaterEqualExpression.java |
41
|
org\overturetool\vdmj\expressions\LessExpression.java |
41
|
public LessExpression(Expression left, LexToken op, Expression right)
{
super(left, op, right);
}
@Override
public Type typeCheck(Environment env, TypeList qualifiers, NameScope scope)
{
super.typeCheck(env, qualifiers, scope);
return new BooleanType(location);
}
@Override
public Value eval(Context ctxt)
{
breakpoint.check(location, ctxt);
Value lv = left.eval(ctxt);
Value rv = right.eval(ctxt);
try
{
return new BooleanValue(lv.realValue(ctxt) < rv.realValue(ctxt));
|
File |
Line |
org\overturetool\vdmj\expressions\LetDefExpression.java |
126
|
org\overturetool\vdmj\statements\LetDefStatement.java |
143
|
Context evalContext = new Context(location, "let statement", ctxt);
LexNameToken sname = new LexNameToken(location.module, "self", location);
ObjectValue self = (ObjectValue)ctxt.check(sname);
for (Definition d: localDefs)
{
NameValuePairList values = d.getNamedValues(evalContext);
if (self != null && d instanceof ExplicitFunctionDefinition)
{
for (NameValuePair nvp: values)
{
if (nvp.value instanceof FunctionValue)
{
FunctionValue fv = (FunctionValue)nvp.value;
fv.setSelf(self);
}
}
}
evalContext.put(values);
}
return statement.eval(evalContext);
|
File |
Line |
org\overturetool\vdmj\expressions\LetBeStExpression.java |
128
|
org\overturetool\vdmj\statements\LetBeStStatement.java |
141
|
Context evalContext = new Context(location, "let be st statement", ctxt);
NameValuePairList nvpl = quantifiers.next();
boolean matches = true;
for (NameValuePair nvp: nvpl)
{
Value v = evalContext.get(nvp.name);
if (v == null)
{
evalContext.put(nvp.name, nvp.value);
}
else
{
if (!v.equals(nvp.value))
{
matches = false;
break; // This quantifier set does not match
}
}
}
if (matches &&
(suchThat == null || suchThat.eval(evalContext).boolValue(ctxt)))
{
return statement.eval(evalContext);
|