当前位置: 首页>>代码示例>>Java>>正文


Java TCExpression类代码示例

本文整理汇总了Java中com.fujitsu.vdmj.tc.expressions.TCExpression的典型用法代码示例。如果您正苦于以下问题:Java TCExpression类的具体用法?Java TCExpression怎么用?Java TCExpression使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


TCExpression类属于com.fujitsu.vdmj.tc.expressions包,在下文中一共展示了TCExpression类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: parseExpression

import com.fujitsu.vdmj.tc.expressions.TCExpression; //导入依赖的package包/类
@Override
protected TCExpression parseExpression(String line, String module) throws Exception
{
	LexTokenReader ltr = new LexTokenReader(line, Settings.dialect, Console.charset);
	ExpressionReader reader = new ExpressionReader(ltr);
	reader.setCurrentModule(module);
	ASTExpression ast = reader.readExpression();
	LexToken end = ltr.getLast();
	
	if (!end.is(Token.EOF))
	{
		throw new ParserException(2330, "Tokens found after expression at " + end, new LexLocation(), 0);
	}

	return ClassMapper.getInstance(TCNode.MAPPINGS).convert(ast);
}
 
开发者ID:nickbattle,项目名称:FJ-VDMJ,代码行数:17,代码来源:ClassInterpreter.java

示例2: evaluate

import com.fujitsu.vdmj.tc.expressions.TCExpression; //导入依赖的package包/类
/**
	 * Parse the line passed, and evaluate it as an expression in the context
	 * passed.
	 *
	 * @param line A VDM expression.
	 * @param ctxt The context in which to evaluate the expression.
	 * @return The value of the expression.
	 * @throws Exception Parser or runtime errors.
	 */
	@Override
	public Value evaluate(String line, Context ctxt) throws Exception
	{
		TCExpression expr = parseExpression(line, getDefaultName());
//		Environment globals = getGlobalEnvironment();
//		Environment env = new PrivateClassEnvironment(defaultClass, globals);

		try
		{
			typeCheck(expr);
		}
		catch (VDMErrorsException e)
		{
			// We don't care... we just needed to type check it.
		}

		ctxt.threadState.init();
		INExpression inex = ClassMapper.getInstance(INNode.MAPPINGS).convert(expr);
		return inex.eval(ctxt);
	}
 
开发者ID:nickbattle,项目名称:FJ-VDMJ,代码行数:30,代码来源:ClassInterpreter.java

示例3: parseExpression

import com.fujitsu.vdmj.tc.expressions.TCExpression; //导入依赖的package包/类
@Override
protected TCExpression parseExpression(String line, String module) throws Exception
{
	LexTokenReader ltr = new LexTokenReader(line, Dialect.VDM_SL, Console.charset);
	ExpressionReader reader = new ExpressionReader(ltr);
	reader.setCurrentModule(getDefaultName());
	ASTExpression ast = reader.readExpression();
	LexToken end = ltr.getLast();
	
	if (!end.is(Token.EOF))
	{
		throw new ParserException(2330, "Tokens found after expression at " + end, new LexLocation(), 0);
	}
	
	return ClassMapper.getInstance(TCNode.MAPPINGS).convert(ast);
}
 
开发者ID:nickbattle,项目名称:FJ-VDMJ,代码行数:17,代码来源:ModuleInterpreter.java

示例4: execute

import com.fujitsu.vdmj.tc.expressions.TCExpression; //导入依赖的package包/类
/**
 * Parse the line passed, type check it and evaluate it as an expression
 * in the initial module context (with default module's state).
 *
 * @param line A VDM expression.
 * @return The value of the expression.
 * @throws Exception Parser, type checking or runtime errors.
 */
@Override
public Value execute(String line) throws Exception
{
	TCExpression expr = parseExpression(line, getDefaultName());
	typeCheck(expr);

	Context mainContext = new StateContext(defaultModule.name.getLocation(),
			"module scope",	null, defaultModule.getStateContext());

	mainContext.putAll(initialContext);
	mainContext.setThreadState(null);
	clearBreakpointHits();

	// scheduler.reset();
	INExpression inex = ClassMapper.getInstance(INNode.MAPPINGS).convert(expr);
	MainThread main = new MainThread(inex, mainContext);
	main.start();
	scheduler.start(main);

	return main.getResult();	// Can throw ContextException
}
 
开发者ID:nickbattle,项目名称:FJ-VDMJ,代码行数:30,代码来源:ModuleInterpreter.java

