NODE(PolyProc) \
NODE(PolyQuery) \
\
- NODE(Note) \
NODE(CallSite) \
\
NODE(CodeBlock) \
Ast_Kind_Zero_Value,
- Ast_Kind_Note,
-
Ast_Kind_Count
} AstKind;
b32 created_export_entity : 1;
};
-struct AstNote {
- AstNode_base;
-};
struct AstCallSite {
AstTyped_base;
Entity_Type_Unknown,
Entity_Type_Error,
- Entity_Type_Note,
Entity_Type_Load_Path,
Entity_Type_Load_File,
Entity_Type_Binding,
b32 fun_output : 1;
b32 print_function_mappings : 1;
b32 print_static_if_results : 1;
- b32 print_notes : 1;
b32 no_colors : 1;
b32 no_file_contents : 1;
Token_Type_Literal_True,
Token_Type_Literal_False,
- Token_Type_Note,
-
Token_Type_Count,
} TokenType;
"FOREIGN BLOCK",
"ZERO VALUE",
-
- "NOTE",
-
+
"AST_NODE_KIND_COUNT",
};
const char* entity_type_strings[Entity_Type_Count] = {
"Unknown",
"Error",
- "Note",
"Add to Load Path",
"Load File",
"Binding (Declaration)",
else if (type->Basic.flags & Basic_Flag_Float) {
if (type->Basic.size == 4) {
- // TODO(Brendan): Check these boundary conditions
if (bh_abs(num->value.l) >= (1 << 23)) {
onyx_report_error(num->token->pos, Error_Critical, "Integer '%l' does not fit in 32-bit float exactly.", num->value.l);
return 0;
return 1;
}
if (type->Basic.size == 8) {
- // TODO(Brendan): Check these boundary conditions
if (bh_abs(num->value.l) >= (1ull << 52)) {
onyx_report_error(num->token->pos, Error_Critical, "Integer '%l' does not fit in 64-bit float exactly.", num->value.l);
return 0;
StructMember containing_member = smem;
// TODO: The following code is not right after it loops, but this should never loop
- // due to a check in types.c line 947.
+ // due to a check in types.c line 947. When nested use-through-pointers are allowed,
+ // thing will have to be reconsidered.
AstTyped **dest = &field->expr;
do {
assert(type_lookup_member_by_idx((*dest)->type, containing_member.use_through_pointer_index, &containing_member));
Type *arg_type = type_build_from_ast(context.ast_alloc, s_node->polymorphic_argument_types[i]);
if (arg_type == NULL) YIELD(s_node->polymorphic_argument_types[i]->token->pos, "Waiting to build type for polymorph argument.");
- // CLEANUP: This might be wrong...
- if (s_node->polymorphic_arguments[i].value) {
- TYPE_CHECK(&s_node->polymorphic_arguments[i].value, arg_type) {
- ERROR_(s_node->polymorphic_arguments[i].value->token->pos, "Expected value of type %s, got %s.",
- type_get_name(arg_type),
- type_get_name(s_node->polymorphic_arguments[i].value->type));
- }
+ //
+ // This check should always be false, but it handles
+ // the case where somewhere a type was expected, but
+ // not enough values were provided. This is checked
+ // elsewhere when instantiating a polymorphic sturucture.
+ if (i >= bh_arr_length(s_node->polymorphic_arguments)
+ || !s_node->polymorphic_arguments[i].value) continue;
+
+
+ TYPE_CHECK(&s_node->polymorphic_arguments[i].value, arg_type) {
+ ERROR_(s_node->polymorphic_arguments[i].value->token->pos, "Expected value of type %s, got %s.",
+ type_get_name(arg_type),
+ type_get_name(s_node->polymorphic_arguments[i].value->type));
}
}
}
break;
}
- case Ast_Kind_Note: {
- ent.type = Entity_Type_Note;
- ent.expr = (AstTyped *) node;
- ent.state = Entity_State_Code_Gen;
- ENTITY_INSERT(ent);
- break;
- }
-
case Ast_Kind_Interface: {
ent.type = Entity_Type_Interface;
ent.interface = (AstInterface *) node;
"true",
"false",
- "NOTE",
-
"TOKEN_TYPE_COUNT"
};
goto token_parsed;
}
- /*if (*tokenizer->curr == '@') {
- INCREMENT_CURR_TOKEN(tokenizer);
- u32 len = 2;
- while (char_is_alphanum(*(tokenizer->curr + 1)) || *(tokenizer->curr + 1) == '_') {
- len++;
- INCREMENT_CURR_TOKEN(tokenizer);
- }
-
- tk.type = Token_Type_Note;
- tk.length = len;
- INCREMENT_CURR_TOKEN(tokenizer);
- goto token_parsed;
- }*/
-
// Number literal
if (char_is_num(*tokenizer->curr)
|| (*(tokenizer->curr) == '.' && char_is_num(*(tokenizer->curr + 1)))) {
"Developer flags:\n"
"\t--print-function-mappings Prints a mapping from WASM function index to source location.\n"
"\t--print-static-if-results Prints the conditional result of each #if statement. Useful for debugging.\n"
- "\t--print-notes Prints the location of notes throughout the loaded code.\n"
"\t--no-colors Disables colors in the error message.\n"
"\t--no-file-contents Disables '#file_contents' for security.\n"
"\n";
else if (!strcmp(argv[i], "--print-static-if-results")) {
options.print_static_if_results = 1;
}
- else if (!strcmp(argv[i], "--print-notes")) {
- options.print_notes = 1;
- }
else if (!strcmp(argv[i], "--no-colors")) {
options.no_colors = 1;
}
parser->prev = parser->curr;
// :LinearTokenDependent
parser->curr++;
- while (parser->curr->type == Token_Type_Comment || parser->curr->type == Token_Type_Note) {
- // if (parser->curr->type == Token_Type_Note) {
- // AstNote* note = make_node(AstNode, Ast_Kind_Note);
- // note->token = parser->curr;
- // ENTITY_SUBMIT(note);
- // }
-
+ while (parser->curr->type == Token_Type_Comment) {
parser->curr++;
}
}
i32 matched = 1;
- // BUG: This does not take into consideration comments and notes that can occur between any tokens.
+ // BUG: This does not take into consideration comments that can occur between any tokens.
fori (i, 0, n) {
TokenType expected_type = va_arg(va, TokenType);
if (peek_token(i)->type != expected_type) {
void onyx_parse(OnyxParser *parser) {
// NOTE: Skip comments at the beginning of the file
- while (consume_token_if_next(parser, Token_Type_Comment) || consume_token_if_next(parser, Token_Type_Note));
+ while (consume_token_if_next(parser, Token_Type_Comment));
parser->package = parse_file_package(parser);
parser->file_scope = scope_create(parser->allocator, parser->package->private_scope, parser->tokenizer->tokens[0].pos);
case Entity_Type_Function: emit_function(module, ent->function); break;
case Entity_Type_Global: emit_global(module, ent->global); break;
- // Cleanup: Maybe these should be printed elsewhere?
- // Also, they should be sorted? Or have that ability?
- case Entity_Type_Note: {
- if (!context.options->print_notes) break;
-
- AstNote* note = (AstNote *) ent->expr;
- OnyxFilePos pos = note->token->pos;
-
- bh_printf("Note: %b %s:%d:%d\n", note->token->text, note->token->length, pos.filename, pos.line, pos.column);
-
- break;
- }
-
default: break;
}