File: KeywordExpr.m3 Last modified on Fri Feb 24 16:43:45 PST 1995 by kalsow modified on Sat Dec 8 00:21:11 1990 by muller
MODULE; IMPORT M3, M3ID, Expr, ExprRep, Type, Target; TYPE P = Expr.T OBJECT expr : Expr.T; key : M3ID.T; OVERRIDES typeOf := TypeOf; check := Check; need_addr := NeedsAddress; prep := Prep; compile := Compile; prepLV := PrepLV; compileLV := CompileLV; prepBR := ExprRep.PrepNoBranch; compileBR := ExprRep.NoBranch; evaluate := Fold; isEqual := EqCheck; getBounds := Bounder; isWritable := IsWritable; isDesignator := IsDesignator; isZeroes := IsZeroes; genFPLiteral := ExprRep.NoFPLiteral; prepLiteral := PrepLiteral; genLiteral := GenLiteral; note_write := NoteWrites; END; PROCEDURE KeywordExpr New (key: M3ID.T; arg: Expr.T): Expr.T = VAR p: P; BEGIN p := NEW (P); ExprRep.Init (p); p.key := key; p.expr := arg; RETURN p; END New; PROCEDUREIs (e: Expr.T): BOOLEAN = BEGIN TYPECASE e OF | NULL => RETURN FALSE; | P => RETURN TRUE; ELSE RETURN FALSE; END; END Is; PROCEDURESplit (e: Expr.T; VAR key: M3ID.T; VAR value: Expr.T): BOOLEAN = BEGIN TYPECASE e OF | NULL => RETURN FALSE; | P(p) => key := p.key; value := p.expr; RETURN TRUE; ELSE RETURN FALSE; END; END Split; PROCEDURETypeOf (p: P): Type.T = BEGIN RETURN Expr.TypeOf (p.expr); END TypeOf; PROCEDURECheck (p: P; VAR cs: Expr.CheckState) = BEGIN Expr.TypeCheck (p.expr, cs); p.type := Expr.TypeOf (p.expr); END Check; PROCEDUREEqCheck (a: P; e: Expr.T; x: M3.EqAssumption): BOOLEAN = BEGIN TYPECASE e OF | NULL => RETURN FALSE; | P(b) => RETURN Expr.IsEqual (a.expr, b.expr, x); ELSE RETURN Expr.IsEqual (a.expr, e, x); END; END EqCheck; PROCEDURENeedsAddress (p: P) = BEGIN Expr.NeedsAddress (p.expr); END NeedsAddress; PROCEDUREPrep (p: P) = BEGIN Expr.Prep (p.expr); END Prep; PROCEDURECompile (p: P) = BEGIN Expr.Compile (p.expr); END Compile; PROCEDUREPrepLV (p: P; traced: BOOLEAN) = BEGIN Expr.PrepLValue (p.expr, traced); END PrepLV; PROCEDURECompileLV (p: P; traced: BOOLEAN) = BEGIN Expr.CompileLValue (p.expr, traced); END CompileLV; PROCEDUREBounder (p: P; VAR min, max: Target.Int) = BEGIN Expr.GetBounds (p.expr, min, max); END Bounder; PROCEDUREIsDesignator (p: P; <*UNUSED*> lhs: BOOLEAN): BOOLEAN = BEGIN RETURN Expr.IsDesignator (p.expr); END IsDesignator; PROCEDUREIsWritable (p: P; lhs: BOOLEAN): BOOLEAN = BEGIN RETURN Expr.IsWritable (p.expr, lhs); END IsWritable; PROCEDUREFold (p: P): Expr.T = BEGIN WITH e = Expr.ConstValue (p.expr) DO IF e = NIL THEN RETURN NIL ELSE p.expr := e; RETURN p; END; END; END Fold; PROCEDUREIsZeroes (p: P; <*UNUSED*> lhs: BOOLEAN): BOOLEAN = BEGIN RETURN Expr.IsZeroes (p.expr); END IsZeroes; PROCEDUREPrepLiteral (p: P; type: Type.T; is_const: BOOLEAN) = BEGIN Expr.PrepLiteral (p.expr, type, is_const); END PrepLiteral; PROCEDUREGenLiteral (p: P; offset: INTEGER; type: Type.T; is_const: BOOLEAN) = BEGIN Expr.GenLiteral (p.expr, offset, type, is_const); END GenLiteral; PROCEDURENoteWrites (p: P) = BEGIN Expr.NoteWrite (p.expr); END NoteWrites; BEGIN END KeywordExpr.