anvil.script.statements
Class FunctionStatement

java.lang.Object
  |
  +--anvil.script.statements.Statement
        |
        +--anvil.script.statements.ScopedStatement
              |
              +--anvil.script.statements.DefinitionStatement
                    |
                    +--anvil.script.statements.FunctionStatement
All Implemented Interfaces:
CodecConstants, CompilableFunction, Function, Scope, Type
Direct Known Subclasses:
InterfaceMethodStatement, MethodStatement

public class FunctionStatement
extends DefinitionStatement
implements CompilableFunction, CodecConstants

class FunctionStatement


Field Summary
protected  BlockStatement _block
           
protected  FunctionStatement _context
           
protected  boolean _escaped
           
protected  ExceptionHandler _handler
           
protected  int _local_frame
           
protected  int _localcount
           
protected  ParameterListDeclaration _parameters
           
protected  VariableNode _return_var
           
protected  java.lang.String _signature
           
protected  Switch _switch
           
protected  boolean _synchronized
           
protected  int _yieldcount
           
 
Fields inherited from class anvil.script.statements.DefinitionStatement
_contentstate, _descriptor, _document, _externals, _imports, _name, _parent, _parents, _private, _taglibs, _types
 
Fields inherited from class anvil.script.statements.Statement
CONTENT_COMPRESS, CONTENT_PACK, CONTENT_PRESERVE, CONTENT_PROCESSING, CONTENT_SILENT, DEFAULT_NAMESPACE, EMPTY, ST_ASSERT, ST_BLOCK, ST_BREAK, ST_CALL, ST_CASE, ST_CATCH, ST_CDATA, ST_CLASS, ST_COMPRESS, ST_CONST, ST_CONTINUE, ST_CUSTOM_TAG, ST_DEFAULT, ST_DO, ST_DOCUMENT, ST_ELSE, ST_ELSEIF, ST_ENDCASE, ST_ENDCLASS, ST_ENDCONST, ST_ENDDEFAULT, ST_ENDEVAL, ST_ENDFOR, ST_ENDFOREACH, ST_ENDFUNCTION, ST_ENDIF, ST_ENDINNER, ST_ENDMODULE, ST_ENDNAMESPACE, ST_ENDOUTER, ST_ENDREPLACE, ST_ENDSWITCH, ST_ENDVAR, ST_ENDWHILE, ST_EVAL, ST_EXIT, ST_FINALLY, ST_FOR, ST_FOREACH, ST_FUNCTION, ST_IF, ST_IMPLICIT_BLOCK, ST_IMPORT, ST_INNER, ST_INTERFACE, ST_INVALID, ST_INVOKE, ST_MODULE, ST_NAMESPACE, ST_NONE, ST_OUTER, ST_PACK, ST_PRESERVE, ST_PRINT, ST_REPLACE, ST_RETURN, ST_SILENT, ST_SWITCH, ST_SYNCHRONIZED, ST_TAG, ST_THROW, ST_TRY, ST_VAR, ST_WHILE, ST_YIELD
 
Fields inherited from interface anvil.script.CompilableFunction
CLASSES, PARAMETER_ANY, PARAMETER_ANYLIST, PARAMETER_ARRAY, PARAMETER_BOOLEAN, PARAMETER_CONTEXT, PARAMETER_DOUBLE, PARAMETER_INT, PARAMETER_LIST, PARAMETER_LONG, PARAMETER_OBJECT, PARAMETER_REST, PARAMETER_STRING, SIGNATURES
 
Fields inherited from interface anvil.script.Type
CLASS, CONSTANT_VARIABLE, CONSTRUCTOR, FUNCTION, FUNCTION_PARAMETER, GLOBAL_NAMESPACE, IMPORT, INTERFACE, INTERFACE_METHOD, LOCAL_VARIABLE, MEMBER_VARIABLE, METHOD, MODULE, NAMESPACE, SCOPE0, STATIC_VARIABLE, SYSTEM_NAMESPACE, TYPE_NAMES
 
Fields inherited from interface anvil.codec.CodecConstants
ACC_ABSTRACT, ACC_FINAL, ACC_INTERFACE, ACC_NATIVE, ACC_PRIVATE, ACC_PROTECTED, ACC_PUBLIC, ACC_STATIC, ACC_STRICT, ACC_SUPER, ACC_SYNCHRONIZED, ACC_TRANSIENT, ACC_VOLATILE, ATTR_Code, ATTR_ConstantValue, ATTR_Deprecated, ATTR_Exceptions, ATTR_InnerClasses, ATTR_LineNumberTable, ATTR_LocalVariableTable, ATTR_SourceFile, ATTR_Synthetic, CLASS_MAGIC, CONSTANT_Class, CONSTANT_Double, CONSTANT_FieldRef, CONSTANT_Float, CONSTANT_Integer, CONSTANT_InterfaceMethodRef, CONSTANT_Long, CONSTANT_MethodRef, CONSTANT_NameAndType, CONSTANT_SourceFile, CONSTANT_String, CONSTANT_Utf8, MAJOR_VERSION, MINOR_VERSION, T_BOOLEAN, T_BYTE, T_CHAR, T_DOUBLE, T_FLOAT, T_INT, T_LONG, T_SHORT
 
