Package edu.uiuc.ncsa.qdl.state
Class State
-
- All Implemented Interfaces:
QDLConstants
,edu.uiuc.ncsa.security.core.Logable
,edu.uiuc.ncsa.security.util.scripting.StateInterface
,Serializable
public class State extends FunctionState implements QDLConstants
This is a facade for the various stateful components we have to track. Represents the internal state of the system.Created by Jeff Gaynor
on 1/21/20 at 7:25 AM- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class edu.uiuc.ncsa.qdl.state.VariableState
VariableState.CyclicalError, VariableState.ResolveState
-
-
Field Summary
Fields Modifier and Type Field Description static VStack
extrinsicVars
-
Fields inherited from class edu.uiuc.ncsa.qdl.state.VariableState
EXTRINSIC_MARKER, int_regex, var_regex
-
Fields inherited from class edu.uiuc.ncsa.qdl.state.NamespaceAwareState
NS_DELIMITER, RESERVED_NAMESPACE
-
Fields inherited from class edu.uiuc.ncsa.qdl.state.ModuleState
MTemplates
-
Fields inherited from class edu.uiuc.ncsa.qdl.state.AbstractState
INTRINSIC_PREFIX, libPath, scriptArgs
-
Fields inherited from interface edu.uiuc.ncsa.qdl.state.QDLConstants
ALL_CHARS, ALPHA_CHARS, ASCII_CHARS, FUNCTION_REFERENCE_MARKER, FUNCTION_REFERENCE_MARKER2, GREEK_CHARS, JSON_QDL_NULL, KEYWORDS, RESERVED_FALSE, RESERVED_NULL, RESERVED_NULL_SET, RESERVED_TRUE, STEM_PATH_MARKER, STEM_PATH_MARKER2, SYS_ASSERT_CODE_SYSTEM_ERROR, SYS_BOOT, SYS_BOOT_BOOT_SCRIPT, SYS_BOOT_CONFIG_FILE, SYS_BOOT_CONFIG_NAME, SYS_BOOT_LOG_FILE, SYS_BOOT_LOG_NAME, SYS_BOOT_QDL_HOME, SYS_BOOT_RESTRICTED_IO_MODE, SYS_BOOT_SERVER_MODE, SYS_CODEC_ALGORITHMS, SYS_CODEC_B16CODE, SYS_CODEC_B32CODE, SYS_CODEC_B64CODE, SYS_CODEC_CSV, SYS_CODEC_ECMA, SYS_CODEC_HTML3, SYS_CODEC_HTML4, SYS_CODEC_JAVA, SYS_CODEC_JSON, SYS_CODEC_QDL_ENCODE, SYS_CODEC_URLCODE, SYS_CODEC_VENCODE, SYS_CODEC_XML_1_0, SYS_CODEC_XML_1_1, SYS_CODEC_XSI, SYS_DETOKENIZE_APPEND, SYS_DETOKENIZE_OMIT_DANGLING_DELIMITER, SYS_DETOKENIZE_PREPEND, SYS_DETOKENIZE_TYPE, SYS_ERROR_CODE_DEFAULT_USER_ERROR, SYS_ERROR_CODE_SYSTEM_ERROR, SYS_ERROR_CODES, SYS_FILE_TYPE_BINARY, SYS_FILE_TYPE_INIT, SYS_FILE_TYPE_NO_LIST_INIT, SYS_FILE_TYPE_STEM, SYS_FILE_TYPE_STRING, SYS_FILE_TYPES, SYS_HASH_ALGORITHMS, SYS_INFO_CLASS_PATH, SYS_INFO_INIT_MEMORY, SYS_INFO_JVM_VERSION, SYS_INFO_OS, SYS_INFO_OS_ARCHITECTURE, SYS_INFO_OS_NAME, SYS_INFO_OS_VERSION, SYS_INFO_SYSTEM, SYS_INFO_SYSTEM_PROCESSORS, SYS_INFO_USER, SYS_INFO_USER_HOME_DIR, SYS_INFO_USER_INVOCATION_DIR, SYS_LOG_ERROR, SYS_LOG_INFO, SYS_LOG_LEVELS, SYS_LOG_NONE, SYS_LOG_SEVERE, SYS_LOG_TRACE, SYS_LOG_WARN, SYS_MODULE_IMPORT_MODES, SYS_QDL_BUILD, SYS_QDL_BUILD_CLASS_PATH, SYS_QDL_BUILD_VERSION, SYS_QDL_VERSION, SYS_QDL_VERSION_BUILD_JDK, SYS_QDL_VERSION_BUILD_NUMBER, SYS_QDL_VERSION_BUILD_TIME, SYS_QDL_VERSION_CREATED_BY, SYS_SCRIPTS_PATH, SYS_VAR_TYPE_BOOLEAN, SYS_VAR_TYPE_CHARACTER_MAP, SYS_VAR_TYPE_CHARACTERS, SYS_VAR_TYPE_DECIMAL, SYS_VAR_TYPE_INTEGER, SYS_VAR_TYPE_NULL, SYS_VAR_TYPE_RESERVED, SYS_VAR_TYPE_SET, SYS_VAR_TYPE_STEM, SYS_VAR_TYPE_STRING, SYS_VAR_TYPE_UNDEFINED, SYS_VAR_TYPES, UNICODE_CHARS, URI_AUTHORITY, URI_FIELDS, URI_FRAGMENT, URI_HOST, URI_PATH, URI_PORT, URI_QUERY, URI_SCHEME, URI_SCHEME_SPECIFIC_PART, URI_USER_INFO
-
-
Constructor Summary
Constructors Constructor Description State()
This is needed for XML deserialization and makes dummy state for everything, assuming the deserializer will replace it all.State(VStack vStack, OpEvaluator opEvaluator, MetaEvaluator metaEvaluator, FStack<? extends FTable<? extends FKey,? extends FunctionRecordInterface>> ftStack, MTStack mtStack, MIStack miStack, edu.uiuc.ncsa.security.core.util.MyLoggingFacade myLoggingFacade, boolean isServerMode, boolean isRestrictedIO, boolean assertionsOn)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
addJSONtoState(net.sf.json.JSONObject jsonObject, String tag, XStack xStack, SerializationState serializationState)
void
addLibEntries(String libraryKey, QDLStem classPaths)
Adds a list of classpath to the info().lib key entry.void
addLibEntry(String libraryKey, String moduleKey, String className)
Add a single entry to a given libraryprotected QDLStem
addManifestConstants(String path)
If this is packaged in a jar, read off the information from the manifest file.void
addModule(Module module)
Add the module under the default aliasvoid
addVFSProvider(VFSFileProvider scriptProvider)
void
buildSO(SerializationState SerializationState)
Recurse through the modules and collects templates and state objects from instances.protected net.sf.json.JSONObject
createConstants()
void
createSystemConstants()
void
createSystemInfo(QDLEnvironment qe)
void
deserializeFromJSON(net.sf.json.JSONObject jsonObject, SerializationState s)
protected void
doLocalSerialization(XStack oldStack, String tag, net.sf.json.JSONObject jsonObject, SerializationState serializationState)
protected void
doXMLImportedModules(XMLEventReader xer)
This just drives running through a bunch of modulesvoid
fromXML(XMLEventReader xer, edu.uiuc.ncsa.security.core.configuration.XProperties xp)
void
fromXML(XMLEventReader xer, edu.uiuc.ncsa.security.core.configuration.XProperties xp, SerializationState serializationState)
edu.uiuc.ncsa.security.core.util.MetaDebugUtil
getDebugUtil()
Debug utility for QDL.VStack
getExtrinsicVars()
static State
getFactory()
VFSEntry
getFileFromVFS(String fqName, int type)
String
getInternalID()
The internal id of the state object is needed in serialization and other operations.QDLStem
getLibMap()
protected QDLStem
getQDLReservedNames()
Get a listing of all the functions, operators and keywords for QDL.static State
getRootState()
At system startup this is set to be the top-level state object for the system.QDLScript
getScriptFromVFS(String fqName)
Convenience to get a script from the VFS.int
getStackSize()
int
getStateID()
This is used in the debugger and refers to paused vs running processes.QDLStem
getSystemConstants()
QDLStem
getSystemInfo()
State
getTargetState()
The target state is used in cases where argument lists are processed.String
getTempVariableName()
Returns an unused variable name.Map<Integer,QDLThreadRecord>
getThreadTable()
VFSFileProvider
getVFS(String fqName)
Given a fully qualified path, find the VFS corresponding to the mount point and return it or null if no such mount point existsHashMap<String,VFSFileProvider>
getVfsFileProviders()
WorkspaceCommands
getWorkspaceCommands()
Allows back reference to workspace to run macros.boolean
hasMountPoint(String mountPoint)
boolean
hasVFSProviders()
void
injectTransientFields(State oldState)
For the case the this has been deserialized and needs to have its transient fields initialized.boolean
isAllowBaseFunctionOverrides()
boolean
isAssertionsOn()
boolean
isRestrictedIO()
In server mode, some IO for debugging with debugger is still be allowed.boolean
isServerMode()
boolean
isVFSFile(String path)
static void
main(String[] args)
State
newCleanState()
This creates a completely clean state, using the current environment (so modules and script paths, but not variables, modules etc.) and preserves debuggingState
newFunctionState()
Carries over modules and functions, but not variables.State
newInstance()
A new instance with the default components.State
newInstance(VStack symbolStack, OpEvaluator opEvaluator, MetaEvaluator metaEvaluator, FStack<? extends FTable<? extends FKey,? extends FunctionRecordInterface>> ftStack, MTStack mtStack, MIStack miStack, edu.uiuc.ncsa.security.core.util.MyLoggingFacade myLoggingFacade, boolean isServerMode, boolean isRestrictedIO, boolean assertionsOn)
If you extend this class, you must override this method to return a new instance of your state with everything in it you want or need.State
newLocalState()
Convenience method fornewLocalState(State)
with a null argumentState
newLocalState(State moduleState)
Creates a new state object and pushes the moduleState's stacks onto the current one.State
newSelectiveState(State moduleState)
State
newSelectiveState(State moduleState, boolean inheritVariables)
Create a clean state, taking the old modules from moduleState, all the functions and allowing inheritance of the current variable stackState
newSelectiveState(State moduleState, boolean inheritFunctions, boolean inheritVariables)
This will clone the current state and will add the modules (templates and instances -- old modules) from moduleState.State
newSelectiveState(State moduleState, boolean inheritModules, boolean inheritFunctions, boolean inheritVariables)
Create a new state based on the current state and choosing what to inherit.protected QDLStem
processManifest(QDLStem versionInfo, ArrayList<String> manifest)
protected QDLStem
processManifest2(QDLStem versionInfo, ArrayList<String> manifest)
protected void
readConstantsFromJSON(net.sf.json.JSONObject json)
void
readExtraXMLAttributes(StartElement xe)
Allows you to read custom attributes from the state tag.void
readExtraXMLElements(XMLEvent xe, XMLEventReader xer)
This passes in the current start event so you can add your own event loop and cases.void
removeScriptProvider(String scheme)
void
removeVFSProvider(String mountPoint)
net.sf.json.JSONObject
serializeLocalStateToJSON(SerializationState serializationState)
Only serialize the local part of the state.net.sf.json.JSONObject
serializeToJSON(SerializationState s)
void
setAllowBaseFunctionOverrides(boolean allowBaseFunctionOverrides)
void
setAssertionsOn(boolean assertionsOn)
void
setDebugUtil(edu.uiuc.ncsa.security.core.util.MetaDebugUtil debugUtil)
void
setExtrinsicVars(VStack extrinsicVars)
static void
setFactory(State factory)
void
setRestrictedIO(boolean restrictedIO)
static void
setRootState(State newRoot)
void
setServerMode(boolean serverMode)
void
setStateID(int pid)
void
setSystemConstants(QDLStem systemConstants)
void
setSystemInfo(QDLStem systemInfo)
void
setTargetState(State targetState)
void
setThreadTable(Map<Integer,QDLThreadRecord> threadTable)
void
setVfsFileProviders(HashMap<String,VFSFileProvider> vfsFileProviders)
void
setWorkspaceCommands(WorkspaceCommands workspaceCommands)
void
toXML(XMLStreamWriter xsw)
void
toXML(XMLStreamWriter xsw, SerializationState serializationState)
void
writeExtraXMLAttributes(XMLStreamWriter xsw)
This exists to let you add additional attributes to the state tag.void
writeExtraXMLElements(XMLStreamWriter xsr)
This is invoked at the end of the serialization and lets you add additional things to be serialized in the State.-
Methods inherited from class edu.uiuc.ncsa.qdl.state.FunctionState
getAllFunctionsByName, getFTStack, listAllDocumentation, listFunctionDoc, listFunctions, listFunctions, listModuleDoc, resolveFunction, resolveFunction, setFTStack
-
Methods inherited from class edu.uiuc.ncsa.qdl.state.VariableState
getValue, getValue, gsrNSScalarOp, gsrNSStemOp, isDefined, isExtrinsic, isStem, listVariables, remove, resolveStemIndex, resolveStemIndex, setValue, setValue
-
Methods inherited from class edu.uiuc.ncsa.qdl.state.NamespaceAwareState
getAlias, getUNQName
-
Methods inherited from class edu.uiuc.ncsa.qdl.state.ModuleState
getImportedModule, getMInstances, getModule, getMTemplates, getUsedModules, hasModule, isImportMode, isModuleState, setImportMode, setMInstances, setModule, setModuleState, setMTemplates, setUsedModules
-
Methods inherited from class edu.uiuc.ncsa.qdl.state.AbstractState
debug, error, error, error, getIoInterface, getLibPath, getLogger, getMetaEvaluator, getModulePaths, getOperatorType, getOpEvaluator, getScriptArgs, getScriptArgStem, getScriptName, getScriptPaths, getScriptStack, getStateRegistry, getSuperState, getUuid, getVStack, hasLogging, hasScriptArgs, hasScriptName, hasSuperState, info, isDebugOn, isEnableLibrarySupport, isIntrinsic, isPrintUnicode, pathToList, setDebugOn, setEnableLibrarySupport, setIoInterface, setLibPath, setLibPath, setLogger, setMetaEvaluator, setModulePaths, setModulePaths, setOpEvaluator, setPrintUnicode, setScriptArgs, setScriptArgStem, setScriptName, setScriptPaths, setScriptPaths, setScriptStack, setSuperState, setUuid, setvStack, warn
-
-
-
-
Field Detail
-
extrinsicVars
public static VStack extrinsicVars
-
-
Constructor Detail
-
State
public State(VStack vStack, OpEvaluator opEvaluator, MetaEvaluator metaEvaluator, FStack<? extends FTable<? extends FKey,? extends FunctionRecordInterface>> ftStack, MTStack mtStack, MIStack miStack, edu.uiuc.ncsa.security.core.util.MyLoggingFacade myLoggingFacade, boolean isServerMode, boolean isRestrictedIO, boolean assertionsOn)
-
State
public State()
This is needed for XML deserialization and makes dummy state for everything, assuming the deserializer will replace it all. Generally do not use outside of XML deserialization.
-
-
Method Detail
-
getInternalID
public String getInternalID()
The internal id of the state object is needed in serialization and other operations. Every instance of a state object has a unique id.- Returns:
-
getStateID
public int getStateID()
This is used in the debugger and refers to paused vs running processes. It does not refer to process ids or the internal id of the state object.- Returns:
-
setStateID
public void setStateID(int pid)
-
getThreadTable
public Map<Integer,QDLThreadRecord> getThreadTable()
-
setThreadTable
public void setThreadTable(Map<Integer,QDLThreadRecord> threadTable)
-
newInstance
public State newInstance()
A new instance with the default components.- Returns:
-
getFactory
public static State getFactory()
-
setFactory
public static void setFactory(State factory)
-
newInstance
public State newInstance(VStack symbolStack, OpEvaluator opEvaluator, MetaEvaluator metaEvaluator, FStack<? extends FTable<? extends FKey,? extends FunctionRecordInterface>> ftStack, MTStack mtStack, MIStack miStack, edu.uiuc.ncsa.security.core.util.MyLoggingFacade myLoggingFacade, boolean isServerMode, boolean isRestrictedIO, boolean assertionsOn)
If you extend this class, you must override this method to return a new instance of your state with everything in it you want or need. Then set yoursetFactory(State)
- Parameters:
opEvaluator
-metaEvaluator
-ftStack
-mtStack
-miStack
-myLoggingFacade
-isServerMode
-isRestrictedIO
-assertionsOn
-- Returns:
-
getSystemConstants
public QDLStem getSystemConstants()
-
setSystemConstants
public void setSystemConstants(QDLStem systemConstants)
-
getSystemInfo
public QDLStem getSystemInfo()
-
setSystemInfo
public void setSystemInfo(QDLStem systemInfo)
-
createSystemInfo
public void createSystemInfo(QDLEnvironment qe)
-
addLibEntries
public void addLibEntries(String libraryKey, QDLStem classPaths)
Adds a list of classpath to the info().lib key entry. This allows modules to add their classes to the library so users can find them. The argument is a stem with key values pairs:
name : classpath
and will be added to an existing entry with the same key or a new one.E.g. calling
addLibEntries("oa2", {"store":"path.to.store"})would result in the entry info().'lib'.'oa2'.'store'
returning the path.to.store- Parameters:
libraryKey
-classPaths
-
-
addLibEntry
public void addLibEntry(String libraryKey, String moduleKey, String className)
Add a single entry to a given library- Parameters:
libraryKey
-moduleKey
-className
-
-
getLibMap
public QDLStem getLibMap()
-
createSystemConstants
public void createSystemConstants()
-
getQDLReservedNames
protected QDLStem getQDLReservedNames()
Get a listing of all the functions, operators and keywords for QDL.- Returns:
-
getDebugUtil
public edu.uiuc.ncsa.security.core.util.MetaDebugUtil getDebugUtil()
Debug utility for QDL. Note that this is completely independent of theDebugUtil
for the JVM, which can be toggled with the WS variable 'debug'- Returns:
-
setDebugUtil
public void setDebugUtil(edu.uiuc.ncsa.security.core.util.MetaDebugUtil debugUtil)
-
addManifestConstants
protected QDLStem addManifestConstants(String path)
If this is packaged in a jar, read off the information from the manifest file. If no manifest, skip this.- Returns:
-
processManifest2
protected QDLStem processManifest2(QDLStem versionInfo, ArrayList<String> manifest)
-
isServerMode
public boolean isServerMode()
-
setServerMode
public void setServerMode(boolean serverMode)
-
isRestrictedIO
public boolean isRestrictedIO()
In server mode, some IO for debugging with debugger is still be allowed. If this flag is set true, then printing is not allowed nor is saving the workspace.- Returns:
-
setRestrictedIO
public void setRestrictedIO(boolean restrictedIO)
-
getVfsFileProviders
public HashMap<String,VFSFileProvider> getVfsFileProviders()
-
setVfsFileProviders
public void setVfsFileProviders(HashMap<String,VFSFileProvider> vfsFileProviders)
-
addVFSProvider
public void addVFSProvider(VFSFileProvider scriptProvider)
-
hasMountPoint
public boolean hasMountPoint(String mountPoint)
-
removeVFSProvider
public void removeVFSProvider(String mountPoint)
-
removeScriptProvider
public void removeScriptProvider(String scheme)
-
getScriptFromVFS
public QDLScript getScriptFromVFS(String fqName) throws Throwable
Convenience to get a script from the VFS. This takes any file and tries to turn it in to a script, so the "onus is on the app" to make sure this is a script.- Parameters:
fqName
-- Returns:
- Throws:
Throwable
-
getVFS
public VFSFileProvider getVFS(String fqName) throws Throwable
Given a fully qualified path, find the VFS corresponding to the mount point and return it or null if no such mount point exists- Parameters:
fqName
-- Returns:
- Throws:
Throwable
-
getFileFromVFS
public VFSEntry getFileFromVFS(String fqName, int type) throws Throwable
- Throws:
Throwable
-
hasVFSProviders
public boolean hasVFSProviders()
-
isVFSFile
public boolean isVFSFile(String path)
-
newLocalState
public State newLocalState()
Convenience method fornewLocalState(State)
with a null argument- Returns:
- State
-
newLocalState
public State newLocalState(State moduleState)
Creates a new state object and pushes the moduleState's stacks onto the current one. This means the resulting state inherits everything.- Parameters:
moduleState
-- Returns:
-
newSelectiveState
public State newSelectiveState(State moduleState, boolean inheritVariables)
Create a clean state, taking the old modules from moduleState, all the functions and allowing inheritance of the current variable stack- Parameters:
moduleState
-inheritVariables
-- Returns:
-
newSelectiveState
public State newSelectiveState(State moduleState, boolean inheritFunctions, boolean inheritVariables)
This will clone the current state and will add the modules (templates and instances -- old modules) from moduleState. If pushFunctions is- Parameters:
moduleState
-inheritFunctions
-inheritVariables
-- Returns:
-
newSelectiveState
public State newSelectiveState(State moduleState, boolean inheritModules, boolean inheritFunctions, boolean inheritVariables)
Create a new state based on the current state and choosing what to inherit. In this case, inherited objects come first, items in current state are appended. This allows for overrides inStatement.evaluate(State)
calls.- Parameters:
moduleState
-inheritModules
-inheritFunctions
-inheritVariables
-- Returns:
-
injectTransientFields
public void injectTransientFields(State oldState)
For the case the this has been deserialized and needs to have its transient fields initialized. These are things like theMetaEvaluator
that should not be serialized or current mount points (which can't be serialized because you'd have to serialize the entire backing file system to satisfy the contract of serialization!)- Parameters:
oldState
-
-
newCleanState
public State newCleanState()
This creates a completely clean state, using the current environment (so modules and script paths, but not variables, modules etc.) and preserves debugging- Returns:
-
newFunctionState
public State newFunctionState()
Carries over modules and functions, but not variables.- Returns:
-
addModule
public void addModule(Module module)
Add the module under the default alias- Parameters:
module
-
-
getStackSize
public int getStackSize()
-
toXML
public void toXML(XMLStreamWriter xsw, SerializationState serializationState) throws XMLStreamException
- Throws:
XMLStreamException
-
toXML
public void toXML(XMLStreamWriter xsw) throws XMLStreamException
- Throws:
XMLStreamException
-
fromXML
public void fromXML(XMLEventReader xer, edu.uiuc.ncsa.security.core.configuration.XProperties xp, SerializationState serializationState) throws XMLStreamException
- Throws:
XMLStreamException
-
fromXML
public void fromXML(XMLEventReader xer, edu.uiuc.ncsa.security.core.configuration.XProperties xp) throws XMLStreamException
- Throws:
XMLStreamException
-
doXMLImportedModules
protected void doXMLImportedModules(XMLEventReader xer) throws XMLStreamException
This just drives running through a bunch of modules- Parameters:
xer
-- Throws:
XMLStreamException
-
writeExtraXMLElements
public void writeExtraXMLElements(XMLStreamWriter xsr) throws XMLStreamException
This is invoked at the end of the serialization and lets you add additional things to be serialized in the State. All new elements are added right before the final closing tag for the state object.- Parameters:
xsr
-- Throws:
XMLStreamException
-
createConstants
protected net.sf.json.JSONObject createConstants()
-
writeExtraXMLAttributes
public void writeExtraXMLAttributes(XMLStreamWriter xsw) throws XMLStreamException
This exists to let you add additional attributes to the state tag. It should only containXMLStreamWriter.writeAttribute(String, String)
calls, nothing else.- Parameters:
xsw
-- Throws:
XMLStreamException
-
readExtraXMLElements
public void readExtraXMLElements(XMLEvent xe, XMLEventReader xer) throws XMLStreamException
This passes in the current start event so you can add your own event loop and cases. Note you need have only a switch on the tag names you want.- Parameters:
xe
-xer
-- Throws:
XMLStreamException
-
readConstantsFromJSON
protected void readConstantsFromJSON(net.sf.json.JSONObject json)
-
readExtraXMLAttributes
public void readExtraXMLAttributes(StartElement xe) throws XMLStreamException
Allows you to read custom attributes from the state tag. This should only contain calls toStartElement.getAttributeByName(QName)
by name calls.- Parameters:
xe
-- Throws:
XMLStreamException
-
getTempVariableName
public String getTempVariableName()
Returns an unused variable name.- Returns:
-
isAssertionsOn
public boolean isAssertionsOn()
-
setAssertionsOn
public void setAssertionsOn(boolean assertionsOn)
-
getWorkspaceCommands
public WorkspaceCommands getWorkspaceCommands()
Allows back reference to workspace to run macros.- Returns:
-
setWorkspaceCommands
public void setWorkspaceCommands(WorkspaceCommands workspaceCommands)
-
buildSO
public void buildSO(SerializationState SerializationState)
Recurse through the modules and collects templates and state objects from instances. Now that templates and instances are handled as stacks with local state, old form of serialization fails due to recursion.
These are serialized into a flat list and references to them are used. This also checks for cycles.- Parameters:
SerializationState
-
-
setExtrinsicVars
public void setExtrinsicVars(VStack extrinsicVars)
-
getExtrinsicVars
public VStack getExtrinsicVars()
- Overrides:
getExtrinsicVars
in classVariableState
-
isAllowBaseFunctionOverrides
public boolean isAllowBaseFunctionOverrides()
-
setAllowBaseFunctionOverrides
public void setAllowBaseFunctionOverrides(boolean allowBaseFunctionOverrides)
-
getTargetState
public State getTargetState()
The target state is used in cases where argument lists are processed. This allows for theANode2
assignment to a different state that the calling state, in particular, this is how functions can assign variables in their argument list only for the duration of the function.- Returns:
-
setTargetState
public void setTargetState(State targetState)
-
getRootState
public static State getRootState()
At system startup this is set to be the top-level state object for the system. It is used, e.g. in resolving default namepsace requests everywhere and should be set exactly once on startup by the system.- Returns:
-
setRootState
public static void setRootState(State newRoot)
-
serializeLocalStateToJSON
public net.sf.json.JSONObject serializeLocalStateToJSON(SerializationState serializationState) throws Throwable
Only serialize the local part of the state. This is used by e.g., modules that have shared state and should never overwrite shared state on deserialization.- Parameters:
serializationState
-- Returns:
- Throws:
Throwable
-
doLocalSerialization
protected void doLocalSerialization(XStack oldStack, String tag, net.sf.json.JSONObject jsonObject, SerializationState serializationState) throws Throwable
- Throws:
Throwable
-
serializeToJSON
public net.sf.json.JSONObject serializeToJSON(SerializationState s) throws Throwable
- Throws:
Throwable
-
addJSONtoState
protected void addJSONtoState(net.sf.json.JSONObject jsonObject, String tag, XStack xStack, SerializationState serializationState) throws Throwable
- Throws:
Throwable
-
deserializeFromJSON
public void deserializeFromJSON(net.sf.json.JSONObject jsonObject, SerializationState s) throws Throwable
- Throws:
Throwable
-
main
public static void main(String[] args)
-
-