Преглед изворни кода

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 дана
родитељ
комит
5703b27527
2 измењених фајлова са 912 додато и 904 уклоњено
  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. *)

Разлика између датотеке није приказан због своје велике величине
+ 904 - 900
compiler/src/M2.lst


Неке датотеке нису приказане због велике количине промена