示例5: evaluate

import com.fujitsu.vdmj.tc.expressions.TCExpression; //导入依赖的package包/类
/**
 * Parse the line passed, and evaluate it as an expression in the context
 * passed. This is called from the debugger.
 *
 * @param line A VDM expression.
 * @param ctxt The context in which to evaluate the expression.
 * @return The value of the expression.
 * @throws Exception Parser or runtime errors.
 */
@Override
public Value evaluate(String line, Context ctxt) throws Exception
{
	TCExpression tc = null;
	
	try
	{
		tc = parseExpression(line, getDefaultName());
		typeCheck(tc);
	}
	catch (VDMErrorsException e)
	{
		// We don't care... we just needed to type check it.
	}

	ctxt.threadState.init();
	INExpression inex = ClassMapper.getInstance(INNode.MAPPINGS).convert(tc);
	return inex.eval(ctxt);
}
 
开发者ID:nickbattle,项目名称:FJ-VDMJ,代码行数:29,代码来源:ModuleInterpreter.java

示例6: TCExplicitFunctionDefinition

import com.fujitsu.vdmj.tc.expressions.TCExpression; //导入依赖的package包/类
public TCExplicitFunctionDefinition(TCAccessSpecifier accessSpecifier, TCNameToken name,
	TCNameList typeParams, TCFunctionType type,
	TCPatternListList parameters, TCExpression body,
	TCExpression precondition,
	TCExpression postcondition, boolean typeInvariant, TCNameToken measure)
{
	super(Pass.DEFS, name.getLocation(), name, NameScope.GLOBAL);

	this.accessSpecifier = accessSpecifier;
	this.typeParams = typeParams;
	this.type = type;
	this.paramPatternList = parameters;
	this.precondition = precondition;
	this.postcondition = postcondition;
	this.body = body;
	this.isTypeInvariant = typeInvariant;
	this.measure = measure;
	this.isCurried = parameters.size() > 1;

	type.definitions = new TCDefinitionList(this);
	type.instantiated = typeParams == null ? null : false;
}
 
开发者ID:nickbattle,项目名称:FJ-VDMJ,代码行数:23,代码来源:TCExplicitFunctionDefinition.java

示例7: TCValueDefinition

import com.fujitsu.vdmj.tc.expressions.TCExpression; //导入依赖的package包/类
public TCValueDefinition(TCAccessSpecifier accessSpecifier, TCPattern p, TCType type, TCExpression exp)
{
	super(Pass.VALUES, p.location, null, NameScope.GLOBAL);

	this.pattern = p;
	this.type = type;
	this.exp = exp;

	defs = new TCDefinitionList();	// Overwritten in typeCheck

	for (TCNameToken var: pattern.getVariableNames())
	{
		defs.add(new TCUntypedDefinition(location, var));
	}
	
	setAccessSpecifier(accessSpecifier);
}
 
开发者ID:nickbattle,项目名称:FJ-VDMJ,代码行数:18,代码来源:TCValueDefinition.java

示例8: TCExplicitOperationDefinition

import com.fujitsu.vdmj.tc.expressions.TCExpression; //导入依赖的package包/类
public TCExplicitOperationDefinition(TCAccessSpecifier accessSpecifier, TCNameToken name,
	TCOperationType type, TCPatternList parameters,
	TCExpression precondition, TCExpression postcondition,
	TCStatement body)
{
	super(Pass.DEFS, name.getLocation(), name, NameScope.GLOBAL);

	this.accessSpecifier = accessSpecifier;
	this.type = type;
	this.parameterPatterns = parameters;
	this.precondition = precondition;
	this.postcondition = postcondition;
	this.body = body;
	
	setAccessSpecifier(accessSpecifier);
}
 
开发者ID:nickbattle,项目名称:FJ-VDMJ,代码行数:17,代码来源:TCExplicitOperationDefinition.java

示例9: getInitDefinition

import com.fujitsu.vdmj.tc.expressions.TCExpression; //导入依赖的package包/类
private TCExplicitFunctionDefinition getInitDefinition()
{
	LexLocation loc = initPattern.location;
	TCPatternList params = new TCPatternList();
	params.add(initPattern);

	TCPatternListList parameters = new TCPatternListList();
	parameters.add(params);

	TCTypeList ptypes = new TCTypeList();
	ptypes.add(new TCUnresolvedType(name));
	TCFunctionType ftype = new TCFunctionType(loc, ptypes, false, new TCBooleanType(loc));

	TCExpression body = new TCStateInitExpression(this);

	TCExplicitFunctionDefinition def = new TCExplicitFunctionDefinition(TCAccessSpecifier.DEFAULT, name.getInitName(loc),
		null, ftype, parameters, body, null, null, false, null);

	ftype.definitions = new TCDefinitionList(def);
	return def;
}
 
