本文整理汇总了Java中com.fujitsu.vdmj.typechecker.TypeChecker.getErrors方法的典型用法代码示例。如果您正苦于以下问题:Java TypeChecker.getErrors方法的具体用法?Java TypeChecker.getErrors怎么用?Java TypeChecker.getErrors使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.fujitsu.vdmj.typechecker.TypeChecker
的用法示例。
在下文中一共展示了TypeChecker.getErrors方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: typeCheck
import com.fujitsu.vdmj.typechecker.TypeChecker; //导入方法依赖的package包/类
/**
* Type check a TC expression tree passed.
*/
public TCType typeCheck(TCNode tree) throws Exception
{
TypeChecker.clearErrors();
TCType type = null;
if (tree instanceof TCExpression)
{
TCExpression exp = (TCExpression)tree;
type = exp.typeCheck(getGlobalEnvironment(), null, NameScope.NAMESANDSTATE, null);
}
else if (tree instanceof TCStatement)
{
TCStatement stmt = (TCStatement)tree;
type = stmt.typeCheck(getGlobalEnvironment(), NameScope.NAMESANDSTATE, null);
}
else
{
throw new Exception("Cannot type check " + tree.getClass().getSimpleName());
}
if (TypeChecker.getErrorCount() > 0)
{
throw new VDMErrorsException(TypeChecker.getErrors());
}
return type;
}
示例2: process
import com.fujitsu.vdmj.typechecker.TypeChecker; //导入方法依赖的package包/类
private void process(String resource, Integer... expected) throws Exception
{
Console.out.println("Processing " + resource + "...");
URL rurl = getClass().getResource("/modtest/" + resource);
String file = rurl.getPath();
long before = System.currentTimeMillis();
LexTokenReader ltr = new LexTokenReader(new File(file), Dialect.VDM_SL);
ModuleReader mr = new ModuleReader(ltr);
ASTModuleList parsed = new ASTModuleList();
parsed.addAll(mr.readModules());
long after = System.currentTimeMillis();
Console.out.println("Parsed " + parsed.size() + " modules in " +
(double)(after-before)/1000 + " secs. ");
mr.printErrors(Console.out);
mr.printWarnings(Console.out);
assertEquals("Parse errors", 0, mr.getErrorCount());
before = System.currentTimeMillis();
TCModuleList checked = ClassMapper.getInstance(TCNode.MAPPINGS).init().convert(parsed);
TypeChecker typeChecker = new ModuleTypeChecker(checked);
typeChecker.typeCheck();
after = System.currentTimeMillis();
Console.out.println("Type checked in " + (double)(after-before)/1000 + " secs. ");
Console.out.println("There were " + TypeChecker.getWarningCount() + " warnings");
TypeChecker.printErrors(Console.out);
//assertEquals("Type check errors", 0, TypeChecker.getErrorCount());
assertEquals("Type check errors", expected.length, TypeChecker.getErrorCount());
int p = 0;
for (VDMError err: TypeChecker.getErrors())
{
assertEquals("Type checking error", err.number, expected[p++].intValue());
}
}