File: Loophole.m3 Last Modified On Tue May 3 16:36:31 PDT 1994 By kalsow Modified On Sat Dec 8 00:57:40 1990 By muller
MODULE; IMPORT CallExpr, Expr, ExprRep, Type, Procedure, CastExpr; IMPORT Int, Module, TypeExpr, Error; VAR Z: CallExpr.MethodList; PROCEDURE Loophole TypeOf (ce: CallExpr.T): Type.T = VAR t: Type.T := Int.T; BEGIN IF TypeExpr.Split (ce.args[1], t) THEN (*ok*) END; RETURN t; END TypeOf; PROCEDURECheck (ce: CallExpr.T; VAR cs: Expr.CheckState) = VAR t: Type.T; BEGIN IF NOT TypeExpr.Split (ce.args[1], t) THEN Error.Msg ("LOOPHOLE: second argument must be a type"); t := Int.T; END; ce.args[0] := CastExpr.New (ce.args[0], t); IF Module.IsSafe () THEN Error.Msg ("LOOPHOLE: unsafe operation") END; Expr.TypeCheck (ce.args[0], cs); ce.type := t; END Check; PROCEDURENeedsAddress (ce: CallExpr.T) = BEGIN Expr.NeedsAddress (ce.args[0]); END NeedsAddress; PROCEDUREPrep (ce: CallExpr.T) = BEGIN Expr.Prep (ce.args[0]); END Prep; PROCEDURECompile (ce: CallExpr.T) = BEGIN Expr.Compile (ce.args[0]); END Compile; PROCEDUREPrepLV (ce: CallExpr.T; traced: BOOLEAN) = BEGIN Expr.PrepLValue (ce.args[0], traced); END PrepLV; PROCEDURECompileLV (ce: CallExpr.T; traced: BOOLEAN) = BEGIN Expr.CompileLValue (ce.args[0], traced); END CompileLV; PROCEDUREIsWritable (ce: CallExpr.T; lhs: BOOLEAN): BOOLEAN = BEGIN RETURN Expr.IsWritable (ce.args[0], lhs); END IsWritable; PROCEDUREIsDesignator (ce: CallExpr.T; <*UNUSED*> lhs: BOOLEAN): BOOLEAN = BEGIN RETURN Expr.IsDesignator (ce.args[0]); END IsDesignator; PROCEDURENoteWrites (ce: CallExpr.T) = BEGIN Expr.NoteWrite (ce.args[0]); END NoteWrites; PROCEDUREInitialize () = BEGIN Z := CallExpr.NewMethodList (2, 2, TRUE, FALSE, TRUE, NIL, TypeOf, NeedsAddress, Check, Prep, Compile, PrepLV, CompileLV, CallExpr.PrepNoBranch, CallExpr.NoBranch, CallExpr.NoValue, (*fold*) CallExpr.NoBounds, IsWritable, IsDesignator, NoteWrites); Procedure.Define ("LOOPHOLE", Z, TRUE); END Initialize; BEGIN END Loophole.