开发者ID:nickbattle,项目名称:FJ-VDMJ,代码行数:22,代码来源:TCStateDefinition.java

示例10: TCTypeDefinition

import com.fujitsu.vdmj.tc.expressions.TCExpression; //导入依赖的package包/类
public TCTypeDefinition(TCAccessSpecifier accessSpecifier, TCNameToken name,
	TCInvariantType type, TCPattern invPattern, TCExpression invExpression,
	TCPattern eqPattern1, TCPattern eqPattern2, TCExpression eqExpression,
	TCPattern ordPattern1, TCPattern ordPattern2, TCExpression ordExpression)
{
	super(Pass.TYPES, name.getLocation(), name, NameScope.TYPENAME);

	this.accessSpecifier = accessSpecifier;
	this.type = type;
	this.invPattern = invPattern;
	this.invExpression = invExpression;
	this.eqPattern1 = eqPattern1;
	this.eqPattern2 = eqPattern2;
	this.eqExpression = eqExpression;
	this.ordPattern1 = ordPattern1;
	this.ordPattern2 = ordPattern2;
	this.ordExpression = ordExpression;
	
	type.definitions = new TCDefinitionList(this);
	composeDefinitions = new TCDefinitionList();
}
 
开发者ID:nickbattle,项目名称:FJ-VDMJ,代码行数:22,代码来源:TCTypeDefinition.java

示例11: getExpression

import com.fujitsu.vdmj.tc.expressions.TCExpression; //导入依赖的package包/类
public TCExpression getExpression(LexNameToken excluding)
{
	TCNameList list = null;

	if (operations.size() == 1)
	{
		list = operations;
	}
	else
	{
		list = new TCNameList();
		list.addAll(operations);
		list.remove(excluding);
	}

	return new TCEqualsExpression(
		new TCHistoryExpression(location, Token.ACTIVE, list),
   		new LexKeywordToken(Token.EQUALS, location),
   		new TCIntegerLiteralExpression(new LexIntegerToken(0, location)));
}
 
开发者ID:nickbattle,项目名称:vdmj,代码行数:21,代码来源:TCMutexSyncDefinition.java

示例12: seq_of_char2val_

import com.fujitsu.vdmj.tc.expressions.TCExpression; //导入依赖的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

示例13: execute

import com.fujitsu.vdmj.tc.expressions.TCExpression; //导入依赖的package包/类
/**
 * Parse the line passed, type check it and evaluate it as an expression
 * in the initial context.
 *
 * @param line A VDM expression.
 * @return The value of the expression.
 * @throws Exception Parser, type checking or runtime errors.
 */
@Override
public Value execute(String line) throws Exception
{
	TCExpression expr = parseExpression(line, getDefaultName());
	typeCheck(expr);
	INExpression inex = ClassMapper.getInstance(INNode.MAPPINGS).convert(expr);
	return execute(inex);
}
 
开发者ID:nickbattle,项目名称:FJ-VDMJ,代码行数:17,代码来源:ClassInterpreter.java

示例14: create

import com.fujitsu.vdmj.tc.expressions.TCExpression; //导入依赖的package包/类
public void create(String var, String exp) throws Exception
{
	TCExpression expr = parseExpression(exp, getDefaultName());
	TCType type = typeCheck(expr);
	Value v = execute(exp);

	LexLocation location = defaultClass.location;
	TCNameToken name = new TCNameToken(location, defaultClass.name.getName(), var);

	createdValues.put(name, v);
	createdDefinitions.add(new TCLocalDefinition(location, name, type));
}
 
开发者ID:nickbattle,项目名称:FJ-VDMJ,代码行数:13,代码来源:ClassInterpreter.java

示例15: typeCheck

import com.fujitsu.vdmj.tc.expressions.TCExpression; //导入依赖的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;
}
 
开发者ID:nickbattle,项目名称:FJ-VDMJ,代码行数:31,代码来源:Interpreter.java


注:本文中的com.fujitsu.vdmj.tc.expressions.TCExpression类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。