Explorar o código

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 hai 2 días
pai
achega
5703b27527
Modificáronse 2 ficheiros con 912 adicións e 904 borrados
  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. *)

A diferenza do arquivo foi suprimida porque é demasiado grande
+ 904 - 900
compiler/src/M2.lst


Algúns arquivos non se mostraron porque demasiados arquivos cambiaron neste cambio