ONYX_AST_NODE_KIND_LITERAL,
ONYX_AST_NODE_KIND_CAST,
ONYX_AST_NODE_KIND_PARAM,
+ ONYX_AST_NODE_KIND_ARGUMENT,
ONYX_AST_NODE_KIND_CALL,
ONYX_AST_NODE_KIND_ASSIGNMENT,
ONYX_AST_NODE_KIND_RETURN,
-print :: foreign "host" "print" proc (value i32) ---
+print :: foreign "host" "print" proc (value i32) ---
+print_float :: foreign "host" "print" proc (value f32) ---
+print_if :: foreign "host" "print" proc (i i32, f f32) ---
foo :: proc -> i32 {
return 10 as i32;
res := diff_square((4 + 5) as i32, (2 + 3) as i32);
res = res + foo();
// res should be 66
- return res;
+ return res * (0 - 1);
+}
+
+export float_test :: proc -> f32 {
+ return (1.2f + 5.3f);
}
export main :: proc {
- output := do_stuff() * (0 - 2);
+ output := do_stuff();
+
print(output);
+ print_float(float_test());
+
+ print_if(output, float_test());
}
"LITERAL",
"CAST",
"PARAM",
+ "ARGUMENT",
"CALL",
"ASSIGN",
"RETURN",
OnyxAstNode** prev = &call_node->arguments;
OnyxAstNode* curr = NULL;
while (parser->curr_token->type != TOKEN_TYPE_CLOSE_PAREN) {
- curr = parse_expression(parser);
+ curr = onyx_ast_node_new(parser->allocator, ONYX_AST_NODE_KIND_ARGUMENT);
+ curr->left = parse_expression(parser);
+ curr->type = curr->left->type;
if (curr != NULL && curr->kind != ONYX_AST_NODE_KIND_ERROR) {
*prev = curr;
{
OnyxAstNodeCall* call = &expr->as_call;
forll (OnyxAstNode, arg, call->arguments, next) {
- process_expression(mod, func, arg);
+ process_expression(mod, func, arg->left);
}
i32 func_idx = (i32) bh_imap_get(&mod->func_map, (u64) call->callee);
if (foreign->import->kind == ONYX_AST_NODE_KIND_FUNCDEF) {
i32 type_idx = generate_type_idx(module, &foreign->import->as_funcdef);
+ bh_imap_put(&module->func_map, (u64) &foreign->import->as_funcdef, module->next_import_func_idx++);
+
WasmImport import = {
.kind = WASM_FOREIGN_FUNCTION,
.idx = type_idx,