Package ortus.boxlang.runtime.context
Class LambdaBoxContext
java.lang.Object
ortus.boxlang.runtime.context.BaseBoxContext
ortus.boxlang.runtime.context.FunctionBoxContext
ortus.boxlang.runtime.context.LambdaBoxContext
- All Implemented Interfaces:
Serializable,IBoxContext,IBoxAttachable
This context represents the execution of a Lambda. Lambdas are a simpler form of a Function which,
unlike UDFs, do not track things like return type, output, etc. Lambdas retain NO reference to the
context in which they were created, and do not search scopes outside their local and arguments scope.
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface ortus.boxlang.runtime.context.IBoxContext
IBoxContext.ScopeSearchResult -
Field Summary
Fields inherited from class ortus.boxlang.runtime.context.FunctionBoxContext
argumentsScope, enclosingBoxClass, enclosingBoxInterface, enclosingStaticBoxClass, function, functionCalledName, localScopeFields inherited from class ortus.boxlang.runtime.context.BaseBoxContext
currentImports, nullIsUndefined, parent -
Constructor Summary
ConstructorsConstructorDescriptionLambdaBoxContext(IBoxContext parent, Lambda function) Creates a new execution context with a bounded function instance and parent contextLambdaBoxContext(IBoxContext parent, Lambda function, ArgumentsScope argumentsScope) Creates a new execution context with a bounded function instance and parent context and arguments scopeLambdaBoxContext(IBoxContext parent, Lambda function, Key functionCalledName, Object[] positionalArguments) Creates a new execution context with a bounded function instance and parent context and arguments scopeLambdaBoxContext(IBoxContext parent, Lambda function, Key functionCalledName, Map<Key, Object> namedArguments) Creates a new execution context with a bounded function instance and parent context and arguments scopeLambdaBoxContext(IBoxContext parent, Lambda function, Key functionCalledName, ArgumentsScope argumentsScope) Creates a new execution context with a bounded function instance and parent context and arguments scope -
Method Summary
Modifier and TypeMethodDescriptionGet the default variable assignment scope for this contextReturns the function being invoked with this context, cast as a LambdaLook for a scope by namegetScopeNearby(Key name, boolean shallow) Look for a "nearby" scope by namegetVisibleScopes(IStruct scopes, boolean nearby, boolean shallow) This is mostly for the debugger.booleanisKeyVisibleScope(Key key, boolean nearby, boolean shallow) Check if a key is visible in the current context as a scope name.Search for a variable in scopesscopeFindNearby(Key key, IScope defaultScope, boolean shallow, boolean forAssign) Search for a variable in "nearby" scopesMethods inherited from class ortus.boxlang.runtime.context.FunctionBoxContext
canOutput, findClosestFunctionName, findFunction, flushBuffer, getArgumentsScope, getFunctionClass, getFunctionInterface, getFunctionParentContext, getFunctionStaticClass, getThisClass, getThisInterface, getThisStaticClass, invokeFunction, invokeFunction, invokeFunction, isInClass, isInInterface, isInStaticClass, registerUDF, scopeFindSuper, scopeFindThis, setThisClass, setThisInterface, setThisStaticClassMethods inherited from class ortus.boxlang.runtime.context.BaseBoxContext
_getAttachable, _getBuffers, _getComponents, _getOutputComponentCount, _getQueryLoops, _getTemplates, clearBuffer, clearConfigCache, computeAttachmentIfAbsent, findBaseTemplate, findBIF, findClosestComponent, findClosestComponent, findClosestComponent, findClosestComponent, findClosestTemplate, getApplicationContext, getAttachment, getAttachmentKeys, getBuffer, getComponents, getConfig, getConfigItem, getConfigItem, getConfigItems, getCurrentImports, getLogger, getModuleRecord, getModuleSettings, getParent, getParentOfType, getQueryRow, getQueryRow, getRequestContext, getRuntime, getScopeNearby, getTemplates, getVisibleScopes, hasAttachment, hasParent, hasTemplates, includeTemplate, incrementQueryLoop, injectParentContext, injectTopParentContext, invokeComponent, invokeFunction, invokeFunction, invokeFunction, invokeFunction, invokeFunction, isDefined, isInOutputComponent, isKeyVisibleScope, navigateConfig, popBuffer, popComponent, popTemplate, pushBuffer, pushComponent, pushTemplate, pushTemplate, putAttachment, queryFindNearby, registerQueryLoop, registerUDF, removeAttachment, removeParentContext, rethrow, scopeFindNearby, setParent, unregisterQueryLoop, unwrapQueryColumn, writeToBuffer, writeToBufferMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface ortus.boxlang.runtime.context.IBoxContext
getApplicationCache, getApplicationName, includeTemplate, registerUDF, shutdown, startup
-
Constructor Details
-
LambdaBoxContext
Creates a new execution context with a bounded function instance and parent context- Parameters:
parent- The parent contextfunction- The Lambda being invoked with this context
-
LambdaBoxContext
Creates a new execution context with a bounded function instance and parent context and arguments scope- Parameters:
parent- The parent contextfunction- The Lambda being invoked with this contextargumentsScope- The arguments scope for this context
-
LambdaBoxContext
public LambdaBoxContext(IBoxContext parent, Lambda function, Key functionCalledName, Object[] positionalArguments) Creates a new execution context with a bounded function instance and parent context and arguments scope- Parameters:
parent- The parent contextfunction- The Closure being invoked with this contextfunctionCalledName- The name of the function being invokedpositionalArguments- The arguments scope for this context
-
LambdaBoxContext
public LambdaBoxContext(IBoxContext parent, Lambda function, Key functionCalledName, Map<Key, Object> namedArguments) Creates a new execution context with a bounded function instance and parent context and arguments scope- Parameters:
parent- The parent contextfunction- The Closure being invoked with this contextfunctionCalledName- The name of the function being invokednamedArguments- The arguments scope for this context
-
LambdaBoxContext
public LambdaBoxContext(IBoxContext parent, Lambda function, Key functionCalledName, ArgumentsScope argumentsScope) Creates a new execution context with a bounded function instance and parent context and arguments scope- Parameters:
parent- The parent contextfunction- The Closure being invoked with this contextfunctionCalledName- The name of the function being invokedargumentsScope- The arguments scope for this context
-
-
Method Details
-
getVisibleScopes
Description copied from class:BaseBoxContextThis is mostly for the debugger. It returns all visible scopes from this context.- Specified by:
getVisibleScopesin interfaceIBoxContext- Overrides:
getVisibleScopesin classFunctionBoxContext- Returns:
- A struct containing all contextual and lexically visible scopes
-
isKeyVisibleScope
Check if a key is visible in the current context as a scope name. This allows us to "reserve" known scope names to ensure arguments.foo will always look in the proper arguments scope and never in local.arguments.foo for example- Specified by:
isKeyVisibleScopein interfaceIBoxContext- Overrides:
isKeyVisibleScopein classFunctionBoxContext- Parameters:
key- The key to check for visibilitynearby- true, check only scopes that are nearby to the current execution contextshallow- true, do not delegate to parent or default scope if not found- Returns:
- True if the key is visible in the current context, else false
-
scopeFindNearby
public IBoxContext.ScopeSearchResult scopeFindNearby(Key key, IScope defaultScope, boolean shallow, boolean forAssign) Search for a variable in "nearby" scopes- Specified by:
scopeFindNearbyin interfaceIBoxContext- Overrides:
scopeFindNearbyin classFunctionBoxContext- Parameters:
key- The key to search fordefaultScope- The default scope to use if the key is not foundshallow- Whether to search only the "nearby" scopes or all scopesforAssign- true, this is for an assignment operation- Returns:
- The search result
-
getScope
Look for a scope by name- Specified by:
getScopein interfaceIBoxContext- Overrides:
getScopein classFunctionBoxContext- Parameters:
name- The name of the scope to look for- Returns:
- The scope reference to use
- Throws:
ScopeNotFoundException- If the scope was not found in any context
-
getScopeNearby
Look for a "nearby" scope by name- Specified by:
getScopeNearbyin interfaceIBoxContext- Overrides:
getScopeNearbyin classFunctionBoxContext- Parameters:
name- The name of the scope to look forshallow- true, do not delegate to parent or default scope if not found- Returns:
- The scope reference to use
- Throws:
ScopeNotFoundException- If the scope was not found in any context
-
scopeFind
Description copied from class:FunctionBoxContextSearch for a variable in scopes- Specified by:
scopeFindin interfaceIBoxContext- Overrides:
scopeFindin classFunctionBoxContext- Parameters:
key- The key to search fordefaultScope- The default scope to use if the key is not foundforAssign- true, this is for an assignment operation- Returns:
- The search result
-
getFunction
Returns the function being invoked with this context, cast as a Lambda- Overrides:
getFunctionin classFunctionBoxContext
-
getDefaultAssignmentScope
Get the default variable assignment scope for this context- Specified by:
getDefaultAssignmentScopein interfaceIBoxContext- Overrides:
getDefaultAssignmentScopein classFunctionBoxContext- Returns:
- The scope reference to use
-