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


Java Environment.findType方法代碼示例

本文整理匯總了Java中com.fujitsu.vdmj.typechecker.Environment.findType方法的典型用法代碼示例。如果您正苦於以下問題:Java Environment.findType方法的具體用法?Java Environment.findType怎麽用?Java Environment.findType使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.fujitsu.vdmj.typechecker.Environment的用法示例。


在下文中一共展示了Environment.findType方法的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: typeCheck

import com.fujitsu.vdmj.typechecker.Environment; //導入方法依賴的package包/類
@Override
public TCType typeCheck(Environment env, TCTypeList qualifiers, NameScope scope, TCType constraint)
{
	TCDefinition cls = env.findType(classname, null);

	if (cls == null || !(cls instanceof TCClassDefinition))
	{
		report(3115, "Undefined class type: " + classname.getName());
	}
	else
	{
		classType = (TCClassType)cls.getType();
	}

	TCType rt = exp.typeCheck(env, null, scope, null);

	if (!rt.isClass(env))
	{
		exp.report(3266, "Argument is not an object");
	}

	return checkConstraint(constraint, new TCBooleanType(location));
}
 
開發者ID:nickbattle,項目名稱:FJ-VDMJ,代碼行數:24,代碼來源:TCIsOfClassExpression.java

示例2: typeCheck

import com.fujitsu.vdmj.typechecker.Environment; //導入方法依賴的package包/類
@Override
public TCType typeCheck(Environment env, TCTypeList qualifiers, NameScope scope, TCType constraint)
{
	if (env.findType(baseclass, null) == null)
	{
		report(3114, "Undefined base class type: " + baseclass.getName());
	}

	TCType rt = exp.typeCheck(env, null, scope, null);

	if (!rt.isClass(env))
	{
		exp.report(3266, "Argument is not an object");
	}

	return checkConstraint(constraint, new TCBooleanType(location));
}
 
開發者ID:nickbattle,項目名稱:FJ-VDMJ,代碼行數:18,代碼來源:TCIsOfBaseClassExpression.java

示例3: typeCheck

import com.fujitsu.vdmj.typechecker.Environment; //導入方法依賴的package包/類
@Override
public TCType typeCheck(Environment env, TCTypeList qualifiers, NameScope scope, TCType constraint)
{
	test.typeCheck(env, null, scope, null);

	if (basictype != null)
	{
		basictype = basictype.typeResolve(env, null);
		TypeComparator.checkComposeTypes(basictype, env, false);
	}

	if (typename != null)
	{
		typedef = env.findType(typename, location.module);

		if (typedef == null)
		{
			report(3113, "Unknown type name '" + typename + "'");
		}
	}

	return checkConstraint(constraint, new TCBooleanType(location));
}
 
開發者ID:nickbattle,項目名稱:FJ-VDMJ,代碼行數:24,代碼來源:TCIsExpression.java

示例4: typeCheck

import com.fujitsu.vdmj.typechecker.Environment; //導入方法依賴的package包/類
@Override
public TCType typeCheck(Environment env, TCTypeList qualifiers, NameScope scope, TCType constraint)
{
	exptype = test.typeCheck(env, null, scope, null);
	TCType result = null;

	if (basictype != null)
	{
		basictype = basictype.typeResolve(env, null);
		result = basictype;
		TypeComparator.checkComposeTypes(basictype, env, false);
	}
	else
	{
		typedef = env.findType(typename, location.module);

		if (typedef == null)
		{
			report(3113, "Unknown type name '" + typename + "'");
			result = new TCUnknownType(location);
		}
		else
		{
			result = typedef.getType();
		}
	}
	
	if (!TypeComparator.compatible(result, exptype))
	{
		report(3317, "Expression can never match narrow type");
	}
	
	return possibleConstraint(constraint, result);
}
 
開發者ID:nickbattle,項目名稱:FJ-VDMJ,代碼行數:35,代碼來源:TCNarrowExpression.java

