arr.count += new_arr.count;
while i := arr.count; i > idx {
- arr.data[i] = arr.data[i - 1];
+ arr.data[i] = arr.data[i - new_arr.count];
i -= 1;
}
-free :: (s: str, allocator := context.allocator) do raw_free(allocator, s.data);
+free :: #match #locked {
+ (s: str, allocator := context.allocator) { raw_free(allocator, s.data); },
+ (s: &dyn_str) { core.array.free(s); },
+}
alloc_copy :: (original: str, allocator := context.allocator) -> str {
if original.count == 0 do return .{};
(defconst onyx-typenames
'("u64" "u32" "u16" "u8"
"i64" "i32" "i16" "i8"
- "f32" "f64" "str" "cstr" "any" "type_expr"
+ "f32" "f64" "str" "cstr" "dyn_str" "any" "type_expr"
"bool" "void" "rawptr"
"i8x16" "i16x8" "i32x4" "i64x2"
"f32x4" "f64x2" "v128"))
- match: '\b(package|struct|interface|use|where|global|enum|if|elseif|else|for|while|do|break|continue|fallthrough|return|cast|sizeof|alignof|typeof|defer|switch|case|macro)\b'
scope: keyword.control.onyx
- - match: '\b(bool|void|i8|u8|i16|u16|i32|u32|i64|u64|f32|f64|rawptr|str|cstr|range|type_expr|any)\b'
+ - match: '\b(bool|void|i8|u8|i16|u16|i32|u32|i64|u64|f32|f64|rawptr|str|cstr|dyn_str|range|type_expr|any)\b'
scope: storage.type
- match: '\b(i8x16|i16x8|i32x4|i64x2|f32x4|f64x2|v128)\b'
syn keyword onyxType i64 u64
syn keyword onyxType f32 f64
syn keyword onyxType rawptr
-syn keyword onyxType str cstr
+syn keyword onyxType str cstr dyn_str
syn keyword onyxType i8x16 i16x8 i32x4 i64x2 f32x4 f64x2 v128
syn keyword onyxType type_expr any
</dict>
<dict>
<key>match</key>
- <string>\b(str|cstr|type_expr|any)\b</string>
+ <string>\b(str|cstr|dyn_str|type_expr|any)\b</string>
<key>name</key>
<string>storage.type.onyx</string>
</dict>
--- /dev/null
+{
+Hello{}World
+Hello{}World
+}{hello}{
+}3R{
--- /dev/null
+use core
+
+main :: () {
+ printf("{\n");
+ printf("Hello{");
+ printf("}World\n");
+ printf("Hello{{}}World\n");
+ printf("}{hello}{\n", 123);
+ printf("}{b32}{\n", 123);
+}
\ No newline at end of file
--- /dev/null
+use core
+
+
+main :: () {
+ output: dyn_str;
+ defer string.free(&output);
+
+ string.append(&output, "Hello");
+ string.append(&output, "World");
+ string.append(&output, "!");
+
+ string.insert(&output, 5, ", ");
+
+ println(output);
+}
\ No newline at end of file