From aad6f4f80e3196b052e96176ff412ddb7ceb7ef6 Mon Sep 17 00:00:00 2001 From: Vladimir Azarov Date: Mon, 11 Aug 2025 23:11:32 +0200 Subject: Mul/Div by constant transformation --- parser.fun | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'parser.fun') diff --git a/parser.fun b/parser.fun index a954a8e..a229425 100644 --- a/parser.fun +++ b/parser.fun @@ -235,6 +235,9 @@ functor Parser(structure Tree: TREE; structure P: PPC; in case t of remote_t id => resolve id + | array_t (n, elT) => array_t (n, resolveType elT) + | function_t (rt, args, variadic) => + function_t (resolveType rt, map resolveType args, variadic) | t => t end @@ -1511,7 +1514,7 @@ functor Parser(structure Tree: TREE; structure P: PPC; end and isLvalue (EA (_, _, lvalue, _)) = lvalue - and getT (EA (_, _, _, t)) = t + and getT (EA (_, _, _, t)) = resolveType t and getPos (EA (_, pos, _, _)) = pos and setT (EA (binop, pos, lvalue, _)) t = EA (binop, pos, lvalue, t) @@ -1703,7 +1706,7 @@ functor Parser(structure Tree: TREE; structure P: PPC; else P.error (getPos right) `"expression has a type incompatible with its sibling: " - `"(" Pctype leftT `", >" Pctype rightT `")" % + `"(" Pctype leftT `", >>" Pctype rightT `")" % else P.error (getPos left) `"expected value of an arithmetic type or a pointer" % @@ -2235,9 +2238,7 @@ functor Parser(structure Tree: TREE; structure P: PPC; and eval' (EA (e, pos, _, t)) = case e of Eid _ => P.error pos `"variable in constant expression" % - | Econst (_, Ninteger w) => - (printf `"eval num: " W w `": " Pctype t `"\n" %; - ER (w, t)) + | Econst (_, Ninteger w) => ER (w, t) | Econst _ => raise Unreachable | Estrlit _ => P.error pos `"string literal in constant expression" % | EmemberByV _ | EmemberByP _ => -- cgit v1.2.3