This is simpler because we don't "discover" functions to compile as we go, we just compile all the ones we can find, and functions have pre-defined exports. This is good and useful to us as we can now refer to functions in different modules by known indices, but it *does* make me wonder what we're going to do for compiling generic specializations. The previous technique was better for that sort of thing. This is all predicated on the idea that I want to have partially-compiled modules, which I can't really say why I want it. If I'm happy to just compile things cross module in the same kind of space then it's much easier to go back to the function key way of working.
79 lines
1.8 KiB
Text
79 lines
1.8 KiB
Text
fun test() -> f64 {
|
|
if true { "discarded"; 23 } else { 45 }
|
|
}
|
|
|
|
// @no-errors
|
|
// Here come some type probes!
|
|
// (type of the condition)
|
|
// @type: 27 bool
|
|
//
|
|
// (the discarded expression)
|
|
// @type: 34 string
|
|
//
|
|
// (the "then" clause)
|
|
// @type: 47 f64
|
|
// @type: 50 f64
|
|
//
|
|
// (the "else" clause)
|
|
// @type: 59 f64
|
|
// @type: 62 f64
|
|
//
|
|
// @concrete:
|
|
// | File
|
|
// | FunctionDecl
|
|
// | Fun:'"fun"'
|
|
// | Identifier:'"test"'
|
|
// | ParamList
|
|
// | LeftParen:'"("'
|
|
// | RightParen:'")"'
|
|
// | ReturnType
|
|
// | Arrow:'"->"'
|
|
// | TypeExpression
|
|
// | TypeIdentifier
|
|
// | Identifier:'"f64"'
|
|
// | Block
|
|
// | LeftBrace:'"{"'
|
|
// | IfStatement
|
|
// | ConditionalExpression
|
|
// | If:'"if"'
|
|
// | LiteralExpression
|
|
// | True:'"true"'
|
|
// | Block
|
|
// | LeftBrace:'"{"'
|
|
// | ExpressionStatement
|
|
// | LiteralExpression
|
|
// | String:'"\"discarded\""'
|
|
// | Semicolon:'";"'
|
|
// | ExpressionStatement
|
|
// | LiteralExpression
|
|
// | Number:'"23"'
|
|
// | RightBrace:'"}"'
|
|
// | Else:'"else"'
|
|
// | Block
|
|
// | LeftBrace:'"{"'
|
|
// | ExpressionStatement
|
|
// | LiteralExpression
|
|
// | Number:'"45"'
|
|
// | RightBrace:'"}"'
|
|
// | RightBrace:'"}"'
|
|
//
|
|
// @compiles-to:
|
|
// | function test (0 args, 0 locals):
|
|
// | strings (1):
|
|
// | 0: "discarded"
|
|
// | code (8):
|
|
// | 0: PushTrue
|
|
// | 1: JumpFalse(6)
|
|
// | 2: PushString(0)
|
|
// | 3: Discard
|
|
// | 4: PushFloat(23.0)
|
|
// | 5: Jump(7)
|
|
// | 6: PushFloat(45.0)
|
|
// | 7: Return
|
|
// | function << module >> (0 args, 0 locals):
|
|
// | strings (0):
|
|
// | code (2):
|
|
// | 0: PushNothing
|
|
// | 1: Return
|
|
// |
|
|
// @eval: Float(23.0)
|