Class Symbol
java.lang.Object
com.oracle.js.parser.ir.Symbol
- All Implemented Interfaces:
Comparable<Symbol>
Symbol is a symbolic address for a value ("variable" if you wish). Identifiers in JavaScript
source, as well as certain synthetic variables created by the compiler are represented by Symbol
objects. Symbols can address either local variable slots in bytecode ("slotted symbol"), or
properties in scope objects ("scoped symbol"). A symbol can also end up being defined but then
not used during symbol assignment calculations; such symbol will be neither scoped, nor slotted;
it represents a dead variable (it might be written to, but is never read). Finally, a symbol can
be both slotted and in scope. This special case can only occur with bytecode method parameters.
They all come in as slotted, but if they are used by a nested function (or eval) then they will
be copied into the scope object, and used from there onwards. Two further special cases are
parameters stored in
NativeArguments objects and parameters stored in Object[]
parameter to variable-arity functions. Those use the #getFieldIndex() property to refer
to their location.-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intIs this symbol already declared? Used for block scoped LET and CONST symbols only.static final intIs this symbol the function 'arguments' binding?static final intIs this symbol a block function declaration?static final intIs this symbol a catch parameter binding?static final intIs this symbol closed over by an inner function closure?static final intIs this a const bindingstatic final intIs this symbol declared in an unprotected switch case context?static final intIs this a function self-reference symbolstatic final intIs this a global bindingstatic final intIs this a hoistable var declaration?static final intIs this symbol a block function declaration hoisted into the body scope.static final intIs this symbol an indirect import binding of a module environment?static final intIs this an internal symbol, never represented explicitly in source codestatic final intIs this a let bindingstatic final intIs this thenew.target.static final intIs this a parameterstatic final intIs this symbol a private name?static final intIs this symbol a private name associated with an accessor?static final intIs this symbol a private name associated with a method?static final intIs this symbol a private name associated with a static member?static final intIs this a program level symbol?static final intIs this the home object, used by super property accesses.static final intIs this a this symbolstatic final intIs this symbol used?static final intIs this symbol used by an inner scope within the same function?static final intIs this a var bindingstatic final intIs this symbol a var declaration binding that needs to be initialized with the value of the parent's scope's binding with the same name? Used for parameter bindings that are replicated in the body's VariableEnvironment.static final intMask for kind flags -
Constructor Summary
ConstructorsConstructorDescriptionSymbol(com.oracle.truffle.api.strings.TruffleString name, int flags) Constructor -
Method Summary
Modifier and TypeMethodDescriptionintintgetFlags()Get the symbol flagsgetName()Get the name of this symbolcom.oracle.truffle.api.strings.TruffleStringbooleanReturns true if this symbol can be assumed to have already been declared and initialized in the declaring scope, i.e., it does not have or need a temporal dead zone.booleanIs this symbol the function 'arguments' binding.booleanIs this symbol a block function declaration.booleanIs this a block scoped symbolbooleanbooleanIs this symbol captured by a closure.booleanisConst()Check if this symbol is a constantbooleanHas this symbol been declaredbooleanFlag this symbol as a function's self-referencing symbol.booleanisGlobal()Check if this symbol is a global (undeclared) variablebooleanCheck if this symbol is a hoistable var declaration.booleanIs this symbol a hoisted block function declaration.booleanbooleanCheck if this is an internal symbol, without an explicit JavaScript source code equivalentbooleanisLet()Check if this symbol is a letbooleanCheck if this symbol representsnew.targetbooleanisParam()Check if this symbol is a function parameterbooleanIs this symbol a private name associated with an accessor.booleanIs this symbol a private name associated with a field.booleanIs this symbol a private name associated with a method.booleanIs this symbol a private name.booleanIs this symbol a private name associated with a static member.booleanCheck if this is a program (script) level definitionbooleanisSuper()Check if this symbol representssuperbooleanisThis()Check if this symbol representsthisbooleanisUsed()Is this symbol used.booleanIs this symbol captured by an inner scope.booleanisVar()Check if this symbol is a variablebooleanvoidMark this symbol as captured by a closure.voidMark this symbol as a hoisted block function declaration.voidsetUsed()Mark this symbol as used.voidMark this symbol as captured by an inner scope.toString()
-
Field Details
-
IS_LET
public static final int IS_LETIs this a let binding- See Also:
-
IS_CONST
public static final int IS_CONSTIs this a const binding- See Also:
-
IS_VAR
public static final int IS_VARIs this a var binding- See Also:
-
KINDMASK
public static final int KINDMASKMask for kind flags- See Also:
-
IS_GLOBAL
public static final int IS_GLOBALIs this a global binding- See Also:
-
IS_PARAM
public static final int IS_PARAMIs this a parameter- See Also:
-
IS_THIS
public static final int IS_THISIs this a this symbol- See Also:
-
IS_INTERNAL
public static final int IS_INTERNALIs this an internal symbol, never represented explicitly in source code- See Also:
-
IS_FUNCTION_SELF
public static final int IS_FUNCTION_SELFIs this a function self-reference symbol- See Also:
-
IS_HOISTABLE_DECLARATION
public static final int IS_HOISTABLE_DECLARATIONIs this a hoistable var declaration?- See Also:
-
IS_PROGRAM_LEVEL
public static final int IS_PROGRAM_LEVELIs this a program level symbol?- See Also:
-
HAS_BEEN_DECLARED
public static final int HAS_BEEN_DECLAREDIs this symbol already declared? Used for block scoped LET and CONST symbols only.- See Also:
-
IS_HOISTED_BLOCK_FUNCTION
public static final int IS_HOISTED_BLOCK_FUNCTIONIs this symbol a block function declaration hoisted into the body scope.- See Also:
-
IS_VAR_REDECLARED_HERE
public static final int IS_VAR_REDECLARED_HEREIs this symbol a var declaration binding that needs to be initialized with the value of the parent's scope's binding with the same name? Used for parameter bindings that are replicated in the body's VariableEnvironment.- See Also:
-
IS_DECLARED_IN_SWITCH_BLOCK
public static final int IS_DECLARED_IN_SWITCH_BLOCKIs this symbol declared in an unprotected switch case context?- See Also:
-
IS_IMPORT_BINDING
public static final int IS_IMPORT_BINDINGIs this symbol an indirect import binding of a module environment?- See Also:
-
IS_CATCH_PARAMETER
public static final int IS_CATCH_PARAMETERIs this symbol a catch parameter binding?- See Also:
-
IS_BLOCK_FUNCTION_DECLARATION
public static final int IS_BLOCK_FUNCTION_DECLARATIONIs this symbol a block function declaration?- See Also:
-
IS_PRIVATE_NAME
public static final int IS_PRIVATE_NAMEIs this symbol a private name?- See Also:
-
IS_PRIVATE_NAME_STATIC
public static final int IS_PRIVATE_NAME_STATICIs this symbol a private name associated with a static member?- See Also:
-
IS_PRIVATE_NAME_METHOD
public static final int IS_PRIVATE_NAME_METHODIs this symbol a private name associated with a method?- See Also:
-
IS_PRIVATE_NAME_ACCESSOR
public static final int IS_PRIVATE_NAME_ACCESSORIs this symbol a private name associated with an accessor?- See Also:
-
IS_ARGUMENTS
public static final int IS_ARGUMENTSIs this symbol the function 'arguments' binding?- See Also:
-
IS_USED
public static final int IS_USEDIs this symbol used?- See Also:
-
IS_CLOSED_OVER
public static final int IS_CLOSED_OVERIs this symbol closed over by an inner function closure?- See Also:
-
IS_USED_IN_INNER_SCOPE
public static final int IS_USED_IN_INNER_SCOPEIs this symbol used by an inner scope within the same function?- See Also:
-
IS_SUPER
public static final int IS_SUPERIs this the home object, used by super property accesses.- See Also:
-
IS_NEW_TARGET
public static final int IS_NEW_TARGETIs this thenew.target.- See Also:
-
-
Constructor Details
-
Symbol
public Symbol(com.oracle.truffle.api.strings.TruffleString name, int flags) Constructor- Parameters:
name- name of symbolflags- symbol flags
-
-
Method Details
-
toString
-
compareTo
- Specified by:
compareToin interfaceComparable<Symbol>
-
isHoistableDeclaration
public boolean isHoistableDeclaration()Check if this symbol is a hoistable var declaration.- Returns:
- true if a hoistable var declaration
- See Also:
-
isVar
public boolean isVar()Check if this symbol is a variable- Returns:
- true if variable
-
isGlobal
public boolean isGlobal()Check if this symbol is a global (undeclared) variable- Returns:
- true if global
-
isParam
public boolean isParam()Check if this symbol is a function parameter- Returns:
- true if parameter
-
isProgramLevel
public boolean isProgramLevel()Check if this is a program (script) level definition- Returns:
- true if program level
-
isConst
public boolean isConst()Check if this symbol is a constant- Returns:
- true if a constant
-
isInternal
public boolean isInternal()Check if this is an internal symbol, without an explicit JavaScript source code equivalent- Returns:
- true if internal
-
isThis
public boolean isThis()Check if this symbol representsthis- Returns:
- true if this
-
isSuper
public boolean isSuper()Check if this symbol representssuper- Returns:
- true if super
-
isNewTarget
public boolean isNewTarget()Check if this symbol representsnew.target- Returns:
- true if
new.target
-
isLet
public boolean isLet()Check if this symbol is a let- Returns:
- true if let
-
isFunctionSelf
public boolean isFunctionSelf()Flag this symbol as a function's self-referencing symbol.- Returns:
- true if this symbol as a function's self-referencing symbol.
-
isBlockScoped
public boolean isBlockScoped()Is this a block scoped symbol- Returns:
- true if block scoped
-
hasBeenDeclared
public boolean hasBeenDeclared()Returns true if this symbol can be assumed to have already been declared and initialized in the declaring scope, i.e., it does not have or need a temporal dead zone. Only relevant for lexical (let, const) declarations.- Returns:
- true if declared
-
getFlags
public int getFlags()Get the symbol flags- Returns:
- flags
-
getName
-
getNameTS
public com.oracle.truffle.api.strings.TruffleString getNameTS() -
isDeclaredInSwitchBlock
public boolean isDeclaredInSwitchBlock()Has this symbol been declared- Returns:
- true if declared
-
isImportBinding
public boolean isImportBinding()- Returns:
- true if this symbol is an indirect import binding
- See Also:
-
isCatchParameter
public boolean isCatchParameter()- Returns:
- true if this symbol is a catch parameter binding
- See Also:
-
isVarRedeclaredHere
public boolean isVarRedeclaredHere() -
isHoistedBlockFunctionDeclaration
public boolean isHoistedBlockFunctionDeclaration()Is this symbol a hoisted block function declaration. -
setHoistedBlockFunctionDeclaration
public void setHoistedBlockFunctionDeclaration()Mark this symbol as a hoisted block function declaration. -
isBlockFunctionDeclaration
public boolean isBlockFunctionDeclaration()Is this symbol a block function declaration. -
isPrivateName
public boolean isPrivateName()Is this symbol a private name. -
isPrivateNameStatic
public boolean isPrivateNameStatic()Is this symbol a private name associated with a static member. -
isPrivateField
public boolean isPrivateField()Is this symbol a private name associated with a field. -
isPrivateMethod
public boolean isPrivateMethod()Is this symbol a private name associated with a method. -
isPrivateAccessor
public boolean isPrivateAccessor()Is this symbol a private name associated with an accessor. -
isArguments
public boolean isArguments()Is this symbol the function 'arguments' binding. -
isUsed
public boolean isUsed()Is this symbol used. -
setUsed
public void setUsed()Mark this symbol as used. -
isClosedOver
public boolean isClosedOver()Is this symbol captured by a closure. -
setClosedOver
public void setClosedOver()Mark this symbol as captured by a closure. -
isUsedInInnerScope
public boolean isUsedInInnerScope()Is this symbol captured by an inner scope. -
setUsedInInnerScope
public void setUsedInInnerScope()Mark this symbol as captured by an inner scope.
-