示例5: getQualifiedDefs

import com.fujitsu.vdmj.typechecker.Environment; //導入方法依賴的package包/類
@Override
public TCDefinitionList getQualifiedDefs(Environment env)
{
	TCDefinitionList result = new TCDefinitionList();
	
	if (test instanceof TCVariableExpression)
	{
		TCVariableExpression exp = (TCVariableExpression)test;
		TCDefinition existing = env.findName(exp.name, NameScope.NAMESANDSTATE);
		
		if (existing != null && existing.nameScope.matches(NameScope.NAMES))
		{
       		if (basictype != null)
       		{
      				result.add(new TCQualifiedDefinition(existing, basictype));
       		}
       		else if (typename != null)
       		{
       			if (typedef == null)
       			{
       				typedef = env.findType(typename, location.module);
       			}

       			if (typedef != null)
       			{
       				result.add(new TCQualifiedDefinition(existing, typedef.getType()));
       			}
       		}
		}
	}
	
	return result;
}
 
開發者ID:nickbattle,項目名稱:FJ-VDMJ,代碼行數:34,代碼來源:TCIsExpression.java

示例6: getFreeVariables

import com.fujitsu.vdmj.typechecker.Environment; //導入方法依賴的package包/類
@Override
public TCNameSet getFreeVariables(Environment env)
{
	if (env.findType(name, name.getModule()) == null)
	{
		// Invariant values covered in TCTypeDefinition
		return new TCNameSet(name.getExplicit(true));
	}
	else
	{
		return new TCNameSet();
	}
}
 
開發者ID:nickbattle,項目名稱:FJ-VDMJ,代碼行數:14,代碼來源:TCRecordType.java

示例7: getFreeVariables

import com.fujitsu.vdmj.typechecker.Environment; //導入方法依賴的package包/類
@Override
public TCNameSet getFreeVariables(Environment env)
{
	if (env.findType(typename, typename.getModule()) == null)
	{
		// Invariant values covered in TCTypeDefinition
		return new TCNameSet(typename.getExplicit(true));
	}
	else
	{
		return new TCNameSet();
	}
}
 
開發者ID:nickbattle,項目名稱:FJ-VDMJ,代碼行數:14,代碼來源:TCNamedType.java

示例8: typeCheck

import com.fujitsu.vdmj.typechecker.Environment; //導入方法依賴的package包/類
@Override
public TCType typeCheck(Environment env, TCTypeList qualifiers, NameScope scope, TCType constraint)
{
	TCDefinition typeDef = env.findType(typename, location.module);

	if (typeDef == null)
	{
		report(3126, "Unknown type '" + typename + "' in constructor");
		return new TCUnknownType(location);
	}

	TCType rec = typeDef.getType();

	if (!(rec instanceof TCRecordType))
	{
		report(3127, "Type '" + typename + "' is not a record type");
		return rec;
	}

	recordType = (TCRecordType)rec;

	if (recordType.opaque && !location.module.equals(recordType.location.module))
	{
		report(3127, "Type '" + typename + "' is not a record type");
		return rec;
	}

	if (typename.isExplicit())
	{
		// If the type name is explicit, the TCType ought to have an explicit
		// name. This only really affects trace expansion.

		TCExplicitFunctionDefinition inv = recordType.invdef;
		TCExplicitFunctionDefinition eq = recordType.eqdef;
		TCExplicitFunctionDefinition ord = recordType.orddef;

		recordType = new TCRecordType(recordType.name, recordType.fields, recordType.composed);
		recordType.setInvariant(inv);
		recordType.setEquality(eq);
		recordType.setOrder(ord);
	}

	if (recordType.fields.size() != args.size())
	{
		report(3128, "Record and constructor do not have same number of fields");
		return rec;
	}

	int i=0;
	Iterator<TCField> fiter = recordType.fields.iterator();
	argTypes = new TCTypeList();

	for (TCExpression arg: args)
	{
		TCType fieldType = fiter.next().type;
		TCType argType = arg.typeCheck(env, null, scope, fieldType);
		i++;

		if (!TypeComparator.compatible(fieldType, argType))
		{
			report(3129, "Constructor field " + i + " is of wrong type");
			detail2("Expected", fieldType, "Actual", argType);
		}

		argTypes.add(argType);
	}

	return checkConstraint(constraint, recordType);
}
 
