bind function calls
This commit is contained in:
parent
e3ef08839f
commit
7b080ff4c2
|
@ -34,17 +34,24 @@ let rec replaceSymbols = (expression: expression, bindings: ExpressionT.bindings
|
||||||
): ExpressionT.bindings =>
|
): ExpressionT.bindings =>
|
||||||
Belt.Map.String.set(bindings, "$parameters", ExpressionT.EParameters(parameters))
|
Belt.Map.String.set(bindings, "$parameters", ExpressionT.EParameters(parameters))
|
||||||
|
|
||||||
switch expression {
|
let answerBindingIfNotParameter = (aSymbol, defaultExpression, parameters, bindings) =>
|
||||||
| ExpressionT.EValue(EvSymbol(aSymbol)) => {
|
switch Js.Array2.some(parameters, a => a == aSymbol) {
|
||||||
let parameters = getParameters(bindings)
|
| true => defaultExpression->Ok // We cannot bind the parameters with global values
|
||||||
switch Js.Array2.some(parameters, a => a == aSymbol) {
|
|
||||||
| true => expression->Ok // We cannot bind the parameters with global values
|
|
||||||
| false =>
|
| false =>
|
||||||
switch bindings->Belt.Map.String.get(aSymbol) {
|
switch bindings->Belt.Map.String.get(aSymbol) {
|
||||||
| Some(boundExpression) => boundExpression->Ok
|
| Some(boundExpression) => boundExpression->Ok
|
||||||
| None => RESymbolNotFound(aSymbol)->Error
|
| None => RESymbolNotFound(aSymbol)->Error
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
switch expression {
|
||||||
|
| ExpressionT.EValue(EvSymbol(aSymbol)) => {
|
||||||
|
let parameters = getParameters(bindings)
|
||||||
|
answerBindingIfNotParameter(aSymbol, expression, parameters, bindings)
|
||||||
|
}
|
||||||
|
| ExpressionT.EValue(EvCall(aSymbol)) => {
|
||||||
|
let parameters = getParameters(bindings)
|
||||||
|
answerBindingIfNotParameter(aSymbol, expression, parameters, bindings)
|
||||||
}
|
}
|
||||||
| ExpressionT.EValue(_) => expression->Ok
|
| ExpressionT.EValue(_) => expression->Ok
|
||||||
| ExpressionT.EBindings(_) => expression->Ok
|
| ExpressionT.EBindings(_) => expression->Ok
|
||||||
|
|
Loading…
Reference in New Issue
Block a user