Constructor Summary
FunctionStatement(DefinitionStatement parent, FunctionStatement context, java.lang.String name, Modifiers mods)
           
 
Method Summary
 int addYieldState()
           
 void bindYieldState(int state)
           
 boolean callFinalizer()
           
 void check(ErrorListener context)
           
 void compile(ByteCompiler context)
           
 void compileBody(ByteCompiler context, Method method, Field typefield)
           
 void compileDescriptor(ByteCompiler context)
           
 LocalVariableStatement declare(java.lang.String name)
           
 ParameterStatement declareParameter(java.lang.String name, Expression type)
           
 VariableStatement declareStatic(java.lang.String name)
           
 Any execute(Context context, Any self)
           
 Any execute(Context context, Any[] parameters)
           
 Any execute(Context context, Any self, Any param1)
           
 Any execute(Context context, Any self, Any[] parameters)
           
 Any execute(Context context, Any self, Any param1, Any param2)
           
 Any execute(Context context, Any self, Any param1, Any param2, Any param3)
           
 Any execute(Context context, Any self, Any param1, Any param2, Any param3, Any param4)
           
 Any getAttribute(java.lang.String name)
           
 Statement getChildStatement()
           
 FunctionStatement getContext()
           
 java.lang.String getDescriptor()
           
 FunctionDispatcher getDispatcher(Context context)
           
 Doc getDocument()
           
 int getFrameIndex()
           
 int getMinimumParameterCount()
           
 java.lang.String getName()
           
 int getNextLocalSlot()
           
 int getParameterCount()
           
 Any getParameterDefault(int index)
           
 Doc getParameterDoc(int index)
           
 java.lang.String getParameterName(int index)
           
 int getParameterType(int index)
           
 VariableNode getReturnVariable()
           
 java.lang.String getSignature()
           
 int getType()
           
 int getTypeRef(ConstantPool pool)
           
 boolean isEscaped()
           
 boolean isGenerator()
           
 boolean isInnerFunction()
           
 boolean isStaticRegion()
           
 Type lookupDeclaration(java.lang.String name)
           
 void markEscaped()
           
 java.lang.String name()
           
 boolean onTag(TemplateParser parser, int type, Tag tag)
           
 void parse(TemplateParser parser, Tag tag)
           
 ParameterListDeclaration parseParameters(TemplateParser parser, Tag tag)
           
 void setParameters(ParameterListDeclaration parameters)
           
 java.lang.String toString()
           
 int typeOf()
           
 
Methods inherited from class anvil.script.statements.DefinitionStatement
addEntityImport, addExternal, addExternal, addExternals, addHrefImport, addImport, addTaglib, compileMembers, declare, declare, declare, follow, getContentState, getDeclarations, getModifiers, getName, getNextInlined, getParent, getParentDefinition, getParents, getQualifiedName, getTag, importExternals, isEntityReserved, isPrivate, lookupLocalDeclaration, onClass, onConst, onFunction, onImport, onNamespace, onVar, setContentState, toString
 
Methods inherited from class anvil.script.statements.ScopedStatement
hasEnd, isBlocked, parseCondition
 
Methods inherited from class anvil.script.statements.Statement
addChild, allowBreak, allowContinue, allowLabel, allowYield, compress, eliminate, getBlockStatement, getCatchStatement, getClassStatement, getDefinitionStatement, getFunctionStatement, getInterfaceStatement, getLabelDepth, getLabeled, getLocation, getModuleStatement, getParentStatement, getScopeStatement, getStaticContent, getSwitch, getTagId, getTypeRef, hasStaticContent, isDeclared, lookupAnyDeclaration, onCharacters, onProcessingInstruction, pack, parseLabel, setChildStatement, setLocation, setParentStatement
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface anvil.script.Type
getParent, getParents, getQualifiedName, isPrivate
 

Field Detail

_context

protected FunctionStatement _context

_synchronized

protected boolean _synchronized

_parameters

protected ParameterListDeclaration _parameters

_block

protected BlockStatement _block

_handler

protected ExceptionHandler _handler

_switch

protected Switch _switch

_escaped

protected boolean _escaped

_localcount

protected int _localcount

_yieldcount

protected int _yieldcount

_signature

protected java.lang.String _signature

_local_frame

protected int _local_frame

_return_var

protected VariableNode _return_var
Constructor Detail

FunctionStatement