開發者ID:nickbattle,項目名稱:FJ-VDMJ,代碼行數:70,代碼來源:TCMkTypeExpression.java

示例9: typeCheck

import com.fujitsu.vdmj.typechecker.Environment; //導入方法依賴的package包/類
@Override
public TCType typeCheck(Environment env, TCTypeList qualifiers, NameScope scope, TCType constraint)
{
	TCDefinition cdef = env.findType(classname.getClassName(), null);

	if (cdef == null || !(cdef instanceof TCClassDefinition))
	{
		report(3133, "Class name " + classname + " not in scope");
		return new TCUnknownType(location);
	}
	
	if (Settings.release == Release.VDM_10 && env.isFunctional())
	{
		report(3348, "Cannot use 'new' in a functional context");
	}

	classdef = (TCClassDefinition)cdef;

	if (classdef instanceof TCSystemDefinition)
	{
		report(3279, "Cannot instantiate system class " + classdef.name);
	}
	
	if (classdef.isAbstract)
	{
		report(3330, "Cannot instantiate abstract class " + classdef.name);
		
		for (TCDefinition d: classdef.getLocalDefinitions())
		{
			if (d.isSubclassResponsibility())
			{
				detail("Unimplemented", d.name.getName() + d.getType());
			}
		}
	}

	TCTypeList argtypes = new TCTypeList();

	for (TCExpression a: args)
	{
		argtypes.add(a.typeCheck(env, null, scope, null));
	}

	TCDefinition opdef = classdef.findConstructor(argtypes);

	if (opdef == null)
	{
		if (!args.isEmpty())	// Not having a default ctor is OK
   		{
   			report(3134, "Class has no constructor with these parameter types");
   			detail("Called", classdef.getCtorName(argtypes));
   		}
		else if (classdef instanceof TCCPUClassDefinition ||
				 classdef instanceof TCBUSClassDefinition)
		{
			report(3297, "Cannot use default constructor for this class");
		}
	}
	else
	{
		if (!opdef.isCallableOperation())
   		{
   			report(3135, "Class has no constructor with these parameter types");
   			detail("Called", classdef.getCtorName(argtypes));
   		}
		else if (!TCClassDefinition.isAccessible(env, opdef, false))
		{
   			report(3292, "Constructor is not accessible");
   			detail("Called", classdef.getCtorName(argtypes));
		}
		else
		{
			ctordef = opdef;
		}
	}

	return checkConstraint(constraint, classdef.getType());
}
 
開發者ID:nickbattle,項目名稱:FJ-VDMJ,代碼行數:79,代碼來源:TCNewExpression.java

示例10: dereference

import com.fujitsu.vdmj.typechecker.Environment; //導入方法依賴的package包/類
private TCType dereference(Environment env, TCTypeDefinition root)
{
	TCDefinition def = env.findType(typename, location.module);

	if (def == null)
	{
		throw new TypeCheckException(
			"Unable to resolve type name '" + typename + "'", location);
	}

	if (def instanceof TCImportedDefinition)
	{
		TCImportedDefinition idef = (TCImportedDefinition)def;
		def = idef.def;
	}

	if (def instanceof TCRenamedDefinition)
	{
		TCRenamedDefinition rdef = (TCRenamedDefinition)def;
		def = rdef.def;
	}

	if (!(def instanceof TCTypeDefinition) &&
		!(def instanceof TCStateDefinition) &&
		!(def instanceof TCClassDefinition) &&
		!(def instanceof TCInheritedDefinition))
	{
		report(3434, "'" + typename + "' is not the name of a type definition");
	}

	if (def instanceof TCTypeDefinition)
	{
		if (def == root)
		{
			root.infinite = true;
		}
	}

	if ((def instanceof TCCPUClassDefinition ||
		 def instanceof TCBUSClassDefinition) && !env.isSystem())
	{
		report(3296, "Cannot use '" + typename + "' outside system class");
	}

	TCType r = def.getType();
	r.definitions = new TCDefinitionList(def);
	return r;
}
 
