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


Java Environment.findClassDefinition方法代码示例

本文整理汇总了Java中com.fujitsu.vdmj.typechecker.Environment.findClassDefinition方法的典型用法代码示例。如果您正苦于以下问题:Java Environment.findClassDefinition方法的具体用法?Java Environment.findClassDefinition怎么用?Java Environment.findClassDefinition使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.fujitsu.vdmj.typechecker.Environment的用法示例。


在下文中一共展示了Environment.findClassDefinition方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: typeCheck

import com.fujitsu.vdmj.typechecker.Environment; //导入方法依赖的package包/类
@Override
public TCType typeCheck(Environment env, TCTypeList qualifiers, NameScope scope, TCType constraint)
{
	// Each local definition is in scope for later local definitions...

	Environment local = env;

	for (TCDefinition d: localDefs)
	{
		if (d instanceof TCExplicitFunctionDefinition)
		{
			// Functions' names are in scope in their bodies, whereas
			// simple variable declarations aren't

			local = new FlatCheckedEnvironment(d, local, scope);	// cumulative
			d.implicitDefinitions(local);
			d.typeResolve(local);

			if (env.isVDMPP())
			{
				TCClassDefinition cdef = env.findClassDefinition();
				d.setClassDefinition(cdef);
				d.setAccessSpecifier(d.accessSpecifier.getStatic(true));
			}

			d.typeCheck(local, scope);
		}
		else
		{
			d.implicitDefinitions(local);
			d.typeResolve(local);
			d.typeCheck(local, scope);
			local = new FlatCheckedEnvironment(d, local, scope);	// cumulative
		}
	}

	TCType r = expression.typeCheck(local, null, scope, constraint);
	local.unusedCheck(env);
	return r;
}
 
开发者ID:nickbattle,项目名称:FJ-VDMJ,代码行数:41,代码来源:TCLetDefExpression.java

示例2: isAccessible

import com.fujitsu.vdmj.typechecker.Environment; //导入方法依赖的package包/类
/**
 * True, if the field passed can be accessed from the current context.
 */
static public boolean isAccessible(Environment env, TCDefinition field, boolean needStatic)
{
	TCClassDefinition self = env.findClassDefinition();
	TCClassDefinition target = field.classDefinition;

	if (self == null)	// Not called from within a class member
	{
		// We're outside, so just public access
		return (field.accessSpecifier.access == Token.PUBLIC);
	}
	else
	{
		TCClassType selftype = (TCClassType)self.getType();
		TCClassType targtype = (TCClassType)target.getType();

		if (!selftype.equals(targtype))
		{
			if (selftype.hasSupertype(targtype))
			{
				// We're a subclass, so see public or protected
				return (field.accessSpecifier.access != Token.PRIVATE);
			}
			else
			{
				// We're outside, so just public/static access
				return (field.accessSpecifier.access == Token.PUBLIC &&
						(needStatic ? field.accessSpecifier.isStatic : true));
			}
		}
		else
		{
			// else same type, so anything goes
			return true;
		}
	}
}
 
开发者ID:nickbattle,项目名称:FJ-VDMJ,代码行数:40,代码来源:TCClassDefinition.java

示例3: typeCheck

import com.fujitsu.vdmj.typechecker.Environment; //导入方法依赖的package包/类
@Override
public TCType typeCheck(Environment env, NameScope scope, TCType constraint)
{
	targetType = target.typeCheck(env);
	expType = exp.typeCheck(env, null, scope, targetType);

	if (!TypeComparator.compatible(targetType, expType))
	{
		report(3239, "Incompatible types in assignment");
		detail2("Target", targetType, "Expression", expType);
	}

	classDefinition = env.findClassDefinition();
	stateDefinition = env.findStateDefinition();
	inConstructor = inConstructor(env);

	if (inConstructor)
	{
		// Mark assignment target as initialized (so no warnings)

		TCDefinition state = target.targetDefinition(env);

		if (state instanceof TCInstanceVariableDefinition)
		{
			TCInstanceVariableDefinition iv = (TCInstanceVariableDefinition)state;
			iv.initialized = true;
		}
	}

	return new TCVoidType(location);
}
 
开发者ID:nickbattle,项目名称:FJ-VDMJ,代码行数:32,代码来源:TCAssignmentStatement.java

示例4: typeCheck

