hiddenNameSpace
This commit is contained in:
parent
d9aef8d9c1
commit
17c3fe9dd8
|
@ -7,6 +7,9 @@ module ErrorValue = Reducer_ErrorValue
|
|||
@genType.opaque
|
||||
type internalCode = Object
|
||||
|
||||
@genType.opaque
|
||||
type hiddenNameSpace = Object
|
||||
|
||||
@genType
|
||||
type rec externalExpressionValue =
|
||||
| EvArray(array<externalExpressionValue>)
|
||||
|
@ -30,7 +33,7 @@ and record = Js.Dict.t<externalExpressionValue>
|
|||
and externalBindings = record
|
||||
and lambdaValue = {
|
||||
parameters: array<string>,
|
||||
context: externalBindings,
|
||||
context: hiddenNameSpace,
|
||||
body: internalCode,
|
||||
}
|
||||
and lambdaDeclaration = Declaration.declaration<lambdaValue>
|
||||
|
|
|
@ -37,6 +37,29 @@ type internalExpressionValue = t
|
|||
|
||||
type functionCall = (string, array<t>)
|
||||
|
||||
module Internal = {
|
||||
module NameSpace = {
|
||||
external castNameSpaceToHidden: nameSpace => ExternalExpressionValue.hiddenNameSpace =
|
||||
"%identity"
|
||||
external castHiddenToNameSpace: ExternalExpressionValue.hiddenNameSpace => nameSpace =
|
||||
"%identity"
|
||||
}
|
||||
module Lambda = {
|
||||
let toInternal = (v: ExternalExpressionValue.lambdaValue): lambdaValue => {
|
||||
let p = v.parameters
|
||||
let c = v.context->NameSpace.castHiddenToNameSpace
|
||||
let b = v.body
|
||||
{parameters: p, context: c, body: b}
|
||||
}
|
||||
and toExternal = (v: lambdaValue): ExternalExpressionValue.lambdaValue => {
|
||||
let p = v.parameters
|
||||
let c = v.context->NameSpace.castNameSpaceToHidden
|
||||
let b = v.body
|
||||
{parameters: p, context: c, body: b}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let rec toString = aValue =>
|
||||
switch aValue {
|
||||
| IEvArray(anArray) => {
|
||||
|
@ -244,12 +267,7 @@ let rec toExternal = (iev: t): ExternalExpressionValue.t => {
|
|||
}
|
||||
and mapToExternal = v =>
|
||||
v->Belt.Map.String.map(e => toExternal(e))->Belt.Map.String.toArray->Js.Dict.fromArray
|
||||
and lambdaValueToExternal = v => {
|
||||
let p = v.parameters
|
||||
let c = v.context->nameSpaceToTypeScriptBindings
|
||||
let b = v.body
|
||||
{parameters: p, context: c, body: b}
|
||||
}
|
||||
and lambdaValueToExternal = Internal.Lambda.toExternal
|
||||
and nameSpaceToTypeScriptBindings = (
|
||||
nameSpace: nameSpace,
|
||||
): ReducerInterface_ExternalExpressionValue.externalBindings => {
|
||||
|
@ -284,12 +302,7 @@ let rec toInternal = (ev: ExternalExpressionValue.t): t => {
|
|||
}
|
||||
and recordToInternal = v =>
|
||||
v->Js.Dict.entries->Belt.Map.String.fromArray->Belt.Map.String.map(e => toInternal(e))
|
||||
and lambdaValueToInternal = v => {
|
||||
let p = v.parameters
|
||||
let c = v.context->nameSpaceFromTypeScriptBindings
|
||||
let b = v.body
|
||||
{parameters: p, context: c, body: b}
|
||||
}
|
||||
and lambdaValueToInternal = Internal.Lambda.toInternal
|
||||
and nameSpaceFromTypeScriptBindings = (
|
||||
r: ReducerInterface_ExternalExpressionValue.externalBindings,
|
||||
): nameSpace =>
|
||||
|
|
Loading…
Reference in New Issue
Block a user