summaryrefslogtreecommitdiff
path: root/tnslc/tnslc.tnsl
diff options
context:
space:
mode:
authorKyle Gunger <kgunger12@gmail.com>2023-08-05 17:48:15 -0400
committerKyle Gunger <kgunger12@gmail.com>2023-08-05 17:48:15 -0400
commitadc97807daa20efd16fcc9ef82f773bdd23f63bd (patch)
tree80a248a90dedf3ebce92cd576cf0db70e359959c /tnslc/tnslc.tnsl
parent6ee6814c269aa5a5c2ea8e031db3a335df2c1f2d (diff)
Fix issue with cf block conditionals
Diffstat (limited to 'tnslc/tnslc.tnsl')
-rw-r--r--tnslc/tnslc.tnsl50
1 files changed, 35 insertions, 15 deletions
diff --git a/tnslc/tnslc.tnsl b/tnslc/tnslc.tnsl
index 7c31fa8..a518cc0 100644
--- a/tnslc/tnslc.tnsl
+++ b/tnslc/tnslc.tnsl
@@ -3417,20 +3417,17 @@
;; else
;cf = cf.new_sub_cf(tok`{cur`}.data)
;/
- ;; else if (tok`{cur`}.cmp("(") || tok`{cur`}.cmp("["))
+ ;; else if (tok`{cur`}.cmp("("))
;int psl = find_closing(tok, cur)
- ;int tmp = statement_list(tok, cur`, psl, current, ~outro, mov, ~cf)
- /; if (tmp < 0 && condition !< 0)
- ;tmp = condition
+ ;int tmp = statement_list(tok, cur`, psl, current, out, mov, ~cf)
+
+ /; if (tmp !< 0 && condition < 0 && cf.cf_type("if") == false)
+ ;condition = tmp
;Type t = {1, "bool", "_bool", {}, {}}
;eval_value(tok, ~tmp, ~outro, mov, current, ~cf, t, true)
- ;; else
- ;condition = tmp
;/
- /; if (tok`{cur`}.cmp("(") && condition !< 0)
- ;out`.add(outro)
- ;outro = {"", "", ""}
+ /; if (tmp !< 0)
/; if (cf.cf_type("if"))
;out`.csec = string_join( {
out`.csec,
@@ -3445,6 +3442,20 @@
}, "")
;/
;/
+
+ ;cur` = psl
+ ;; else if (tok`{cur`}.cmp("["))
+ ;CompData t_outro = {"", "", ""}
+ ;int psl = find_closing(tok, cur)
+ ;int tmp = statement_list(tok, cur`, psl, current, ~t_outro, mov, ~cf)
+
+ /; if (tmp < 0 && condition !< 0)
+ ;t_outro.add(outro)
+ ;outro = t_outro
+ ;; else
+ ;outro = t_outro
+ ;/
+
;cur` = psl
;; else
;break
@@ -3613,12 +3624,21 @@
;out`.add(outro)
;/
- ;out`.csec = string_join( {
- out`.csec,
- "\ttest al, al\n",
- "\tjnz ", cf.scope_start_label(), "\n",
- cf.scope_end_label(), ":\n"
- }, "")
+ /; if (condition !< 0)
+ ;out`.csec = string_join( {
+ out`.csec,
+ "\ttest al, al\n",
+ "\tjnz ", cf.scope_start_label(), "\n",
+ cf.scope_end_label(), ":\n"
+ }, "")
+ ;; else
+ ;out`.csec = string_join( {
+ out`.csec,
+ "\tjmp ", cf.scope_start_label(), "\n",
+ cf.scope_end_label(), ":\n"
+ }, "")
+ ;/
+
;; else
;out`.csec = string_join( {
out`.csec,