public FunctionStatement(DefinitionStatement parent,
                         FunctionStatement context,
                         java.lang.String name,
                         Modifiers mods)
Method Detail

setParameters

public void setParameters(ParameterListDeclaration parameters)

toString

public java.lang.String toString()
Overrides:
toString in class DefinitionStatement

typeOf

public int typeOf()
Overrides:
typeOf in class Statement

getNextLocalSlot

public int getNextLocalSlot()

lookupDeclaration

public Type lookupDeclaration(java.lang.String name)
Specified by:
lookupDeclaration in interface Scope
Overrides:
lookupDeclaration in class DefinitionStatement

declare

public LocalVariableStatement declare(java.lang.String name)

declareStatic

public VariableStatement declareStatic(java.lang.String name)

declareParameter

public ParameterStatement declareParameter(java.lang.String name,
                                           Expression type)

isStaticRegion

public boolean isStaticRegion()
Overrides:
isStaticRegion in class Statement

isInnerFunction

public boolean isInnerFunction()
Specified by:
isInnerFunction in interface CompilableFunction

parse

public void parse(TemplateParser parser,
                  Tag tag)
Overrides:
parse in class DefinitionStatement

onTag

public boolean onTag(TemplateParser parser,
                     int type,
                     Tag tag)
Overrides:
onTag in class DefinitionStatement

parseParameters

public ParameterListDeclaration parseParameters(TemplateParser parser,
                                                Tag tag)

check

public void check(ErrorListener context)
Overrides:
check in class DefinitionStatement

markEscaped

public void markEscaped()

isEscaped

public boolean isEscaped()

addYieldState

public int addYieldState()

isGenerator

public boolean isGenerator()

name

public java.lang.String name()
Overrides:
name in class Statement

getName

public java.lang.String getName()
Specified by:
getName in interface Type
Overrides:
getName in class DefinitionStatement

getDescriptor

public java.lang.String getDescriptor()
Overrides:
getDescriptor in class DefinitionStatement

getType

public int getType()
Specified by:
getType in interface Type

getContext

public FunctionStatement getContext()

getDocument

public Doc getDocument()
Specified by:
getDocument in interface Type
Overrides:
getDocument in class DefinitionStatement

getChildStatement

public Statement getChildStatement()
Overrides:
getChildStatement in class Statement

getMinimumParameterCount

public int getMinimumParameterCount()
Specified by:
getMinimumParameterCount in interface CompilableFunction

getParameterCount

public int getParameterCount()
Specified by:
getParameterCount in interface CompilableFunction

getParameterName

public java.lang.String getParameterName(int index)
Specified by:
getParameterName in interface CompilableFunction

getParameterType

public int getParameterType(int index)
Specified by:
getParameterType in interface CompilableFunction

getParameterDefault

public Any getParameterDefault(int index)
Specified by:
getParameterDefault in interface CompilableFunction

getParameterDoc

public Doc getParameterDoc(int index)
Specified by:
getParameterDoc in interface CompilableFunction

getAttribute

public Any getAttribute(java.lang.String name)
Specified by:
getAttribute in interface CompilableFunction

getDispatcher

public FunctionDispatcher getDispatcher(Context context)
Specified by:
getDispatcher in interface CompilableFunction

execute

public Any execute(Context context,
                   Any[] parameters)
Specified by:
execute in interface Function

execute

public Any execute(Context context,
                   Any self,
                   Any[] parameters)
Specified by:
execute in interface Function

execute

public Any execute(Context context,
                   Any self)
Specified by:
execute in interface Function

execute

public Any execute(Context context,
                   Any self,
                   Any param1)
Specified by:
execute in interface Function

execute

public Any execute(Context context,
                   Any self,
                   Any param1,
                   Any param2)
Specified by:
execute in interface Function

execute

public Any execute(Context context,
                   Any self,
                   Any param1,
                   Any param2,
                   Any param3)
Specified by:
execute in interface Function

execute

public Any execute(Context context,
                   Any self,
                   Any param1,
                   Any param2,
                   Any param3,
                   Any param4)
Specified by:
execute in interface Function

getFrameIndex

public int getFrameIndex()

getSignature

public java.lang.String getSignature()

compileDescriptor

public void compileDescriptor(ByteCompiler context)

compile

public void compile(ByteCompiler context)
Overrides:
compile in class DefinitionStatement

compileBody

public void compileBody(ByteCompiler context,
                        Method method,
                        Field typefield)

getTypeRef

public int getTypeRef(ConstantPool pool)
Specified by:
getTypeRef in interface Type
Overrides:
getTypeRef in class DefinitionStatement

bindYieldState

public void bindYieldState(int state)

callFinalizer

public boolean callFinalizer()
Overrides:
callFinalizer in class Statement

getReturnVariable

public VariableNode getReturnVariable()