public class MethodBodySemanticChecker extends Object
Constructor and Description |
---|
MethodBodySemanticChecker(LexicalScope current_scope)
Construct a new MethodBodySemanticChecker from the current lexical scope.
|
Modifier and Type | Method and Description |
---|---|
void |
addTypeProblem(IASNode typeNode,
IDefinition typeDef,
String typeDesc,
boolean reportAmbiguousReference)
Add the appropriate Problem when a type annotation did not resolve to a Type
|
boolean |
canFunctionBeInlined(FunctionDefinition function)
Test whether the specified function can be inlined.
|
boolean |
canGetterBeInlined(AccessorDefinition accessor)
Test whether the getter for the specified accessor can be inlined
|
boolean |
canSetterBeInlined(AccessorDefinition accessor)
Test whether the setter for the specified accessor can be inlined
|
void |
checkAssignment(IASNode iNode,
Binding binding)
Perform semantic checks on an assignment.
|
void |
checkAssignmentValue(IDefinition leftDefinition,
IASNode rightNode)
Checks that the value (RHS) is appropriate, given the type of the LHS
|
void |
checkAssignToBracketExpr(IASNode iNode)
Perform semantic checks on an x[i] = rvalue assignment expression.
|
void |
checkBinaryOperator(IASNode root,
IASNode left,
IASNode right,
int opcode)
Check a (possibly implicit) binary operator.
|
void |
checkBinaryOperator(IASNode iNode,
int opcode)
Check a binary operator.
|
void |
checkBindableVariableDeclaration(IASNode iNode,
IDefinition d)
Check if we are allowed to declare a bindable variable at this location.
|
void |
checkClassField(VariableNode var)
Check a class field declaration.
|
void |
checkCompoundAssignment(IASNode iNode,
Binding lvalue,
int opcode)
Check a compound assignment.
|
void |
checkConstantValue(IASNode iNode)
Check a constant value used in a non-initializer context.
|
void |
checkControlFlow(IASNode iNode,
MethodInfo mi,
MethodBodyInfo mbi)
Perform semantic checks that require flow-aware analysis.
|
void |
checkDefaultSuperCall(IASNode iNode)
Check that a synthetic super() call is allowed by the class' superclass.
|
void |
checkDeleteExpr(IASNode iNode,
Binding binding)
Perform semantic checks on a delete expression.
|
void |
checkExplicitSuperCall(IASNode iNode,
Vector<? extends Object> args)
Check a super() or super(a,b,c) call.
|
void |
checkForDuplicateModifiers(BaseDefinitionNode bdn)
Ensure that a definition does not have the same modifier more than once
|
void |
checkFunctionBody(IASNode iNode)
Check a function body's overall characteristics.
|
void |
checkFunctionCall(IASNode iNode,
Binding method_binding,
Vector<? extends Object> actuals)
Check a function call.
|
void |
checkFunctionDecl(IFunctionNode funcNode)
Do a semantic analysis of all the arguments of a function
|
void |
checkFunctionDefinition(IFunctionNode iNode,
FunctionDefinition def)
Check a function definition.
|
boolean |
checkFunctionForConflictingDefinitions(IASNode iNode,
FunctionDefinition funcDef)
Check for other definitions that might conflict with the function passed in.
|
void |
checkGetProperty(Binding binding)
Check a getproperty operation.
|
void |
checkImplicitConversion(IASNode iNode,
IDefinition expected_type,
FunctionDefinition func)
Check an implicit conversion.
|
void |
checkImportDirective(IImportNode importNode)
Check an import directive.
|
void |
checkIncDec(IASNode iNode,
boolean is_incr)
Check foo++ and foo-- expressions.
|
void |
checkIncDec(IASNode iNode,
boolean is_incr,
Binding binding)
Check foo++ and foo-- expressions.
|
void |
checkInitialization(IASNode iNode,
Binding binding)
Perform semantic checks on an initialization
|
PooledValue |
checkInitialValue(IVariableNode iNode,
Binding type,
PooledValue initial_value)
Check the initial value of an
IVariableNode . |
void |
checkInterfaceFunctionForConflictingDefinitions(IASNode iNode,
FunctionDefinition funcDef)
Check for other definitions that might conflict with the function passed in.
|
void |
checkLValue(IASNode iNode,
Binding binding)
Perform semantic checks on an lvalue,
i.e., the target of an assignment
or other storage-mutating operation.
|
void |
checkMemberAccess(IASNode iNode,
Binding member,
int opcode)
Check a member access expression.
|
void |
checkNamespaceDeclaration(IASNode iNode,
Binding ns_name)
Check a namespace declaration.
|
void |
checkNamespaceOfDefinition(IASNode iNode,
IDefinition def,
ICompilerProject project)
Check that the namespace of the definition is valid
|
void |
checkNativeMethod(IASNode iNode) |
void |
checkNestedFunctionDecl(IFunctionNode funcNode)
Semantic analysis of a function declared inside another function.
|
void |
checkNewExpr(IASNode call_node)
Check a "new expression".
|
void |
checkNewExpr(IASNode iNode,
Binding class_binding,
Vector<? extends Object> args)
Check a new expression.
|
void |
checkQualifier(IASNode iNode)
Check the qualifier of a qualified name ('a' in 'a::foo')
|
void |
checkReference(Binding b)
Check for possible problems with a reference for an r-value.
|
void |
checkReference(Binding b,
boolean forLValue)
Check for possible problems with a reference.
|
void |
checkRestParameter(IASNode iNode,
Binding param_type)
Check a rest parameter declaration (...rest)
|
void |
checkReturnValue(IASNode iNode)
Check a return expression that returns a value.
|
void |
checkReturnVoid(IASNode iNode)
Check a return expression that returns void.
|
void |
checkSimpleName(IASNode iNode,
Binding binding)
Check a simple name reference.
|
void |
checkSuperAccess(IASNode iNode)
Ensure a super-qualified access is in an instance method.
|
void |
checkThrow(IASNode iNode)
Check a throw statement.
|
void |
checkTypeCheckImplicitConversion(IASNode iNode)
Check an implicit conversion in an 'is' or 'as' binop
|
void |
checkTypeName(Binding typename)
Verify that a named type exists.
|
void |
checkUnaryOperator(IASNode iNode,
int opcode)
Check a unary operator.
|
void |
checkUseNamespaceDirective(IASNode iNode,
Binding ns_name)
Check a use namespace directive.
|
void |
checkVariableDeclaration(IASNode iNode)
Check a variable declaration.
|
void |
checkVariableForConflictingDefinitions(IASNode iNode,
VariableDefinition varDef)
Check for other definitions that might conflict with the variable passed in.
|
void |
checkVectorLiteral(IASNode iNode,
Binding type_param)
Check a Vector literal.
|
void |
enterConstructor()
Signal the semantic checker that its caller is entering a constructor:
initialize constructor-specific state variables.
|
boolean |
functionBodyHasNonInlineableInstructions(InstructionList insns,
boolean reportInlineProblems,
String functionName)
Iterate through the Instructions which are to be inlined and
ensure the can all be inlined.
|
boolean |
functionBodyHasNonInlineableNodes(IASNode n,
boolean reportInlineProblems,
String functionName,
AtomicInteger exprCount)
Check for any constructs we know we can't inline, or if the function is too large
|
ICompilerProblem |
isMissingMember(IASNode iNode) |
void |
leaveConstructor()
Signal the semantic checker that its caller is leaving a constructor:
reset constructor-specific state variables.
|
public MethodBodySemanticChecker(LexicalScope current_scope)
public void checkFunctionDecl(IFunctionNode funcNode)
funcNode
- is the function to be analyzedpublic void checkNestedFunctionDecl(IFunctionNode funcNode)
funcNode
- The node of the nested functionpublic void checkAssignment(IASNode iNode, Binding binding)
public void checkAssignmentValue(IDefinition leftDefinition, IASNode rightNode)
leftDefinition
- is the definition of the variable on the LHSrightNode
- is the tree node for the RHS of the assignmentpublic void checkInitialization(IASNode iNode, Binding binding)
public void checkAssignToBracketExpr(IASNode iNode)
public void checkBinaryOperator(IASNode iNode, int opcode)
iNode
- - the operator node.opcode
- - the opcode.public void checkBinaryOperator(IASNode root, IASNode left, IASNode right, int opcode)
root
- - the operator node.left
- - the left-hand operand.right
- - the right-hand operand.opcode
- - the opcode.public void checkImplicitConversion(IASNode iNode, IDefinition expected_type, FunctionDefinition func)
iNode
- - the expression being checked.expected_type
- - the type to convert to.public void checkTypeCheckImplicitConversion(IASNode iNode)
iNode
- - the expression being checked.public void checkCompoundAssignment(IASNode iNode, Binding lvalue, int opcode)
iNode
- - the node at the root of the assignment subtree.lvalue
- - the resolved lvalue (which is also an implicit rvalue).opcode
- - the opcode of the implied binary operator.public void checkBindableVariableDeclaration(IASNode iNode, IDefinition d)
public void checkConstantValue(IASNode iNode)
public void checkDefaultSuperCall(IASNode iNode)
public void checkDeleteExpr(IASNode iNode, Binding binding)
public void checkExplicitSuperCall(IASNode iNode, Vector<? extends Object> args)
public void checkFunctionBody(IASNode iNode)
public void checkNativeMethod(IASNode iNode)
public void checkFunctionCall(IASNode iNode, Binding method_binding, Vector<? extends Object> actuals)
public void checkFunctionDefinition(IFunctionNode iNode, FunctionDefinition def)
iNode
- - the top-level definition node.def
- - the function's definition.public void checkSimpleName(IASNode iNode, Binding binding)
public void checkGetProperty(Binding binding)
binding
- - the Binding which is being fetched.public void checkReference(Binding b)
b
- the binding to checkpublic void checkReference(Binding b, boolean forLValue)
b
- the binding to checkforLValue
- Whether the binding is for an l-value.public PooledValue checkInitialValue(IVariableNode iNode, Binding type, PooledValue initial_value)
IVariableNode
. The specified
IVariableNode
could be:
IParameterNode
for a function parameter.IVariableNode
for a var or const in any scope.ICompilerProblem
s if the specified
initial value is not the correct type and will return an initializer
value that is the correct type that was created by apply the AS3 coercion
rules.iNode
- The IVariableNode
whose initializer value should be
checked.type
- A Binding
for the specified IVariableNode
's
type annotation.initial_value
- A PooledValue
that contains the constant
initializer value computed by the constant propagation code.PooledValue
with the correct type to initialize the
specified IVariableNode
. This can be the same as the specified
PooledValue
if it was already of the correct type.public ICompilerProblem isMissingMember(IASNode iNode)
public void checkSuperAccess(IASNode iNode)
public void checkIncDec(IASNode iNode, boolean is_incr)
public void checkIncDec(IASNode iNode, boolean is_incr, Binding binding)
iNode
- the inc/dec Nodeis_incr
- whether this is an increment or decrement operationbinding
- the binding for the name we are incrementing/decrementingpublic void checkLValue(IASNode iNode, Binding binding)
public void checkMemberAccess(IASNode iNode, Binding member, int opcode)
public void checkNewExpr(IASNode call_node)
call_node
- FunctionCallNode
that has the "new" call.public void checkNewExpr(IASNode iNode, Binding class_binding, Vector<? extends Object> args)
public void checkReturnValue(IASNode iNode)
iNode
- - the return statement.
Known to have a child 0 expression.public void checkReturnVoid(IASNode iNode)
iNode
- - the return statement.public void checkControlFlow(IASNode iNode, MethodInfo mi, MethodBodyInfo mbi)
iNode
- - an AST within a function.mi
- - the function's MethodInfo.mbi
- - the function's MethodBodyInfo.public void checkThrow(IASNode iNode)
public void checkImportDirective(IImportNode importNode)
importNode
- - the import node.public void checkUseNamespaceDirective(IASNode iNode, Binding ns_name)
iNode
- - the use namespace node.ns_name
- - the namespace's Binding.public void checkUnaryOperator(IASNode iNode, int opcode)
iNode
- - the operator's i-node.opcode
- - the corresponding opcode.public void checkForDuplicateModifiers(BaseDefinitionNode bdn)
public void checkVariableDeclaration(IASNode iNode)
public void checkTypeName(Binding typename)
typename
- - the name of the type.public void checkClassField(VariableNode var)
public void addTypeProblem(IASNode typeNode, IDefinition typeDef, String typeDesc, boolean reportAmbiguousReference)
typeNode
- the Node to use for location info for the problemtypeDef
- The IDefinition the type annotation resolved totypeDesc
- A String to use as the description of the type annotation in the diagnosticreportAmbiguousReference
- A flag indicating whether an AmbiguousReferenceProblem
should be reported, if the typeDef
is ambiguous.public void checkQualifier(IASNode iNode)
iNode
- the node representing the qualifierpublic void checkNamespaceDeclaration(IASNode iNode, Binding ns_name)
public void checkNamespaceOfDefinition(IASNode iNode, IDefinition def, ICompilerProject project)
public void checkVectorLiteral(IASNode iNode, Binding type_param)
public void checkRestParameter(IASNode iNode, Binding param_type)
iNode
- - the ParameterNode for the rest decl.param_type
- - the type of the rest parampublic boolean checkFunctionForConflictingDefinitions(IASNode iNode, FunctionDefinition funcDef)
iNode
- The Node that produced the function definition. Used for location info for any diagnostics.funcDef
- The FunctionDefinition of the function to checkpublic void checkInterfaceFunctionForConflictingDefinitions(IASNode iNode, FunctionDefinition funcDef)
iNode
- The node that produced the function definition. Used for location info for any diagnostics.funcDef
- The FunctionDefinition of the interface function to checkpublic void checkVariableForConflictingDefinitions(IASNode iNode, VariableDefinition varDef)
iNode
- The node that produced the variable definition. Used for location info for any diagnostics.varDef
- The VariableDefinition of the variable to checkpublic void enterConstructor()
public void leaveConstructor()
public boolean canGetterBeInlined(AccessorDefinition accessor)
accessor
- The accessor to test whether the getter can be inlinedpublic boolean canSetterBeInlined(AccessorDefinition accessor)
accessor
- The accessor to test whether the setter can be inlinedpublic boolean canFunctionBeInlined(FunctionDefinition function)
function
- The function to test whether it can be inlinedpublic boolean functionBodyHasNonInlineableNodes(IASNode n, boolean reportInlineProblems, String functionName, AtomicInteger exprCount)
n
- the node to testreportInlineProblems
- whether or not to report inline problemsfunctionName
- the name of the function being inlinedexprCount
- a running count of the expressions in the bodypublic boolean functionBodyHasNonInlineableInstructions(InstructionList insns, boolean reportInlineProblems, String functionName)
insns
- inlined instructionsreportInlineProblems
- whether or not to report inline problemsfunctionName
- the name of the function being inlinedCopyright © 2016 The Apache Software Foundation. All rights reserved.