import com.fujitsu.vdmj.typechecker.Environment; //导入方法依赖的package包/类
@Override
public TCType typeCheck(Environment env, NameScope scope, TCType constraint)
{
	// Each local definition is in scope for later local definitions...

	Environment local = env;

	for (TCDefinition d: localDefs)
	{
		if (d instanceof TCExplicitFunctionDefinition)
		{
			// Functions' names are in scope in their bodies, whereas
			// simple variable declarations aren't

			local = new FlatCheckedEnvironment(d, local, scope);	// cumulative
			d.implicitDefinitions(local);
			d.typeResolve(local);

			if (env.isVDMPP())
			{
				TCClassDefinition cdef = env.findClassDefinition();
				d.setClassDefinition(cdef);
				d.setAccessSpecifier(d.accessSpecifier.getStatic(true));
			}

			d.typeCheck(local, scope);
		}
		else
		{
			d.implicitDefinitions(local);
			d.typeResolve(local);
			d.typeCheck(local, scope);
			local = new FlatCheckedEnvironment(d, local, scope);	// cumulative
		}
	}

	TCType r = statement.typeCheck(local, scope, constraint);
	local.unusedCheck(env);
	return r;
}
 
开发者ID:nickbattle,项目名称:FJ-VDMJ,代码行数:41,代码来源:TCLetDefStatement.java

示例5: typeCheck

import com.fujitsu.vdmj.typechecker.Environment; //导入方法依赖的package包/类
@Override
public TCType typeCheck(Environment env, TCTypeList qualifiers, NameScope scope, TCType constraint)
{
	TCClassDefinition classdef = env.findClassDefinition();

	for (TCNameToken opname: opnames)
	{
		int found = 0;

		for (TCDefinition def: classdef.getDefinitions())
		{
			if (def.name != null && def.name.matches(opname))
			{
				found++;

				if (!def.isCallableOperation())
				{
					opname.report(3105, opname + " is not an explicit operation");
				}
				
				if (def.isPure())
				{
					opname.report(3342, "Cannot use history counters for pure operations");
				}
				
				if (!def.isStatic() && env.isStatic())
				{
					opname.report(3349, "Cannot see non-static operation from static context");
				}
			}
		}

		if (found == 0)
		{
			opname.report(3106, opname + " is not in scope");
		}
		else if (found > 1)
		{
			opname.warning(5004, "History expression of overloaded operation");
		}

		if (opname.getName().equals(classdef.name.getName()))
		{
			opname.report(3107, "Cannot use history of a constructor");
		}
	}

	return new TCNaturalType(location);
}
 
开发者ID:nickbattle,项目名称:FJ-VDMJ,代码行数:50,代码来源:TCHistoryExpression.java

示例6: typeCheck

import com.fujitsu.vdmj.typechecker.Environment; //导入方法依赖的package包/类
@Override
public void typeCheck(Environment base, NameScope scope)
{
	TCClassDefinition classdef = base.findClassDefinition();
	int opfound = 0;
	int perfound = 0;
	Boolean isStatic = null;

	for (TCDefinition def: classdef.getDefinitions())
	{
		if (def.name != null && def.name.matches(opname))
		{
			opfound++;

			if (!def.isCallableOperation())
			{
				opname.report(3042, opname + " is not an explicit operation");
			}
			
			if (isStatic != null && isStatic != def.isStatic())
			{
				opname.report(3323, "Overloaded operation cannot mix static and non-static");
			}
			
			if (def.isPure())
			{
				opname.report(3340, "Pure operation cannot have permission predicate");
			}
			
			isStatic = def.isStatic();
		}

		if (def instanceof TCPerSyncDefinition)
		{
			TCPerSyncDefinition psd = (TCPerSyncDefinition)def;

			if (psd.opname.equals(opname))
			{
				perfound++;
			}
		}
	}

	if (opfound == 0)
	{
		opname.report(3043, opname + " is not in scope");
	}
	else if (opfound > 1)
	{
		opname.warning(5003, "Permission guard of overloaded operation");
	}

	if (perfound != 1)
	{
		opname.report(3044, "Duplicate permission guard found for " + opname);
	}

	if (opname.getName().equals(classdef.name.getName()))
	{
		opname.report(3045, "Cannot put guard on a constructor");
	}

	FlatCheckedEnvironment local = new FlatCheckedEnvironment(this, base, scope);
	local.setEnclosingDefinition(this);	// Prevent op calls
	local.setFunctional(true);
	
	if (isStatic != null)
	{
		local.setStatic(isStatic);
	}
	
	TCType rt = guard.typeCheck(local, null, NameScope.NAMESANDSTATE, new TCBooleanType(location));

	if (!rt.isType(TCBooleanType.class, location))
	{
		guard.report(3046, "Guard is not a boolean expression");
	}
}
 
开发者ID:nickbattle,项目名称:FJ-VDMJ,代码行数:79,代码来源:TCPerSyncDefinition.java


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