Package gw.internal.gosu.parser
Class Symbol
- java.lang.Object
-
- gw.internal.gosu.parser.Symbol
-
- All Implemented Interfaces:
IFunctionSymbol,IHasType,IReducedSymbol,ISymbol
- Direct Known Subclasses:
AbstractDynamicSymbol,AmbiguousSymbol,CapturedSymbol,CommonSymbolsScope.LockedDownSymbol,CompileTimeExpressionParser.CompileTimeFieldSymbol,QueryPathRootSymbol,ReadOnlySymbol,ReducedSymbol.SyntheticSymbol,TemplateGenerator.LockedDownSymbol,ThisSymbol,TypedSymbol
public class Symbol extends java.lang.Object implements IFunctionSymbol
Base class for all symbols in the symbol table.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static classSymbol.MemberStackProvider
-
Field Summary
Fields Modifier and Type Field Description protected boolean_bGlobalprivate IExpression_defaultValueprotected int_iIndexprivate ModifierInfo_modifiersprivate java.lang.String_nameprotected IStackProvider_stackProviderprotected ISymbolTable_symbolTableprivate IType_typeprotected java.lang.Object_valueprivate MutableBoolean_valueIsBoxedstatic IStackProviderMEMBER_STACK_PROVIDER
-
Constructor Summary
Constructors Constructor Description Symbol(Symbol copy)Symbol(java.lang.String strName, IType type, IStackProvider stackProvider)Symbol(java.lang.String strName, IType type, IStackProvider stackProvider, java.lang.Object value)Symbol(java.lang.String strName, IType type, IStackProvider stackProvider, java.lang.Object value, IScope scope)Symbol(java.lang.String strName, IType type, java.lang.Object value)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected intassignIndex(IScope scope)protected intassignIndexInStack(IScope scope)booleancanBeCaptured()IReducedSymbolcreateReducedSymbol()booleanequals(java.lang.Object o)java.util.List<IGosuAnnotation>getAnnotations()IExpressiongetDefaultValueExpression()The symbol's default value e.g., a default parameter value for a function.java.lang.StringgetDisplayName()Returns the Symbol's optional display name.ISymbolTablegetDynamicSymbolTable()java.lang.StringgetFullDescription()IGosuClassgetGosuClass()intgetIndex()ISymbolgetLightWeightReference()Creates a copy of this symbol without the value so that the empty symbol can be stored.ModifierInfogetModifierInfo()intgetModifiers()Returns the modifiers for this function symboljava.lang.StringgetName()Returns the Symbol's name.IScriptPartIdgetScriptPart()java.lang.StringgetSignatureDescription()Returns a description of arguments of the form ( < argName1 >, < argName2 >, etc.java.lang.ClassgetSymbolClass()ITypegetType()Returns the Symbol's type.java.lang.ObjectgetValue()Returns the value assigned to this Symbol.java.lang.ObjectgetValueDirectly()private java.lang.ObjectgetValueFromSymbolTable()booleanhasDynamicSymbolTable()booleanhasTypeVariables()java.lang.Objectinvoke(java.lang.Object[] args)Invokes function.booleanisAbstract()booleanisClassMember()booleanisFinal()booleanisFromJava()booleanisHide()booleanisImplicitlyInitialized()booleanisInternal()booleanisLocal()booleanisOverride()booleanisPrivate()booleanisProtected()booleanisPublic()booleanisReified()booleanisStackSymbol()Returns true if the value of this function symbol is stored on the stack as a variablebooleanisStatic()booleanisValueBoxed()booleanisWritable()Returns true if this symbol is writable.ICapturedSymbolmakeCapturedSymbol(java.lang.String strName, ISymbolTable symbolTable, IScope scope)voidrenameAsErrantDuplicate(int iIndex)voidreplaceModifierInfo(IModifierInfo mi)voidsetAbstract(boolean bAbstract)voidsetClassMember(boolean bClassMember)voidsetDefaultValueExpression(IExpression defaultValue)voidsetDynamicSymbolTable(ISymbolTable symTable)Assigns an optional symbol table so that the symbol can get/set its value dynamically e.g., via ThreadLocalSymbolTable.voidsetFinal(boolean bFinal)voidsetHide(boolean bHide)voidsetIndex(int i)voidsetInternal(boolean bInternal)voidsetModifierInfo(IModifierInfo modifiers)voidsetModifiers(int modifiers)protected voidsetName(java.lang.String name)voidsetOverride(boolean bOverride)voidsetPrivate(boolean bPrivate)voidsetProtected(boolean bProtected)voidsetPublic(boolean bPublic)voidsetReified(boolean bReified)voidsetStatic(boolean bStatic)voidsetType(IType type)Sets the Symbol's type.voidsetValue(java.lang.Object value)Assigns a value to this Symbol.voidsetValueDirectly(java.lang.Object value)private voidsetValueFromSymbolTable(java.lang.Object value)voidsetValueIsBoxed(boolean b)Indicates that this symbol should use a reference rather than storing its value directly.java.lang.StringtoString()
-
-
-
Field Detail
-
MEMBER_STACK_PROVIDER
public static final IStackProvider MEMBER_STACK_PROVIDER
-
_name
private java.lang.String _name
-
_type
private IType _type
-
_value
protected java.lang.Object _value
-
_defaultValue
private IExpression _defaultValue
-
_iIndex
protected int _iIndex
-
_bGlobal
protected boolean _bGlobal
-
_stackProvider
protected IStackProvider _stackProvider
-
_symbolTable
protected ISymbolTable _symbolTable
-
_valueIsBoxed
private MutableBoolean _valueIsBoxed
-
_modifiers
private ModifierInfo _modifiers
-
-
Constructor Detail
-
Symbol
public Symbol(java.lang.String strName, IType type, IStackProvider stackProvider)
-
Symbol
public Symbol(java.lang.String strName, IType type, IStackProvider stackProvider, java.lang.Object value)
-
Symbol
public Symbol(java.lang.String strName, IType type, IStackProvider stackProvider, java.lang.Object value, IScope scope)
-
Symbol
public Symbol(Symbol copy)
-
Symbol
public Symbol(java.lang.String strName, IType type, java.lang.Object value)
-
-
Method Detail
-
setDynamicSymbolTable
public void setDynamicSymbolTable(ISymbolTable symTable)
Description copied from interface:ISymbolAssigns an optional symbol table so that the symbol can get/set its value dynamically e.g., via ThreadLocalSymbolTable.- Specified by:
setDynamicSymbolTablein interfaceISymbol
-
hasDynamicSymbolTable
public boolean hasDynamicSymbolTable()
- Specified by:
hasDynamicSymbolTablein interfaceISymbol
-
getDynamicSymbolTable
public ISymbolTable getDynamicSymbolTable()
- Specified by:
getDynamicSymbolTablein interfaceISymbol
-
assignIndex
protected int assignIndex(IScope scope)
-
assignIndexInStack
protected int assignIndexInStack(IScope scope)
-
getName
public java.lang.String getName()
Returns the Symbol's name.- Specified by:
getNamein interfaceIReducedSymbol- Specified by:
getNamein interfaceISymbol
-
getDisplayName
public java.lang.String getDisplayName()
Returns the Symbol's optional display name. If a display name is not assigned, returns the symbol's name.- Specified by:
getDisplayNamein interfaceIReducedSymbol- Specified by:
getDisplayNamein interfaceISymbol
-
getFullDescription
public java.lang.String getFullDescription()
- Specified by:
getFullDescriptionin interfaceIReducedSymbol
-
renameAsErrantDuplicate
public void renameAsErrantDuplicate(int iIndex)
-
getType
public IType getType()
Returns the Symbol's type.
-
setType
public void setType(IType type)
Sets the Symbol's type.
-
getValue
public java.lang.Object getValue()
Returns the value assigned to this Symbol.
-
getValueFromSymbolTable
private java.lang.Object getValueFromSymbolTable()
-
setValue
public void setValue(java.lang.Object value)
Assigns a value to this Symbol.
-
getDefaultValueExpression
public IExpression getDefaultValueExpression()
Description copied from interface:ISymbolThe symbol's default value e.g., a default parameter value for a function.- Specified by:
getDefaultValueExpressionin interfaceIReducedSymbol- Specified by:
getDefaultValueExpressionin interfaceISymbol
-
setDefaultValueExpression
public void setDefaultValueExpression(IExpression defaultValue)
- Specified by:
setDefaultValueExpressionin interfaceISymbol
-
isStackSymbol
public boolean isStackSymbol()
Description copied from interface:IFunctionSymbolReturns true if the value of this function symbol is stored on the stack as a variable- Specified by:
isStackSymbolin interfaceIFunctionSymbol
-
setValueFromSymbolTable
private void setValueFromSymbolTable(java.lang.Object value)
-
getValueDirectly
public java.lang.Object getValueDirectly()
-
setValueDirectly
public void setValueDirectly(java.lang.Object value)
-
invoke
public java.lang.Object invoke(java.lang.Object[] args)
Invokes function.- Specified by:
invokein interfaceIFunctionSymbol- Parameters:
args- An array of arguments to forward to the function.
-
getLightWeightReference
public ISymbol getLightWeightReference()
Description copied from interface:ISymbolCreates a copy of this symbol without the value so that the empty symbol can be stored.- Specified by:
getLightWeightReferencein interfaceISymbol
-
isImplicitlyInitialized
public boolean isImplicitlyInitialized()
-
isWritable
public boolean isWritable()
Description copied from interface:ISymbolReturns true if this symbol is writable. An example of a symbol that is not writable is a readonly Property referenced as a symbol in a Gosu class.- Specified by:
isWritablein interfaceISymbol
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equalsin classjava.lang.Object
-
getSignatureDescription
public java.lang.String getSignatureDescription()
Description copied from interface:IFunctionSymbolReturns a description of arguments of the form ( < argName1 >, < argName2 >, etc. ) appropriate for display in a source editor ui.- Specified by:
getSignatureDescriptionin interfaceIFunctionSymbol
-
getIndex
public int getIndex()
- Specified by:
getIndexin interfaceIReducedSymbol- Specified by:
getIndexin interfaceISymbol
-
isClassMember
public boolean isClassMember()
-
setClassMember
public void setClassMember(boolean bClassMember)
-
isStatic
public boolean isStatic()
- Specified by:
isStaticin interfaceIReducedSymbol
-
setStatic
public void setStatic(boolean bStatic)
-
isPrivate
public boolean isPrivate()
- Specified by:
isPrivatein interfaceIReducedSymbol
-
setPrivate
public void setPrivate(boolean bPrivate)
-
isInternal
public boolean isInternal()
- Specified by:
isInternalin interfaceIReducedSymbol
-
setInternal
public void setInternal(boolean bInternal)
-
isProtected
public boolean isProtected()
- Specified by:
isProtectedin interfaceIReducedSymbol
-
setProtected
public void setProtected(boolean bProtected)
-
isPublic
public boolean isPublic()
- Specified by:
isPublicin interfaceIReducedSymbol
-
setPublic
public void setPublic(boolean bPublic)
-
isAbstract
public boolean isAbstract()
- Specified by:
isAbstractin interfaceIReducedSymbol
-
setAbstract
public void setAbstract(boolean bAbstract)
-
isFinal
public boolean isFinal()
- Specified by:
isFinalin interfaceIReducedSymbol
-
setFinal
public void setFinal(boolean bFinal)
-
isReified
public boolean isReified()
- Specified by:
isReifiedin interfaceIReducedSymbol
-
setReified
public void setReified(boolean bReified)
-
isOverride
public boolean isOverride()
-
setOverride
public void setOverride(boolean bOverride)
-
isHide
public boolean isHide()
-
setHide
public void setHide(boolean bHide)
-
getModifierInfo
public ModifierInfo getModifierInfo()
- Specified by:
getModifierInfoin interfaceISymbol
-
setModifierInfo
public void setModifierInfo(IModifierInfo modifiers)
-
replaceModifierInfo
public void replaceModifierInfo(IModifierInfo mi)
-
getModifiers
public int getModifiers()
Description copied from interface:IFunctionSymbolReturns the modifiers for this function symbol- Specified by:
getModifiersin interfaceIFunctionSymbol- Specified by:
getModifiersin interfaceIReducedSymbol
-
getAnnotations
public java.util.List<IGosuAnnotation> getAnnotations()
- Specified by:
getAnnotationsin interfaceIReducedSymbol
-
getScriptPart
public IScriptPartId getScriptPart()
- Specified by:
getScriptPartin interfaceIReducedSymbol
-
getGosuClass
public IGosuClass getGosuClass()
- Specified by:
getGosuClassin interfaceIReducedSymbol
-
hasTypeVariables
public boolean hasTypeVariables()
- Specified by:
hasTypeVariablesin interfaceIReducedSymbol
-
setModifiers
public void setModifiers(int modifiers)
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
canBeCaptured
public boolean canBeCaptured()
- Specified by:
canBeCapturedin interfaceISymbol
-
makeCapturedSymbol
public ICapturedSymbol makeCapturedSymbol(java.lang.String strName, ISymbolTable symbolTable, IScope scope)
- Specified by:
makeCapturedSymbolin interfaceISymbol
-
setIndex
public void setIndex(int i)
-
setValueIsBoxed
public void setValueIsBoxed(boolean b)
Description copied from interface:ISymbolIndicates that this symbol should use a reference rather than storing its value directly.- Specified by:
setValueIsBoxedin interfaceISymbol
-
isValueBoxed
public boolean isValueBoxed()
- Specified by:
isValueBoxedin interfaceIReducedSymbol- Specified by:
isValueBoxedin interfaceISymbol
-
setName
protected void setName(java.lang.String name)
-
isFromJava
public boolean isFromJava()
- Specified by:
isFromJavain interfaceIFunctionSymbol- Returns:
- true if this function symbol came from a java superclass
-
getSymbolClass
public java.lang.Class getSymbolClass()
- Specified by:
getSymbolClassin interfaceIReducedSymbol
-
createReducedSymbol
public IReducedSymbol createReducedSymbol()
- Specified by:
createReducedSymbolin interfaceISymbol
-
-