当前位置: 首页>>代码示例>>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;未经允许,请勿转载。