Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
internal/core/runtime: expand runtime.Compile signature to accomodate…
… non-builtins Widen runtime.Compile signature to accomodate external interpreters that return more complex structures than a builtin. One example would be interpreters that fill in concrete data. A more immediate use case is for Wasm where we want the interpreter to be able to refer to other declarations, for example functions with arguments of types defined in another package. Also, when processing a field, an external interpreter often needs access to the struct that contains the field in order to resolve identifiers specified in the extern attribute at the correct scope. Add a parameter to runtime.Compile which represents this struct. Additionally, modify Interpreter to take a *Runtime argument in NewCompiler. This is needed because if the external interpreter needs to generate synthetic code, this code has to use the same runtime as the compiler. Change-Id: Ia28690f48122573364c420541f95edcf552449e6 Signed-off-by: Aram Hăvărneanu <aram@mgk.ro> Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1173962 Unity-Result: CUE porcuepine <cue.porcuepine@gmail.com> Reviewed-by: Marcel van Lohuizen <mpvl@gmail.com> TryBot-Result: CUEcueckoo <cueckoo@gmail.com>
- Loading branch information
Showing
4 changed files
with
85 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
-- cue.mod/modules.cue -- | ||
-- file1.cue -- | ||
@extern("test") | ||
|
||
package scopetest | ||
|
||
#Bar: float | ||
#Baz: { | ||
#Quux: string | ||
spam: eggs: bool | ||
} | ||
|
||
foo: _ @extern(int) | ||
bar: _ @extern(#Bar) | ||
baz: { | ||
quux: _ @extern(#Baz.#Quux) | ||
eggs: _ @extern(#Baz.spam.eggs) | ||
} | ||
-- out/extern -- | ||
{ | ||
foo: int | ||
bar: float | ||
baz: { | ||
quux: string | ||
eggs: bool | ||
} | ||
} |