Explorar el 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 hace 2 días
padre
commit
5703b27527
Se han modificado 2 ficheros con 912 adiciones y 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. *)

La diferencia del archivo ha sido suprimido porque es demasiado grande
+ 904 - 900
compiler/src/M2.lst


Algunos archivos no se mostraron porque demasiados archivos cambiaron en este cambio