public static <P> TypeCheckResult<P> typeCheck( ParserResult<P> parserResult, P tcList, TypeChecker tc) { if (parserResult.errors.isEmpty()) { TypeChecker.clearErrors(); tc.typeCheck(); return new TypeCheckResult<P>(parserResult, parserResult.result, TypeChecker.getWarnings(), TypeChecker.getErrors()); } return new TypeCheckResult<P>(parserResult, null, new Vector<VDMWarning>(), new Vector<VDMError>()); }
public PType possibleConstraint(PType constraint, PType actual, ILexLocation location) { if (constraint != null) { if (!af.getTypeComparator().compatible(constraint, actual)) { TypeChecker.report(3327, "Value is not of the right type", location); TypeChecker.detail2("Actual", actual, "Expected", constraint); } } return actual; }
public PType typeCheck(PStm stmt, Environment env) throws Exception { TypeChecker.clearErrors(); try { PType type = stmt.apply(new TypeCheckVisitor(), new TypeCheckInfo(assistantFactory, env, NameScope.NAMESANDSTATE)); if (TypeChecker.getErrorCount() > 0) { throw new VDMErrorsException(TypeChecker.getErrors()); } return type; } catch (Exception e) { throw e; } catch (Throwable e) { e.printStackTrace(); } return null; }
typeChecker.typeCheck(); } catch (InternalException e) terrs += TypeChecker.getErrorCount(); TypeChecker.printErrors(Console.out); int twarn = TypeChecker.getWarningCount(); TypeChecker.printWarnings(Console.out);
if (getErrorCount() > 0) dependencies.put(nameFix(name.getExplicit(true)), nameFix(freevars)); skip.add(nameFix(def.getName().getExplicit(true))); stack.push(sought); if (reachable(sought, dependencies.get(sought), dependencies, stack)) report(3355, "Cyclic dependency detected for " + sought, sought.getLocation()); detail("Cycle", stack.toString());
public static SClassDefinition tcClass(ClassList classes, SClassDefinition clazz) throws AnalysisException, VDMErrorsException { for (SClassDefinition c : classes) { clearTypeData(c); } TypeCheckerAssistantFactory af = new TypeCheckerAssistantFactory(); ClassTypeChecker.clearErrors(); ClassTypeChecker classTc = new ClassTypeChecker(classes, af); classes.add(clazz); classTc.typeCheck(); if (TypeChecker.getErrorCount() > 0) { throw new VDMErrorsException(TypeChecker.getErrors()); } else { return clazz; } }
public TypeChecker(ITypeCheckerAssistantFactory factory) { clearErrors(); this.assistantFactory = factory; }
TypeChecker.printErrors(out); out.flush(); exit(2);
public static void detail2(boolean serious, String tag1, Object obj1, String tag2, Object obj2) { if (serious) { TypeChecker.detail2(tag1, obj1, tag2, obj2); } }
public PType typeCheck(PExp expr, Environment env) throws Exception { TypeChecker.clearErrors(); try { PType type = expr.apply(new TypeCheckVisitor(), new TypeCheckInfo(assistantFactory, env, NameScope.NAMESANDSTATE)); if (TypeChecker.getErrorCount() > 0) { throw new VDMErrorsException(TypeChecker.getErrors()); } return type; } catch (Exception e) { throw e; } catch (Throwable e) { e.printStackTrace(); } return null; }
typeChecker.typeCheck(); } catch (InternalException e) terrs += TypeChecker.getErrorCount(); TypeChecker.printErrors(Console.out); int twarn = TypeChecker.getWarningCount(); TypeChecker.printWarnings(Console.out);
/** * VDM-only constructor. <b>NOT</b> for use by extensions. */ public TypeChecker() { clearErrors(); this.assistantFactory = new TypeCheckerAssistantFactory(); }
public static void detail2(String tag1, Object obj1, String tag2, Object obj2) { TypeChecker.detail2(tag1, obj1, tag2, obj2); }
public static PExp tcExp(ClassList classes, PExp exp) throws AnalysisException, VDMErrorsException { TypeCheckerAssistantFactory af = new TypeCheckerAssistantFactory(); ClassTypeChecker.clearErrors(); ClassTypeChecker classTc = new ClassTypeChecker(classes, af); for (SClassDefinition c : classes) { clearTypeData(c); } classTc.typeCheck(); TypeCheckVisitor tc = new TypeCheckVisitor(); TypeChecker.clearErrors(); Environment env = new PublicClassEnvironment(af, classes, null); exp.apply(tc, new TypeCheckInfo(af, env, NameScope.NAMESANDSTATE)); if (TypeChecker.getErrorCount() > 0) { throw new VDMErrorsException(TypeChecker.getErrors()); } else { return exp; } }
public PType checkConstraint(PType constraint, PType actual, ILexLocation location) { if (constraint != null) { if (!af.getTypeComparator().isSubType(actual, constraint, true)) { TypeChecker.report(3327, "Value is not of the right type", location); TypeChecker.detail2("Actual", actual, "Expected", constraint); } } return actual; }
public static void detail(boolean serious, String tag, Object obj) { if (serious) { TypeChecker.detail(tag, obj); } }
public PType checkReturnType(PType constraint, PType actual, ILexLocation location) { PTypeAssistantTC assistant = af.createPTypeAssistant(); if (constraint != null && !(actual instanceof AVoidType) && !assistant.isUnknown(actual)) { if (assistant.hasVoid(actual) && !(constraint instanceof AVoidType)) { TypeChecker.report(3328, "Statement may return void value", location); TypeChecker.detail2("Actual", actual, "Expected", constraint); } else if (!af.getTypeComparator().compatible(constraint, actual)) { TypeChecker.report(3327, "Value is not of the right type", location); TypeChecker.detail2("Actual", actual, "Expected", constraint); } } return actual; }
public static void detail(String tag, Object obj) { TypeChecker.detail(tag, obj); }