m3front/src/stmts/EvalStmt.m3


Copyright (C) 1994, Digital Equipment Corp.
File: EvalStmt.m3

MODULE EvalStmt;

IMPORT CG, Expr, Token, Scanner, Stmt, StmtRep, Error, Type;

TYPE
  P = Stmt.T OBJECT
        e       : Expr.T;
      OVERRIDES
        check       := Check;
	compile     := Compile;
        outcomes    := GetOutcome;
      END;

PROCEDURE Parse (): Stmt.T =
  VAR p: P;
  BEGIN
    p := NEW (P);
    StmtRep.Init (p);
    Scanner.Match (Token.T.tEVAL);
    p.e := Expr.Parse ();
    RETURN p;
  END Parse;

PROCEDURE Check (p: P;  VAR cs: Stmt.CheckState) =
  BEGIN
    Expr.TypeCheck (p.e, cs);
    IF (Expr.TypeOf (p.e) = NIL) THEN
      Error.Msg ("expression doesn\'t have a value");
    END;
  END Check;

PROCEDURE Compile (p: P): Stmt.Outcomes =
  BEGIN
    Expr.Prep (p.e);
    Expr.Compile (p.e);
    CG.Discard (Type.CGType (Expr.TypeOf (p.e)));
    RETURN Stmt.Outcomes {Stmt.Outcome.FallThrough};
  END Compile;

PROCEDURE GetOutcome (<*UNUSED*> p: P): Stmt.Outcomes =
  BEGIN
    RETURN Stmt.Outcomes {Stmt.Outcome.FallThrough};
  END GetOutcome;

BEGIN
END EvalStmt.