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 doDumpBindings = (continuation: nameSpace, value: internalExpressionValue) => {
|
||||||
// let _ = Continuation.inspect(continuation, "doDumpBindings")
|
// let _ = Continuation.inspect(continuation, "doDumpBindings")
|
||||||
accessors.continuation = continuation
|
accessors.states.continuation = continuation
|
||||||
value->Ok
|
value->Ok
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -107,8 +107,9 @@ let reduceReturningBindings = (
|
||||||
continuation: T.bindings,
|
continuation: T.bindings,
|
||||||
accessors: ProjectAccessorsT.t,
|
accessors: ProjectAccessorsT.t,
|
||||||
): (result<InternalExpressionValue.t, 'e>, T.bindings) => {
|
): (result<InternalExpressionValue.t, 'e>, T.bindings) => {
|
||||||
|
let states = accessors.states
|
||||||
let result = reduceExpressionInProject(expression, continuation, accessors)
|
let result = reduceExpressionInProject(expression, continuation, accessors)
|
||||||
(result, accessors.continuation)
|
(result, states.continuation)
|
||||||
}
|
}
|
||||||
|
|
||||||
module BackCompatible = {
|
module BackCompatible = {
|
||||||
|
|
|
@ -16,7 +16,7 @@ let ievFromTypeExpression = (
|
||||||
Reducer_Expression.BackCompatible.parse(sourceCode)->Belt.Result.flatMap(expr => {
|
Reducer_Expression.BackCompatible.parse(sourceCode)->Belt.Result.flatMap(expr => {
|
||||||
let accessors = ProjectAccessorsT.identityAccessors
|
let accessors = ProjectAccessorsT.identityAccessors
|
||||||
let result = reducerFn(expr, Bindings.emptyBindings, accessors)
|
let result = reducerFn(expr, Bindings.emptyBindings, accessors)
|
||||||
let nameSpace = accessors.continuation
|
let nameSpace = accessors.states.continuation
|
||||||
|
|
||||||
switch result {
|
switch result {
|
||||||
| Ok(_) =>
|
| Ok(_) =>
|
||||||
|
|
|
@ -138,7 +138,7 @@ module Private = {
|
||||||
}
|
}
|
||||||
|
|
||||||
let buildProjectAccessors = (this: t): ProjectAccessorsT.t => {
|
let buildProjectAccessors = (this: t): ProjectAccessorsT.t => {
|
||||||
continuation: Bindings.emptyBindings,
|
states: {continuation: Bindings.emptyBindings},
|
||||||
stdLib: getStdLib(this),
|
stdLib: getStdLib(this),
|
||||||
environment: getEnvironment(this),
|
environment: getEnvironment(this),
|
||||||
}
|
}
|
||||||
|
@ -149,9 +149,10 @@ module Private = {
|
||||||
continuation: ProjectItem.T.continuation,
|
continuation: ProjectItem.T.continuation,
|
||||||
): unit => {
|
): unit => {
|
||||||
let accessors = buildProjectAccessors(this)
|
let accessors = buildProjectAccessors(this)
|
||||||
|
let states = accessors.states
|
||||||
let newItem = this->getItem(sourceId)->ProjectItem.run(continuation, accessors)
|
let newItem = this->getItem(sourceId)->ProjectItem.run(continuation, accessors)
|
||||||
Belt.Map.String.set(this["items"], sourceId, newItem)->T.Private.setFieldItems(this, _)
|
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)
|
type runState = (ProjectItem.T.resultArgumentType, ProjectItem.T.continuation)
|
||||||
|
|
|
@ -3,22 +3,38 @@ module Bindings = Reducer_Bindings
|
||||||
module ExpressionT = Reducer_Expression_T
|
module ExpressionT = Reducer_Expression_T
|
||||||
module InternalExpressionValue = ReducerInterface_InternalExpressionValue
|
module InternalExpressionValue = ReducerInterface_InternalExpressionValue
|
||||||
|
|
||||||
|
type states = {mutable continuation: ProjectItemT.continuationArgumentType}
|
||||||
|
|
||||||
type projectAccessors = {
|
type projectAccessors = {
|
||||||
stdLib: Reducer_Bindings.t,
|
stdLib: Reducer_Bindings.t,
|
||||||
environment: ExpressionT.environment,
|
environment: ExpressionT.environment,
|
||||||
mutable continuation: ProjectItemT.continuationArgumentType,
|
states: states,
|
||||||
}
|
}
|
||||||
|
|
||||||
type t = projectAccessors
|
type t = projectAccessors
|
||||||
|
|
||||||
let identityAccessors: t = {
|
let identityAccessors: t = {
|
||||||
continuation: Bindings.emptyBindings,
|
// 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,
|
stdLib: ReducerInterface_StdLib.internalStdLib,
|
||||||
environment: InternalExpressionValue.defaultEnvironment,
|
environment: InternalExpressionValue.defaultEnvironment,
|
||||||
}
|
}
|
||||||
|
|
||||||
let identityAccessorsWithEnvironment = (environment): t => {
|
let identityAccessorsWithEnvironment = (environment): t => {
|
||||||
continuation: Bindings.emptyBindings,
|
states: {
|
||||||
|
continuation: Bindings.emptyBindings,
|
||||||
|
},
|
||||||
stdLib: ReducerInterface_StdLib.internalStdLib,
|
stdLib: ReducerInterface_StdLib.internalStdLib,
|
||||||
environment: environment,
|
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