(* Copyright (C) 1989, Digital Equipment Corporation *) (* All rights reserved. *) (* See the file COPYRIGHT for a full description. *) (* File: Dispose.m3 *) (* Last Modified On Tue Mar 20 03:08:05 1990 By muller *) (* Modified On Tue Jan 16 15:04:24 1990 By kalsow *) MODULE Dispose; IMPORT CallExpr, Expr, Type, Procedure, Void, Emit; IMPORT Address, Refany, Module, Error; IMPORT ObjectRef, ObjectAdr, Temp; VAR Z: CallExpr.MethodList; PROCEDURE Bind (<*UNUSED*> proc: Expr.T; <*UNUSED*> args: Expr.List): Type.T = BEGIN RETURN Void.T; END Bind; PROCEDURE Check (<*UNUSED*> proc: Expr.T; VAR args: Expr.List) = VAR t: Type.T; BEGIN t := Expr.TypeOf (args[0]); IF Module.IsSafe () THEN Error.Msg ("DISPOSE: unsafe operation") END; IF ( NOT Type.IsSubtype (t, Refany.T)) AND ( NOT Type.IsSubtype (t, Address.T)) THEN Error.Msg ("DISPOSE: must be applied to a reference type"); ELSIF Type.IsEqual (t, Refany.T) OR Type.IsEqual (t, Address.T) OR Type.IsEqual (t, ObjectRef.T) OR Type.IsEqual (t, ObjectAdr.T) THEN Error.Msg ("DISPOSE: must be applied to a fixed reference type"); END; END Check; PROCEDURE Compile (<*UNUSED*> proc: Expr.T; args: Expr.List): Temp.T = VAR t: Type.T; e: Expr.T; x: Temp.T; BEGIN e := args[0]; t := Type.Base (Expr.TypeOf (e)); IF Type.IsTraced (t) THEN IF Expr.IsDesignator (e) THEN x := Expr.CompileLValue (e); Emit.OpT ("TVDISPOSE(& @);\n", x); ELSE x := Expr.Compile (e); Emit.OpT ("TDISPOSE(@);\n", x); END; ELSE (* untrace ref *) IF Expr.IsDesignator (e) THEN x := Expr.CompileLValue (e); Emit.OpT ("UVDISPOSE(& @);\n", x); ELSE x := Expr.Compile (e); Emit.OpT ("UDISPOSE(@);\n", x); END; END; Temp.Free (x); RETURN x; (*DUMMY*) END Compile; PROCEDURE Initialize () = BEGIN Z := CallExpr.NewMethodList (1, 1, FALSE, Bind, Check, Compile, CallExpr.NoValue, CallExpr.IsNever, (* writable *) CallExpr.IsNever(* designator *)); Procedure.Define ("DISPOSE", Z); END Initialize; BEGIN END Dispose.