當前位置: 首頁>>代碼示例>>Java>>正文


Java Interpreter類代碼示例

本文整理匯總了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;
}
 
開發者ID:nickbattle,項目名稱:FJ-VDMJ,代碼行數:18,代碼來源:DBGPReader.java

示例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);
	}
}
 
開發者ID:nickbattle,項目名稱:FJ-VDMJ,代碼行數:23,代碼來源:ValueFactory.java

示例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);
}
 
開發者ID:nickbattle,項目名稱:FJ-VDMJ,代碼行數:35,代碼來源:SLSpecificationReader.java

示例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);
}
 
開發者ID:nickbattle,項目名稱:FJ-VDMJ,代碼行數:42,代碼來源:SpecificationReader.java

示例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);
}
 
開發者ID:nickbattle,項目名稱:FJ-VDMJ,代碼行數:41,代碼來源:OOSpecificationReader.java

示例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);
}
 
開發者ID:nickbattle,項目名稱:FJ-VDMJ,代碼行數:39,代碼來源:VDMUtil.java

示例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;
}
 
開發者ID:nickbattle,項目名稱:FJ-VDMJ,代碼行數:13,代碼來源:DBGPReader.java

示例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;
	}
}
 
開發者ID:nickbattle,項目名稱:FJ-VDMJ,代碼行數:34,代碼來源:DBGPReader.java

示例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;
}
 
開發者ID:nickbattle,項目名稱:FJ-VDMJ,代碼行數:36,代碼來源:InvariantValue.java

示例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);
	}
}
 
開發者ID:nickbattle,項目名稱:FJ-VDMJ,代碼行數:16,代碼來源:ValueFactory.java

示例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();
}
 
開發者ID:nickbattle,項目名稱:FJ-VDMJ,代碼行數:14,代碼來源:ValueFactory.java

示例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);
	}
}
 
開發者ID:nickbattle,項目名稱:FJ-VDMJ,代碼行數:40,代碼來源:OvertureTest.java

示例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);
}
 
開發者ID:nickbattle,項目名稱:vdmj,代碼行數:36,代碼來源:IO.java

示例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);
}
 
開發者ID:nickbattle,項目名稱:FJ-VDMJ,代碼行數:6,代碼來源:DBGPReaderV2.java

示例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;
	}
}
 
開發者ID:nickbattle,項目名稱:FJ-VDMJ,代碼行數:73,代碼來源:ConsoleDebugReader.java


注:本文中的com.fujitsu.vdmj.runtime.Interpreter類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。