From 7e3861fce218008b52b6ebcdc666dcd14d57fd3b Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Astor?= Date: Fri, 18 Dec 2020 02:24:21 +0100 Subject: [PATCH] :art: Indexed jumps --- ast | 2 +- include/env/context.h | 1 - include/env/env.h | 1 - tests/error/label_defined.gw | 4 ---- tests/error/label_defined_not_used.gw | 3 --- tests/error/label_not_defined1.gw | 2 -- tests/error/label_not_defined2.gw | 4 ---- tests/error/upper_label.gw | 3 --- tests/jump_index/break_idx0.gw | 5 +++++ tests/jump_index/break_idx1.gw | 5 +++++ tests/jump_index/break_idx_fail.gw | 5 +++++ tests/jump_index/break_many.gw | 7 +++++++ tests/tree/class_goto.gw | 6 ------ tests/tree/cpy_ast.gw | 2 -- tests/tree/goto.gw | 4 ---- 15 files changed, 23 insertions(+), 31 deletions(-) delete mode 100644 tests/error/label_defined.gw delete mode 100644 tests/error/label_defined_not_used.gw delete mode 100644 tests/error/label_not_defined1.gw delete mode 100644 tests/error/label_not_defined2.gw delete mode 100644 tests/error/upper_label.gw create mode 100644 tests/jump_index/break_idx0.gw create mode 100644 tests/jump_index/break_idx1.gw create mode 100644 tests/jump_index/break_idx_fail.gw create mode 100644 tests/jump_index/break_many.gw delete mode 100644 tests/tree/class_goto.gw delete mode 100644 tests/tree/goto.gw diff --git a/ast b/ast index 126d1ee5..b6efc837 160000 --- a/ast +++ b/ast @@ -1 +1 @@ -Subproject commit 126d1ee5c16fca467fddec3f463fc3d1865722ea +Subproject commit b6efc8376c611d9c86e662ad4c348b64baebd523 diff --git a/include/env/context.h b/include/env/context.h index 0fea1b74..ca74c197 100644 --- a/include/env/context.h +++ b/include/env/context.h @@ -5,7 +5,6 @@ struct Context_ { m_str name; Ast tree; Nspc nspc; - struct Map_ lbls; m_bool error; m_bool global; uint16_t ref; diff --git a/include/env/env.h b/include/env/env.h index 9d73be48..823ab45d 100644 --- a/include/env/env.h +++ b/include/env/env.h @@ -32,7 +32,6 @@ ANN void free_env(Env); ANN2(1,3) m_uint env_push(const Env, const Type, const Nspc); ANN static inline m_uint env_push_global(const Env env) { return env_push(env, NULL, env->global_nspc); } ANN void env_pop(const Env, const m_uint); -ANN Map env_label(const Env); ANN Type scan_type(const Env, const Type, Type_Decl*); ANN Value mk_class(const Env env, const Type base); ANN m_bool compat_func(const __restrict__ Func_Def, const __restrict__ Func_Def); diff --git a/tests/error/label_defined.gw b/tests/error/label_defined.gw deleted file mode 100644 index 51e6b434..00000000 --- a/tests/error/label_defined.gw +++ /dev/null @@ -1,4 +0,0 @@ -#! [contains] already defined - test: -test: -; diff --git a/tests/error/label_defined_not_used.gw b/tests/error/label_defined_not_used.gw deleted file mode 100644 index e308ad05..00000000 --- a/tests/error/label_defined_not_used.gw +++ /dev/null @@ -1,3 +0,0 @@ -#! [contains] defined but not used -test: -; diff --git a/tests/error/label_not_defined1.gw b/tests/error/label_not_defined1.gw deleted file mode 100644 index e552ce98..00000000 --- a/tests/error/label_not_defined1.gw +++ /dev/null @@ -1,2 +0,0 @@ -#! [contains] used but not defined -goto test; diff --git a/tests/error/label_not_defined2.gw b/tests/error/label_not_defined2.gw deleted file mode 100644 index 37db4849..00000000 --- a/tests/error/label_not_defined2.gw +++ /dev/null @@ -1,4 +0,0 @@ -#! [contains] used but not defined -goto here; -here: -goto test; diff --git a/tests/error/upper_label.gw b/tests/error/upper_label.gw deleted file mode 100644 index e4da9b19..00000000 --- a/tests/error/upper_label.gw +++ /dev/null @@ -1,3 +0,0 @@ -#! [contains] you are trying to use a upper label -end: -goto end; diff --git a/tests/jump_index/break_idx0.gw b/tests/jump_index/break_idx0.gw new file mode 100644 index 00000000..83aa3432 --- /dev/null +++ b/tests/jump_index/break_idx0.gw @@ -0,0 +1,5 @@ +var int i; +while(i < 2) { + <<< i++ >>>; + break 0; +} diff --git a/tests/jump_index/break_idx1.gw b/tests/jump_index/break_idx1.gw new file mode 100644 index 00000000..1cde9a6c --- /dev/null +++ b/tests/jump_index/break_idx1.gw @@ -0,0 +1,5 @@ +var int i; +while(i < 2) { + <<< i++ >>>; + break 1; +} diff --git a/tests/jump_index/break_idx_fail.gw b/tests/jump_index/break_idx_fail.gw new file mode 100644 index 00000000..e1cf2bf5 --- /dev/null +++ b/tests/jump_index/break_idx_fail.gw @@ -0,0 +1,5 @@ +var int i; +while(i < 2) { + <<< i++ >>>; + break 2; +} diff --git a/tests/jump_index/break_many.gw b/tests/jump_index/break_many.gw new file mode 100644 index 00000000..c72b74d5 --- /dev/null +++ b/tests/jump_index/break_many.gw @@ -0,0 +1,7 @@ +while(true) { + while(true) { + while(true) { + break 3; + } + } +} diff --git a/tests/tree/class_goto.gw b/tests/tree/class_goto.gw deleted file mode 100644 index 00e35eee..00000000 --- a/tests/tree/class_goto.gw +++ /dev/null @@ -1,6 +0,0 @@ -class C { - goto here; - here: - ; -} - diff --git a/tests/tree/cpy_ast.gw b/tests/tree/cpy_ast.gw index 3ffd53f7..39fd87fe 100644 --- a/tests/tree/cpy_ast.gw +++ b/tests/tree/cpy_ast.gw @@ -23,10 +23,8 @@ class C:[A] { } where var int b; enum { zero }; typedef int Int; - goto end; new Object; spork { <<< __func__ >>>; }; - end: while(0){ <<< __func__ >>>; } } diff --git a/tests/tree/goto.gw b/tests/tree/goto.gw deleted file mode 100644 index addb0be4..00000000 --- a/tests/tree/goto.gw +++ /dev/null @@ -1,4 +0,0 @@ -goto here; -here: -; - -- 2.43.0