Przeglądaj źródła

resolve-check step 4a: store expression-node types (AST.SetTy)

The parser computes each expression's type (t) but never recorded it on
the AST node, so nothing could walk expressions.  SetTy is now called at
the four expression levels (Expr/SimExpr/Term/Fact) on the node each
produces.  This is the prerequisite for moving expression typing into
Check, and for Lower to read types instead of re-deriving them.

No behaviour change: suite 190/190; fixpoint OK (3,468,071 bytes).
Eric Streit 2 dni temu
rodzic
commit
5703b27527
2 zmienionych plików z 912 dodań i 904 usunięć
  1. 8 4
      compiler/src/M2.atg
  2. 904 900
      compiler/src/M2.lst

+ 8 - 4
compiler/src/M2.atg

@@ -2542,7 +2542,8 @@ PRODUCTIONS
               QbeGen.CopyOp("0", q)
             END;
             astCur := AST.MakeBin(AST.NkBinExpr, astOp, astA, astB); .) ]
-       (. IF NOT astMade THEN astCur := astA END; .) .
+       (. IF NOT astMade THEN astCur := astA END; .)
+           (. IF astCur # AST.NoNode THEN AST.SetTy(astCur, t) END; .) .
   Rel<VAR op: INTEGER>
     = "="                               (. op := SymTab.OpEq; .)
     | "#"                               (. op := SymTab.OpNeq1; .)
@@ -2654,7 +2655,8 @@ PRODUCTIONS
                 END
              ELSE QbeGen.CopyOp("0", q)
              END
-           END; .) } .
+           END; .) }
+           (. IF astCur # AST.NoNode THEN AST.SetTy(astCur, t) END; .) .
   AddOp<VAR op: INTEGER>
     = "+"                               (. op := SymTab.OpAdd; .)
     | "-"                               (. op := SymTab.OpSub; .)
@@ -2723,7 +2725,8 @@ PRODUCTIONS
               END
            ELSE QbeGen.CopyOp("0", q)
            END
-         END; .) } .
+         END; .) }
+           (. IF astCur # AST.NoNode THEN AST.SetTy(astCur, t) END; .) .
   MulOp<VAR op: INTEGER>
     = "*"                               (. op := SymTab.OpTimes; .)
     | "/"                               (. op := SymTab.OpSlash; .)
@@ -3229,7 +3232,8 @@ PRODUCTIONS
                                            astCur := AST.MakeUn(
                                              AST.NkUnary, AST.OpNot, astNot); .)
     )
-    (. IF NOT astIsLit THEN astCur := AST.NoNode END; .) .
+    (. IF NOT astIsLit THEN astCur := AST.NoNode END; .)
+           (. IF astCur # AST.NoNode THEN AST.SetTy(astCur, t) END; .) .
   (* Set literals are SET OF [0..255] (8 words); elements validated
      0..255 statically when foldable (222 otherwise), runtime trap
      for computed elements. Ranges always lower via SetRange. *)

Plik diff jest za duży
+ 904 - 900
compiler/src/M2.lst


Niektóre pliki nie zostały wyświetlone z powodu dużej ilości zmienionych plików