}
if aa == .Resize || aa == .Free {
- if data.first == old {
- data.first = data.first.next;
-
- } else {
+ if old.prev {
old.prev.next = old.next;
+ } else {
+ data.first = old.next;
+ }
+
+ if old.next {
old.next.prev = old.prev;
}
}
use runtime.info;
callw, call := io.string_builder();
defer io.buffer_stream_free(call);
- defer delete(cast(rawptr) call);
+ defer cfree(call);
param_num := 0;
for method_info.parameter_types {
s.count == 0 || s.data == null;
}
+index_of :: #match #local {}
+
+#overload
index_of :: (s: str, c: u8) -> i32 {
for s.count {
if s[it] == c do return it;
return -1;
}
+#overload
+index_of :: (s: str, substr: str) -> i32 {
+ while i := 0; i < s.count {
+ start := i;
+ while j := 0; j < substr.count {
+ if s[i + j] != substr[j] {
+ i += j + 1;
+ continue continue;
+ }
+
+ j += 1;
+ }
+
+ return start;
+ }
+
+ return -1;
+}
+
last_index_of :: (s: str, c: u8) -> i32 {
for range.{s.count, 0, -1} {
if s[it] == c do return it;
// character occurs at the very beginning or end of
// the string, or if it does not occur at all.
//
+bisect :: #match #local {}
+
+#overload
bisect :: (s: str, c: u8) -> (str, str) {
index := index_of(s, c);
if index == -1 {
return s[0 .. index], s[index+1 .. s.length];
}
+#overload
+bisect :: (s: str, substr: str) -> (str, str) {
+ index := index_of(s, substr);
+ if index == -1 {
+ return s, "";
+ }
+
+ return s[0 .. index], s[index+1 .. s.length];
+}
+
return ((ovm_value_t) {0});
}
+
+
+void ovm_print_stack_trace(ovm_engine_t *engine, ovm_state_t *state, ovm_program_t *program) {
+ int i = 0;
+ bh_arr_rev_each(ovm_stack_frame_t, frame, state->stack_frames) {
+ ovm_func_t *func = frame->func;
+ printf("[%03d] %s\n", i++, func->name);
+ }
+}
+