本文整理汇总了Java中com.fujitsu.vdmj.runtime.Interpreter类的典型用法代码示例。如果您正苦于以下问题:Java Interpreter类的具体用法?Java Interpreter怎么用?Java Interpreter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Interpreter类属于com.fujitsu.vdmj.runtime包,在下文中一共展示了Interpreter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: writeCoverage
import com.fujitsu.vdmj.runtime.Interpreter; //导入依赖的package包/类
private static void writeCoverage(Interpreter interpreter, File coverage)
throws IOException
{
Properties.init();
for (File f: interpreter.getSourceFiles())
{
SourceFile source = interpreter.getSourceFile(f);
File data = new File(coverage.getPath() + File.separator + f.getName() + ".covtbl");
PrintWriter pw = new PrintWriter(data);
source.writeCoverage(pw);
pw.close();
}
Properties.parser_tabstop = 1;
}
示例2: mkRecord
import com.fujitsu.vdmj.runtime.Interpreter; //导入依赖的package包/类
public static RecordValue mkRecord(String module, String name, Value ...args) throws ValueException
{
TCType type = getType(module, name);
if (type instanceof TCRecordType)
{
TCRecordType r = (TCRecordType)type;
ValueList l = new ValueList();
for (int a=0; a<args.length; a++)
{
l.add(args[a]);
}
return new RecordValue(r, l, Interpreter.getInstance().getInitialContext());
}
else
{
throw new ValueException(69, "Definition " + module + "`" + name +
" is " + type.getClass().getSimpleName() + " not TCRecordType", null);
}
}
示例3: readSpecification
import com.fujitsu.vdmj.runtime.Interpreter; //导入依赖的package包/类
/**
* @see com.fujitsu.vdmjunit.SpecificationReader#readSpecification(Charset, java.util.List)
*/
@Override
protected Interpreter readSpecification(Charset charset, List<File> files) throws Exception
{
ASTModuleList parsedModules = new ASTModuleList();
for (File file: files)
{
LexTokenReader lexer = new LexTokenReader(file, Settings.dialect, charset.toString());
ModuleReader reader = new ModuleReader(lexer);
parsedModules.addAll(reader.readModules());
if (reader.getErrorCount() > 0)
{
printMessages(reader.getErrors());
fail("Syntax errors (see stdout)");
}
}
TCModuleList checkedModules = ClassMapper.getInstance(TCNode.MAPPINGS).init().convert(parsedModules);
TypeChecker checker = new ModuleTypeChecker(checkedModules);
checker.typeCheck();
if (ModuleTypeChecker.getErrorCount() > 0)
{
printMessages(ModuleTypeChecker.getErrors());
fail("Type errors (see stdout)");
}
INModuleList executableModules = ClassMapper.getInstance(INNode.MAPPINGS).init().convert(checkedModules);
return new ModuleInterpreter(executableModules, checkedModules);
}
示例4: readSpecification
import com.fujitsu.vdmj.runtime.Interpreter; //导入依赖的package包/类
/**
* Parse and type check source files, and create an interpreter. Directories are
* expanded to include any VDM source files they contain.
*
* @param charset The charset for the specification files.
* @param filenames A list of VDM source files or directories.
* @throws Exception
*/
public Interpreter readSpecification(Charset charset, String... filenames) throws Exception
{
List<File> list = new Vector<File>(filenames.length);
for (String filename: filenames)
{
URL url = getClass().getResource("/" + filename);
if (url == null)
{
throw new FileNotFoundException(filename);
}
File file = new File(url.getFile());
if (file.isDirectory())
{
for (File subfile: file.listFiles(Settings.dialect.getFilter()))
{
if (subfile.isFile())
{
list.add(subfile);
}
}
}
else
{
list.add(file);
}
}
return readSpecification(charset, list);
}
示例5: readSpecification
import com.fujitsu.vdmj.runtime.Interpreter; //导入依赖的package包/类
/**
* @see com.fujitsu.vdmjunit.SpecificationReader#readSpecification(Charset, java.util.List)
*/
@Override
protected Interpreter readSpecification(Charset charset, List<File> files) throws Exception
{
ASTClassList parsedClasses = new ASTClassList();
for (File file: files)
{
LexTokenReader lexer = new LexTokenReader(file, Settings.dialect, charset.toString());
ClassReader reader = new ClassReader(lexer);
parsedClasses.addAll(reader.readClasses());
if (reader.getErrorCount() > 0)
{
printMessages(reader.getErrors());
fail("Syntax errors (see stdout)");
}
}
if (Settings.dialect == Dialect.VDM_RT)
{
parsedClasses.add(new ASTCPUClassDefinition());
parsedClasses.add(new ASTBUSClassDefinition());
}
TCClassList checkedClasses = ClassMapper.getInstance(TCNode.MAPPINGS).init().convert(parsedClasses);
ClassTypeChecker checker = new ClassTypeChecker(checkedClasses);
checker.typeCheck();
if (ClassTypeChecker.getErrorCount() > 0)
{
printMessages(ClassTypeChecker.getErrors());
fail("Type errors (see stdout)");
}
INClassList executableClasses = ClassMapper.getInstance(INNode.MAPPINGS).init().convert(checkedClasses);
return new ClassInterpreter(executableClasses, checkedClasses);
}
示例6: seq_of_char2val_
import com.fujitsu.vdmj.runtime.Interpreter; //导入依赖的package包/类
public static Value seq_of_char2val_(Value arg)
{
ValueList result = new ValueList();
try
{
SeqValue seq = (SeqValue) arg;
StringBuilder expression = new StringBuilder();
for (Value v: seq.values)
{
CharacterValue ch = (CharacterValue) v;
expression.append(ch.unicode);
}
LexTokenReader ltr = new LexTokenReader(expression.toString(), Dialect.VDM_PP);
ExpressionReader reader = new ExpressionReader(ltr);
reader.setCurrentModule("VDMUtil");
ASTExpression exp = reader.readExpression();
TCExpression tcexp = ClassMapper.getInstance(TCNode.MAPPINGS).convert(exp);
Interpreter ip = Interpreter.getInstance();
ip.typeCheck(tcexp);
INExpression inexp = ClassMapper.getInstance(INNode.MAPPINGS).convert(tcexp);
result.add(new BooleanValue(true));
Context ctxt = new Context(null, "seq_of_char2val", null);
ctxt.setThreadState(null);
result.add(inexp.eval(ctxt));
}
catch (Exception e)
{
result = new ValueList();
result.add(new BooleanValue(false));
result.add(new NilValue());
}
return new TupleValue(result);
}
示例7: DBGPReader
import com.fujitsu.vdmj.runtime.Interpreter; //导入依赖的package包/类
public DBGPReader(
String host, int port, String ideKey,
Interpreter interpreter, String expression, CPUValue cpu)
{
DBGPReader.host = host;
DBGPReader.port = port;
DBGPReader.ideKey = ideKey;
DBGPReader.interpreter = interpreter;
this.expression = expression;
this.cpu = cpu;
}
示例8: processRuntrace
import com.fujitsu.vdmj.runtime.Interpreter; //导入依赖的package包/类
private void processRuntrace(DBGPCommand c) throws DBGPException
{
if (status == DBGPStatus.BREAK)
{
throw new DBGPException(DBGPErrorCode.NOT_AVAILABLE, c.toString());
}
try
{
String[] parts = c.data.split("\\s+");
int startTest = Integer.parseInt(parts[1]);
int endTest = Integer.parseInt(parts[2]);
boolean debug = Boolean.parseBoolean(parts[3]);
ByteArrayOutputStream out = new ByteArrayOutputStream();
PrintWriter pw = new PrintWriter(out);
Interpreter.setTraceOutput(pw);
breaksSuspended = !debug;
interpreter.runtrace(parts[0], startTest, endTest, debug);
pw.close();
cdataResponse(out.toString());
statusResponse(DBGPStatus.STOPPED, DBGPReason.OK);
}
catch (Exception e)
{
throw new DBGPException(DBGPErrorCode.INTERNAL_ERROR, e.getMessage());
}
finally
{
breaksSuspended = false;
}
}
示例9: equals
import com.fujitsu.vdmj.runtime.Interpreter; //导入依赖的package包/类
@Override
public boolean equals(Object other)
{
if (other instanceof Value)
{
if (equality != null)
{
Context ctxt = Interpreter.getInstance().getInitialContext();
ctxt.setThreadState(null);
ctxt.threadState.setAtomic(true);
try
{
ValueList args = new ValueList();
args.add(this);
args.add((Value)other);
return equality.eval(equality.location, args, ctxt).boolValue(ctxt);
}
catch (ValueException e)
{
throw new RuntimeException(e);
}
finally
{
ctxt.threadState.setAtomic(false);
}
}
else
{
return super.equals(other);
}
}
return false;
}
示例10: mkInvariant
import com.fujitsu.vdmj.runtime.Interpreter; //导入依赖的package包/类
public static InvariantValue mkInvariant(String module, String name, Value x) throws ValueException
{
TCType type = getType(module, name);
if (type instanceof TCNamedType)
{
TCNamedType r = (TCNamedType)type;
return new InvariantValue(r, x, Interpreter.getInstance().getInitialContext());
}
else
{
throw new ValueException(69, "Definition " + module + "`" + name +
" is " + type.getClass().getSimpleName() + " not TCNamedType", null);
}
}
示例11: getType
import com.fujitsu.vdmj.runtime.Interpreter; //导入依赖的package包/类
private static TCType getType(String module, String name) throws ValueException
{
Interpreter i = Interpreter.getInstance();
TCNameToken tcname = new TCNameToken(new LexLocation(), module, name);
TCDefinition def = i.getGlobalEnvironment().findType(tcname, i.getDefaultName());
if (def == null)
{
throw new ValueException(70, "Definition " + tcname.getExplicit(true) + " not found", null);
}
return def.getType();
}
示例12: checkErrors
import com.fujitsu.vdmj.runtime.Interpreter; //导入依赖的package包/类
private void checkErrors(List<VDMMessage> actual)
{
try
{
Interpreter interpreter = new ClassInterpreter(new INClassList(), new TCClassList());
interpreter.init();
Value assertions = interpreter.execute(new File(assertName));
assertTrue("Expecting error list", assertions instanceof SeqValue);
List<Long> expected = new Vector<Long>();
for (Value ex: assertions.seqValue(null))
{
long n = ex.intValue(null);
expected.add(n);
}
List<Long> actNums = new Vector<Long>();
for (VDMMessage m: actual)
{
actNums.add((long)m.number);
}
if (!actNums.equals(expected))
{
Console.out.println("Expected errors: " + listErrNos(expected));
Console.out.println("Actual errors: " + listErrs(actual));
Console.out.println(Utils.listToString(actual, "\n"));
fail("Actual errors not as expected");
}
}
catch (Exception e)
{
fail("Caught: " + e + " in " + assertName);
}
}
示例13: freadval
import com.fujitsu.vdmj.runtime.Interpreter; //导入依赖的package包/类
public static Value freadval(Value fval, Context ctxt)
{
ValueList result = new ValueList();
try
{
File file = new File(stringOf(fval).replace('/', File.separatorChar));
if (!file.isAbsolute())
{
file = new File(new File(".").getParentFile(), file.getAbsolutePath());
}
LexTokenReader ltr = new LexTokenReader(file, Dialect.VDM_PP, VDMJ.filecharset);
ExpressionReader reader = new ExpressionReader(ltr);
reader.setCurrentModule("IO");
ASTExpression exp = reader.readExpression();
TCExpression tcexp = ClassMapper.getInstance(TCNode.MAPPINGS).convert(exp);
Interpreter ip = Interpreter.getInstance();
ip.typeCheck(tcexp);
INExpression inexp = ClassMapper.getInstance(INNode.MAPPINGS).convert(tcexp);
result.add(new BooleanValue(true));
result.add(inexp.eval(ctxt));
}
catch (Exception e)
{
lastError = e.toString();
result = new ValueList();
result.add(new BooleanValue(false));
result.add(new NilValue());
}
return new TupleValue(result);
}
示例14: DBGPReaderV2
import com.fujitsu.vdmj.runtime.Interpreter; //导入依赖的package包/类
private DBGPReaderV2(String host, int port, String ideKey,
Interpreter interpreter, String expression, CPUValue cpu)
{
super(host, port, ideKey, interpreter, expression, cpu);
}
示例15: doCommand
import com.fujitsu.vdmj.runtime.Interpreter; //导入依赖的package包/类
private boolean doCommand()
{
try
{
Breakpoint bp = link.getBreakpoint(debuggedThread);
LexLocation loc = link.getLocation(debuggedThread);
if (bp != null && bp.number != 0) // Zero is used for next/step breakpoints.
{
Console.out.println("Stopped " + bp);
Console.out.println(Interpreter.getInstance().getSourceLine(bp.location));
lastLoc = bp.location;
}
else if (loc == null)
{
Console.out.printf("Thread %s has not yet started\n", debuggedThread.getName());
}
else // Only print the source if we have moved
{
if (!debuggedThread.equals(lastThread) || !loc.equals(lastLoc))
{
Console.out.println(Interpreter.getInstance().getSourceLine(loc));
lastLoc = loc;
}
}
DebugCommand command = null;
while (command == null)
{
Console.out.printf("%s> ", debuggedThread.getName());
Console.out.flush();
command = DebugParser.parse(Console.in.readLine().trim());
}
switch (command.getType())
{
case THREADS:
doThreads();
return true;
case THREAD:
doThread(command);
return true;
default:
{
DebugCommand response = link.sendCommand(debuggedThread, command);
switch (response.getType())
{
case RESUME:
link.resumeThreads();
return false;
case STOP:
case QUIT:
link.killThreads();
return false;
default:
Console.out.println(response); // toString of commands are sensible
return true;
}
}
}
}
catch (IOException e)
{
return false;
}
}