소스 검색

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 1 주 전
부모
커밋
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


이 변경점에서 너무 많은 파일들이 변경되어 몇몇 파일들은 표시되지 않았습니다.