開發者ID:nickbattle,項目名稱:FJ-VDMJ,代碼行數:49,代碼來源:TCUnresolvedType.java

示例11: typeCheck

import com.fujitsu.vdmj.typechecker.Environment; //導入方法依賴的package包/類
@Override
public void typeCheck(Environment base, NameScope scope)
{
	getDefinitions().setExcluded(true);
	expType = exp.typeCheck(base, null, scope, type);
	getDefinitions().setExcluded(false);
	
	if (expType instanceof TCUnknownType)
	{
		pass = Pass.FINAL;	// Come back to this
	}
	
	if (expType instanceof TCVoidType)
	{
		exp.report(3048, "Expression does not return a value");
	}
	else if (type != null && !(type instanceof TCUnknownType))
	{
		TypeComparator.checkComposeTypes(type, base, false);
		
		if (!TypeComparator.compatible(type, expType))
		{
			report(3051, "Expression does not match declared type");
			detail2("Declared", type, "Expression", expType);
		}
	}
	else
	{
		type = expType;
	}

	if (base.isVDMPP() && type instanceof TCNamedType)
	{
		TCNamedType named = (TCNamedType)type;
   		TCDefinition typedef = base.findType(named.typename, location.module);

   		if (typedef.accessSpecifier.narrowerThan(accessSpecifier))
   		{
   			report(3052, "Value type visibility less than value definition");
   		}
	}

	pattern.typeResolve(base);
	updateDefs();
	defs.typeCheck(base, scope);
}
 
開發者ID:nickbattle,項目名稱:FJ-VDMJ,代碼行數:47,代碼來源:TCValueDefinition.java

示例12: setInherited

import com.fujitsu.vdmj.typechecker.Environment; //導入方法依賴的package包/類
/**
 * Create the class hierarchy. This populates the superdefs and supertypes
 * fields, while first calling setInherited of the superclasses first. The
 * settingHierarchy field is used to avoid loops.
 *
 * @param base
 */
private void setInherited(Environment base)
{
	switch (settingHierarchy)
	{
		case UNSET:
			settingHierarchy = Setting.INPROGRESS;
			break;

		case INPROGRESS:
			report(3002, "Circular class hierarchy detected: " + name);
			return;

		case DONE:
			return;
	}

	definitions.implicitDefinitions(base);

	for (TCNameToken supername: supernames)
	{
		TCDefinition def = base.findType(supername, null);

		if (def == null)
		{
			report(3003, "Undefined superclass: " + supername);
		}
		else if (def instanceof TCCPUClassDefinition)
		{
			report(3298, "Cannot inherit from CPU");
		}
		else if (def instanceof TCBUSClassDefinition)
		{
			report(3299, "Cannot inherit from BUS");
		}
		else if (def instanceof TCSystemDefinition)
		{
			report(3278, "Cannot inherit from system class " + supername);
		}
		else if (def instanceof TCClassDefinition)
		{
			TCClassDefinition superdef = (TCClassDefinition)def;
			superdef.setInherited(base);
			superdefs.add(superdef);
			supertypes.add(superdef.getType());
		}
		else
		{
			report(3004, "Superclass name is not a class: " + supername);
		}
	}

	settingHierarchy = Setting.DONE;
	return;
}
 
開發者ID:nickbattle,項目名稱:FJ-VDMJ,代碼行數:62,代碼來源:TCClassDefinition.java


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