"configuration": {
"type": "cppdbg",
"request": "launch",
- "program": "/mnt/c/dev/onyx/bin/onyx",
- "args": ["-VVV", "test/basic"],
+ "program": "${workspaceFolder}/bin/onyx",
+ "args": ["-VVV", "tmp/a"],
"stopAtEntry": true,
- "cwd": "/mnt/c/dev/onyx-imgui",
+ "cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
[ ] Aliasing in many cases does not work. For example:
- arr.data[idx] = x;
SomeNamespace :: struct {
foo :: () { ... }
bar :: ...
SN.foo()
}
+
+List of things to change:
+[ ] Currently, there is no way to use the initialized members of a structure without using a struct literal.
+ There should be a initialize intrinsic procedure that takes a pointer to anything and initializes it.
+ For example:
+
+ initialize :: (x: ^$T) -> void #intrinsic ---
+
+ Foo :: struct {
+ x := 1;
+ y : f32;
+ }
+
+ x : Foo;
+ initialize(^x);
+
+ // x.x = 1
+ // x.y = <uninitialized>
+
+[ ] Anonymous struct, enum and array literals.
if (node_is_type((AstNode *) node)) return 0;
+ if (node->kind == Ast_Kind_Struct_Literal && node->type_node == NULL) {
+ node->type = type;
+
+ add_entities_for_node(NULL, (AstNode *) node, NULL, NULL);
+ return 1;
+ }
+
if (node->kind == Ast_Kind_Polymorphic_Proc) {
AstFunction* func = polymorphic_proc_lookup((AstPolyProc *) node, PPLM_By_Function_Type, type, node->token);
if (func == NULL) return 0;
return Check_Error;
}
- if (binop->right->type == NULL) {
- // nocheckin
- // onyx_report_error(binop->token->pos,
- // "Unable to resolve type for symbol '%b'.",
- // binop->right->token->text, binop->right->token->length);
- return Check_Error;
- }
-
if (binop->operation == Binary_Op_Assign) {
// NOTE: Raw assignment
if (binop->left->type == NULL) {
resolve_expression_type(binop->right);
+ if (binop->right->type == NULL) {
+ onyx_report_error(binop->token->pos, "Could not resolve type of right hand side to infer.");
+ return Check_Error;
+ }
+
if (binop->right->type->kind == Type_Kind_Compound) {
AstCompound* lhs = (AstCompound *) binop->left;
assert(lhs->kind == Ast_Kind_Compound);
return Check_Error;
}
+ // CLEANUP: This seems like it should be here. But I don't know where
+ // or what the right place is for it.
+ // if (binop->right->type == NULL) {
+ // onyx_report_error(binop->right->token->pos, "Unable to resolve type for this expression.");
+ // return Check_Error;
+ // }
+
binop->type = &basic_types[Basic_Kind_Void];
return Check_Success;
}
CheckStatus check_struct_literal(AstStructLiteral* sl) {
- if (!node_is_type((AstNode *) sl->stnode)) {
- onyx_report_error(sl->token->pos, "Struct type is not a type.");
- return Check_Error;
- }
+ if (sl->type == NULL) {
+ if (sl->stnode == NULL) return Check_Success;
- fill_in_type((AstTyped *) sl);
- if (sl->type == NULL) return Check_Error;
+ if (!node_is_type((AstNode *) sl->stnode)) {
+ onyx_report_error(sl->token->pos, "Type used for struct literal is not a type.");
+ return Check_Error;
+ }
+
+ fill_in_type((AstTyped *) sl);
+ if (sl->type == NULL) return Check_Error;
+ }
if (!type_is_structlike_strict(sl->type)) {
onyx_report_error(sl->token->pos, "Type is not a constructable using a struct literal.");
break;
}
}
-}
\ No newline at end of file
+}
break;
}
+ case '.': {
+ if (parse_possible_struct_literal(parser, NULL, &retval)) return retval;
+ if (parse_possible_array_literal(parser, NULL, &retval)) return retval;
+ goto no_match;
+ }
+
case Token_Type_Tilde_Tilde: {
AstUnaryOp* ac_node = make_node(AstUnaryOp, Ast_Kind_Unary_Op);
ac_node->operation = Unary_Op_Auto_Cast;
break;
}
- onyx_report_error(parser->curr->pos, "invalid directive in expression.");
+ onyx_report_error(parser->curr->pos, "Invalid directive in expression.");
return NULL;
}
default:
- onyx_report_error(parser->curr->pos, "unexpected token '%s'.", token_name(parser->curr->type));
+ no_match:
+ onyx_report_error(parser->curr->pos, "Unexpected token '%s'.", token_name(parser->curr->type));
return NULL;
}
SYMRES(type, (AstType **) &sl->stnode);
sl->type_node = (AstType *) sl->stnode;
- while (sl->type_node->kind == Ast_Kind_Type_Alias)
+ while (sl->type_node && sl->type_node->kind == Ast_Kind_Type_Alias)
sl->type_node = ((AstTypeAlias *) sl->type_node)->to;
SYMRES(arguments, &sl->args);
assert(idx < bh_arr_length(args->values));
- if (args->values[idx] != NULL) {
+ if (args->values[idx] != NULL && args->values[idx] != named_value->value) {
if (err_msg) *err_msg = bh_aprintf(global_scratch_allocator, "Multiple values given for parameter named '%s'.", named_value->token->text);
token_toggle_end(named_value->token);
return 0;
*dest = 0;
return total_len;
-}
\ No newline at end of file
+}