ESC/Java2
© 2003,2004,2005 David Cok and Joseph Kiniry
© 2005 UCD Dublin
© 2003,2004 Radboud University Nijmegen
© 1999,2000 Compaq Computer Corporation
© 1997,1998,1999 Digital Equipment Corporation
All Rights Reserved

javafe.tc
Class FlowInsensitiveChecks

java.lang.Object
  extended byjavafe.tc.FlowInsensitiveChecks
Direct Known Subclasses:
FlowInsensitiveChecks

public class FlowInsensitiveChecks
extends java.lang.Object

Does disambiguation and flow insensitive checks on a type declaration.


Field Summary
protected  TypeSigVec allowedExceptions
           
private static ASTDecoration branchDecoration
          Decorates BranchStmt nodes to point to labelled Stmt objects.
static boolean dontAddImplicitConstructorInvocations
          Controls whether or not implicit super-calls in constructors are made explicit.
protected  StmtVec enclosingLabels
           
static FlowInsensitiveChecks inst
           
protected  boolean leftToRight
           
protected  Type returnType
           
protected  EnvForTypeSig rootIEnv
           
protected  EnvForTypeSig rootSEnv
           
protected  TypeSig sig
           
private static ASTDecoration typeDecoration
          Decorates VarInit nodes to point to Type objects.
 
Constructor Summary
protected FlowInsensitiveChecks()
           
 
Method Summary
protected  boolean assignmentConvertable(Expr e, Type t)
          Checks if Exp e can be assigned to Type t.
protected  Type checkBinaryExpr(int op, Expr left, Expr right, int loc)
           
protected  Expr checkDesignator(Env env, Expr e)
           
protected  Expr checkExpr(Env env, Expr x)
          This method should call setType on x before its done.
protected  Expr checkExpr(Env env, Expr expr, Type t)
           
protected  Type[] checkExprVec(Env env, ExprVec ev)
           
 void checkFieldDecl(FieldDecl fd)
          Moves fd into implementation checked state.
protected  void checkForLoopAfterInit(Env se, ForStmt f)
           
protected  VarInit checkInit(Env env, VarInit x, Type expectedResult)
           
(package private) static boolean checkIntegralType(Expr e)
           
protected  Env checkModifierPragma(ModifierPragma p, ASTNode ctxt, Env env)
          Hook to do additional processing on Modifiers.
protected  Env checkModifierPragmaVec(ModifierPragmaVec v, ASTNode ctxt, Env env)
          Hook to do additional processing on ModifierVecs.
(package private) static boolean checkNumericType(Expr e)
           
protected  Type checkObjectDesignator(Env env, ObjectDesignator od)
           
protected  Env checkStmt(Env e, Stmt s)
          Typecheck a statement in a given environment then return the environment in effect for statements that follow the given statement.
protected  Env checkStmtPragma(Env e, StmtPragma s)
           
protected  Env checkStmtVec(Env env, StmtVec v)
           
(package private) static void checkType(Expr expr, Type t)
           
 void checkTypeDeclaration(TypeSig s)
          Moves s into implementation checked state.
protected  void checkTypeDeclElem(TypeDeclElem e)
           
protected  void checkTypeDeclElemPragma(TypeDeclElemPragma e)
           
protected  Env checkTypeModifierPragma(TypeModifierPragma p, ASTNode ctxt, Env env)
           
protected  Env checkTypeModifierPragmaVec(TypeModifierPragmaVec v, ASTNode ctxt, Env env)
           
protected  Env checkTypeModifiers(Env env, Type t)
          This may be called more than once on a Type t.
(package private) static Stmt getBranchLabel(BranchStmt s)
          Retrieves the Stmt target of a BranchStmt.
static Type getType(VarInit i)
          Retrieves the Type of a VarInit.
protected static Type getTypeOrNull(VarInit i)
          Retrieves the Type of a VarInit.
static FlowInsensitiveChecks inst()
           
(package private) static boolean isVariable(Expr e)
           
protected  EnvForTypeSig makeEnvForTypeSig(TypeSig s, boolean staticContext)
          Factory method so subclasses can override.
protected static void reportLookupException(LookupException e, java.lang.String s, java.lang.String t, int loc)
           
private static void setBranchLabel(BranchStmt s, Stmt l)
           
static VarInit setType(VarInit i, Type t)
           
private  Type tryCondExprMatch(Expr leftExpr, Expr rightExpr)
          Return the type of a E1 : L ?
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

inst

public static FlowInsensitiveChecks inst

dontAddImplicitConstructorInvocations

public static boolean dontAddImplicitConstructorInvocations
Controls whether or not implicit super-calls in constructors are made explicit. By default they are.


sig

protected TypeSig sig

rootIEnv

protected EnvForTypeSig rootIEnv

rootSEnv

protected EnvForTypeSig rootSEnv

leftToRight

protected boolean leftToRight

returnType

protected Type returnType

allowedExceptions

protected TypeSigVec allowedExceptions

enclosingLabels

protected StmtVec enclosingLabels

typeDecoration

private static ASTDecoration typeDecoration
Decorates VarInit nodes to point to Type objects.


branchDecoration

private static ASTDecoration branchDecoration
Decorates BranchStmt nodes to point to labelled Stmt objects.

