本文整理汇总了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;
}
示例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;
}
}
}
示例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);
}
示例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;
}
示例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);
}
示例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");
}
}