當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。