Constructor Detail

FlowInsensitiveChecks

protected FlowInsensitiveChecks()
Method Detail

inst

public static FlowInsensitiveChecks inst()

makeEnvForTypeSig

protected EnvForTypeSig makeEnvForTypeSig(TypeSig s,
                                          boolean staticContext)
Factory method so subclasses can override.


checkTypeDeclaration

public void checkTypeDeclaration(TypeSig s)
Moves s into implementation checked state.


checkFieldDecl

public void checkFieldDecl(FieldDecl fd)
Moves fd into implementation checked state.


checkTypeDeclElem

protected void checkTypeDeclElem(TypeDeclElem e)

checkStmt

protected Env checkStmt(Env e,
                        Stmt s)
Typecheck a statement in a given environment then return the environment in effect for statements that follow the given statement.

(The returned environment will be the same as the one passed in unless the statement is a declaration.)


checkForLoopAfterInit

protected void checkForLoopAfterInit(Env se,
                                     ForStmt f)

checkStmtVec

protected Env checkStmtVec(Env env,
                           StmtVec v)

checkExprVec

protected Type[] checkExprVec(Env env,
                              ExprVec ev)

checkInit

protected VarInit checkInit(Env env,
                            VarInit x,
                            Type expectedResult)

checkDesignator

protected Expr checkDesignator(Env env,
                               Expr e)

checkExpr

protected Expr checkExpr(Env env,
                         Expr expr,
                         Type t)

checkExpr

protected Expr checkExpr(Env env,
                         Expr x)
This method should call setType on x before its done.


checkObjectDesignator

protected Type checkObjectDesignator(Env env,
                                     ObjectDesignator od)

tryCondExprMatch

private Type tryCondExprMatch(Expr leftExpr,
                              Expr rightExpr)
Return the type of a E1 : L ? R expression given the typechecked Expr's for L and R, as per JLS 15.24.

Returns:
null if the given combination is illegal.

checkBinaryExpr

protected Type checkBinaryExpr(int op,
                               Expr left,
                               Expr right,
                               int loc)

checkIntegralType

static boolean checkIntegralType(Expr e)

checkNumericType

static boolean checkNumericType(Expr e)

isVariable

static boolean isVariable(Expr e)

setType

public static VarInit setType(VarInit i,
                              Type t)

getTypeOrNull

protected static Type getTypeOrNull(VarInit i)
Retrieves the Type of a VarInit. This type is associated with an expression by the typechecking pass. If the expression does not have an associated type, then null is returned.


getType

public static Type getType(VarInit i)
Retrieves the Type of a VarInit. This type is associated with an expression by the typechecking pass. If the expression does not have an associated type, then Assert.fail is called.


setBranchLabel

private static void setBranchLabel(BranchStmt s,
                                   Stmt l)

getBranchLabel

static Stmt getBranchLabel(BranchStmt s)
Retrieves the Stmt target of a BranchStmt. This Stmt may be mentioned either explicitly (as in break label;), or implicitly (as in break;) by the BranchStmt. The correct Stmt target is associated with the BranchStmt by the typechecking pass. This type is associated with an expression by the typechecking pass. If the BranchStmt does not have an associated Stmt target, then Assert.fail is called.


checkType

static void checkType(Expr expr,
                      Type t)

reportLookupException

protected static void reportLookupException(LookupException e,
                                            java.lang.String s,
                                            java.lang.String t,
                                            int loc)

assignmentConvertable

protected boolean assignmentConvertable(Expr e,
                                        Type t)
Checks if Exp e can be assigned to Type t. This method is here instead of in Types, because it needs to mess with constants.


checkTypeDeclElemPragma

protected void checkTypeDeclElemPragma(TypeDeclElemPragma e)

checkModifierPragmaVec

protected Env checkModifierPragmaVec(ModifierPragmaVec v,
                                     ASTNode ctxt,
                                     Env env)
Hook to do additional processing on ModifierVecs. The ASTNode is the parent of the ModifierPragma, and env is the current environment.


checkModifierPragma

protected Env checkModifierPragma(ModifierPragma p,
                                  ASTNode ctxt,
                                  Env env)
Hook to do additional processing on Modifiers. The ASTNode is the parent of the ModifierPragma, and env is the current environment.

Returns:
true if pragma should be deleted

checkStmtPragma

protected Env checkStmtPragma(Env e,
                              StmtPragma s)

checkTypeModifierPragmaVec

protected Env checkTypeModifierPragmaVec(TypeModifierPragmaVec v,
                                         ASTNode ctxt,
                                         Env env)

checkTypeModifierPragma

protected Env checkTypeModifierPragma(TypeModifierPragma p,
                                      ASTNode ctxt,
                                      Env env)

checkTypeModifiers

protected Env checkTypeModifiers(Env env,
                                 Type t)
This may be called more than once on a Type t.


ESC/Java2
© 2003,2004,2005 David Cok and Joseph Kiniry
© 2005 UCD Dublin
© 2003,2004 Radboud University Nijmegen
© 1999,2000 Compaq Computer Corporation
© 1997,1998,1999 Digital Equipment Corporation
All Rights Reserved

The ESC/Java2 Project Homepage