Skip to content

Commit 7f1d01b

Browse files
committed
added: #error in statements; Set.from
1 parent 1367a45 commit 7f1d01b

File tree

4 files changed

+24
-5
lines changed

4 files changed

+24
-5
lines changed

compiler/src/library_main.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -487,7 +487,7 @@ onyx_pump_t onyx_pump(onyx_context_t *ctx) {
487487
// cycle detection algorithm must be used.
488488
//
489489
if (!changed) {
490-
if (!context->watermarked_node) {
490+
if (!context->watermarked_node || context->watermarked_node->macro_attempts < ent->macro_attempts) {
491491
context->watermarked_node = ent;
492492
context->highest_watermark = bh_max(context->highest_watermark, ent->macro_attempts);
493493
}
@@ -506,10 +506,6 @@ onyx_pump_t onyx_pump(onyx_context_t *ctx) {
506506
context->cycle_almost_detected += 1;
507507
}
508508
}
509-
else if (context->watermarked_node->macro_attempts < ent->macro_attempts) {
510-
context->watermarked_node = ent;
511-
context->highest_watermark = bh_max(context->highest_watermark, ent->macro_attempts);
512-
}
513509
} else {
514510
context->watermarked_node = NULL;
515511
context->cycle_almost_detected = 0;

compiler/src/parser.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2143,6 +2143,15 @@ static AstNode* parse_statement(OnyxParser* parser) {
21432143
break;
21442144
}
21452145

2146+
if (parse_possible_directive(parser, "error")) {
2147+
AstDirectiveError *error = make_node(AstDirectiveError, Ast_Kind_Directive_Error);
2148+
error->token = parser->curr - 2;
2149+
error->error_msg = expect_token(parser, Token_Type_Literal_String);
2150+
2151+
ENTITY_SUBMIT(error);
2152+
break;
2153+
}
2154+
21462155
if (next_tokens_are(parser, 2, '#', Token_Type_Symbol)) {
21472156
retval = (AstNode *) parse_factor(parser);
21482157
break;

core/container/iter.onyx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@ Iterator.generator_no_copy :: generator_no_copy
5252
Iterator.comp :: comp
5353
Iterator.prod :: prod
5454

55+
Iterator.single :: single
56+
Iterator.const :: const
57+
5558

5659

5760
/// The standard function to convert something to an Iterator.

core/container/set.onyx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,17 @@ Set.make :: ($T: type_expr, allocator := context.allocator) -> Set(T) {
3636
return set;
3737
}
3838

39+
Set.from :: (arr: [] $T, allocator := context.allocator) -> Set(T) {
40+
set : Set(T)
41+
Set.init(&set, allocator=allocator)
42+
43+
for a in arr {
44+
Set.insert(&set, a)
45+
}
46+
47+
return set
48+
}
49+
3950
#overload
4051
builtin.__make_overload :: macro (x: &Set, allocator: Allocator) =>
4152
#this_package.Set.make(x.Elem_Type, allocator = allocator);

0 commit comments

Comments
 (0)