version out there in a packaged format.
Additions:
+* Macros and paste-able code blocks
* overloaded procedures can have polymorphic and overloaded procedures as overloads. This makes them MUCH more powerful.
* types are not required on struct members that have default values. This is still very experimental so there are some
noticable bugs with it. You can always specify the type explicitly if you have issues.
}
// Semi-useful shortcut for adding something to an array.
-#operator << macro (arr: [..] $T, v: T) do array.push(^arr, v);
+#operator << macro (arr: [..] $T, v: T) do (package core.array).push(^arr, v);
insert :: (arr: ^[..] $T, idx: u32, x: T) -> bool {
if !ensure_capacity(arr, arr.count + 1) do return false;
}
}
+#operator << macro (b: Bucket_Array($T), elem: T) do (package core.bucket_array).push(^b, elem);
+
pop :: (use b: ^Bucket_Array($T)) {
last_bucket := ^buckets[buckets.count - 1];
last_bucket.count -= 1;
}
// Give you a pointer to the bucket data via 'it'.
-for_each :: macro (b: Bucket_Array($T), $body: Code) {
+for_each :: macro (b: Bucket_Array($T), body: Code) {
for ^bucket: b.buckets {
for bucket_index: bucket.count {
it := ^bucket.data[bucket_index];
formatting.minimum_width = ~~digits;
}
+ case #char "}" {
+ arg := va[vararg_index];
+ vararg_index += 1;
+ print_any(^output, formatting, arg);
+
+ break break;
+ }
+
case #default do break break;
}
}
continue;
}
- arg := va[vararg_index];
- vararg_index += 1;
- print_any(^output, formatting, arg);
-
continue;
}
}
buffer_append :: (use buffer: ^String_Buffer, end: str) -> bool {
- if count + end.count == capacity do return false;
+ if count + end.count > capacity do return false;
for i: end.count {
data[i + count] = end[i];
typedef enum BlockRule {
Block_Rule_New_Scope = BH_BIT(1),
- Block_Rule_New_Binding_Scope = BH_BIT(2), // Unused
- Block_Rule_Clear_Defer = BH_BIT(3),
+ Block_Rule_Clear_Defer = BH_BIT(2),
- Block_Rule_Normal = Block_Rule_New_Scope | Block_Rule_New_Binding_Scope | Block_Rule_Clear_Defer,
- Block_Rule_Macro = Block_Rule_New_Scope | Block_Rule_New_Binding_Scope,
+ Block_Rule_Normal = Block_Rule_New_Scope | Block_Rule_Clear_Defer,
+ Block_Rule_Macro = Block_Rule_New_Scope,
Block_Rule_Code_Block = Block_Rule_New_Scope,
} BlockRule;
}
#add_match json.encode, (w: ^io.Writer, v: Vector2) -> json.Encoding_Error {
- io.write_format(w, "{\"x\":%f,\"y\":%f}", v.x, v.y);
+ io.write_format(w, "{{\"x\":{},\"y\":{}}}", v.x, v.y);
return .None;
}
\ No newline at end of file
ib := io.read_byte(reader);
switch cast(u32) ib {
- case 0x00 do instr.code = .unreachable;
- case 0x01 do instr.code = .nop;
+ case 0x00 { instr.code = .unreachable; }
+ case 0x01 { instr.code = .nop; }
case 0x02 { instr.code = .block; block_depth += 1; parse_after = .Block_Type; }
case 0x03 { instr.code = .loop; block_depth += 1; parse_after = .Block_Type; }
case 0x04 { instr.code = .if_; block_depth += 1; parse_after = .Block_Type; }
AstNode* cloned_block = ast_clone(context.ast_alloc, code_block->code);
cloned_block->next = insert->next;
-
- /*if (cloned_block->kind == Ast_Kind_Block) {
- AstNode* next = insert->next;
- insert->next = (AstNode *) ((AstBlock *) cloned_block)->body;
-
- AstNode* last_stmt = insert->next;
- while (last_stmt->next != NULL) last_stmt = last_stmt->next;
- last_stmt->next = next;
-
- } else {
- */
- *(AstNode **) pinsert = cloned_block;
- //}
+ *(AstNode **) pinsert = cloned_block;
insert->flags |= Ast_Flag_Has_Been_Checked;
AstPolyProc* pp = (AstPolyProc *) macro->body;
bh_table_each_start(AstSolidifiedFunction, pp->concrete_funcs);
- if (value.func == template)
+ if (value.func == template) {
scope_include(argument_scope, value.poly_scope, call->token->pos);
+ break;
+ }
bh_table_each_end;
}
use package core
main :: (args: [] cstr) {
-
ba := bucket_array.make(i32, 4);
- for i: 24 {
- bucket_array.push(^ba, i);
- }
+ for i: 24 do ba << i;
sum := 0;
bucket_array.for_each(ba, #code {