You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In the ASL transpiler, it is common to check the type of a value before acting on it.
For example, when adding two values, we check to see if they are both numbers, both string and then coerce whichever the algorithm says to do.
When we have literal values, we know their type and can act accordingly, but when we have jsonPath (references) we cannot assume their types.
If we add typeHint to the ASLGraph.JsonPath object and then populate it when it we produce JsonPath objects, we could avoid runtime checks.
Example:
`a ${b}`+1
TemplateExpr(StirngLiteral("a "), Ident(b)) => Pass(States.Format('a {}', $.b)) => { jsonPath: heap1.str }
BinaryOp({ jsonPath: heap1.str }, NumberLiteral(1), '+')
=> Check if left is a string or number
=> if number => Pass(States.MathAdd($heap1.str, 1)
=> if string => Pass(States.Format('{}1', $heap1.str))
If we the TemplateExpr logic instead returns { jsonPath: "heap1.str", typeHint: "String" }, we can now do
In the ASL transpiler, it is common to check the type of a value before acting on it.
For example, when adding two values, we check to see if they are both numbers, both string and then coerce whichever the algorithm says to do.
When we have literal values, we know their type and can act accordingly, but when we have jsonPath (references) we cannot assume their types.
If we add
typeHint
to theASLGraph.JsonPath
object and then populate it when it we produce JsonPath objects, we could avoid runtime checks.Example:
If we the
TemplateExpr
logic instead returns{ jsonPath: "heap1.str", typeHint: "String" }
, we can now doThe text was updated successfully, but these errors were encountered: