compatibility to change environment at runtime
There will be changes in develop to change environment at runtime. This fix provides compatibility. So that they can be merged easier.
This commit is contained in:
parent
66f2f18a00
commit
1b69ce3aa1
|
@ -104,7 +104,7 @@ let callInternal = (
|
|||
|
||||
let doDumpBindings = (continuation: nameSpace, value: internalExpressionValue) => {
|
||||
// let _ = Continuation.inspect(continuation, "doDumpBindings")
|
||||
accessors.continuation = continuation
|
||||
accessors.states.continuation = continuation
|
||||
value->Ok
|
||||
}
|
||||
|
||||
|
|
|
@ -107,8 +107,9 @@ let reduceReturningBindings = (
|
|||
continuation: T.bindings,
|
||||
accessors: ProjectAccessorsT.t,
|
||||
): (result<InternalExpressionValue.t, 'e>, T.bindings) => {
|
||||
let states = accessors.states
|
||||
let result = reduceExpressionInProject(expression, continuation, accessors)
|
||||
(result, accessors.continuation)
|
||||
(result, states.continuation)
|
||||
}
|
||||
|
||||
module BackCompatible = {
|
||||
|
|
|
@ -16,7 +16,7 @@ let ievFromTypeExpression = (
|
|||
Reducer_Expression.BackCompatible.parse(sourceCode)->Belt.Result.flatMap(expr => {
|
||||
let accessors = ProjectAccessorsT.identityAccessors
|
||||
let result = reducerFn(expr, Bindings.emptyBindings, accessors)
|
||||
let nameSpace = accessors.continuation
|
||||
let nameSpace = accessors.states.continuation
|
||||
|
||||
switch result {
|
||||
| Ok(_) =>
|
||||
|
|
|
@ -138,7 +138,7 @@ module Private = {
|
|||
}
|
||||
|
||||
let buildProjectAccessors = (this: t): ProjectAccessorsT.t => {
|
||||
continuation: Bindings.emptyBindings,
|
||||
states: {continuation: Bindings.emptyBindings},
|
||||
stdLib: getStdLib(this),
|
||||
environment: getEnvironment(this),
|
||||
}
|
||||
|
@ -149,9 +149,10 @@ module Private = {
|
|||
continuation: ProjectItem.T.continuation,
|
||||
): unit => {
|
||||
let accessors = buildProjectAccessors(this)
|
||||
let states = accessors.states
|
||||
let newItem = this->getItem(sourceId)->ProjectItem.run(continuation, accessors)
|
||||
Belt.Map.String.set(this["items"], sourceId, newItem)->T.Private.setFieldItems(this, _)
|
||||
setContinuation(this, sourceId, accessors.continuation)
|
||||
setContinuation(this, sourceId, states.continuation)
|
||||
}
|
||||
|
||||
type runState = (ProjectItem.T.resultArgumentType, ProjectItem.T.continuation)
|
||||
|
|
|
@ -3,22 +3,38 @@ module Bindings = Reducer_Bindings
|
|||
module ExpressionT = Reducer_Expression_T
|
||||
module InternalExpressionValue = ReducerInterface_InternalExpressionValue
|
||||
|
||||
type states = {mutable continuation: ProjectItemT.continuationArgumentType}
|
||||
|
||||
type projectAccessors = {
|
||||
stdLib: Reducer_Bindings.t,
|
||||
environment: ExpressionT.environment,
|
||||
mutable continuation: ProjectItemT.continuationArgumentType,
|
||||
states: states,
|
||||
}
|
||||
|
||||
type t = projectAccessors
|
||||
|
||||
let identityAccessors: t = {
|
||||
// We need the states at the end of the runtime.
|
||||
// Accessors can be modified but states will stay as the same pointer
|
||||
states: {
|
||||
continuation: Bindings.emptyBindings,
|
||||
},
|
||||
stdLib: ReducerInterface_StdLib.internalStdLib,
|
||||
environment: InternalExpressionValue.defaultEnvironment,
|
||||
}
|
||||
|
||||
let identityAccessorsWithEnvironment = (environment): t => {
|
||||
states: {
|
||||
continuation: Bindings.emptyBindings,
|
||||
},
|
||||
stdLib: ReducerInterface_StdLib.internalStdLib,
|
||||
environment: environment,
|
||||
}
|
||||
|
||||
// to support change of environment in runtime
|
||||
let setEnvironment = (this: t, environment: ExpressionT.environment): t => {
|
||||
{
|
||||
...this,
|
||||
environment: environment,
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user