MODULE M3CWordProcs; (***************************************************************************) (* Copyright (C) Olivetti 1989 *) (* All Rights reserved *) (* *) (* Use and copy of this software and preparation of derivative works based *) (* upon this software are permitted to any person, provided this same *) (* copyright notice and the following Olivetti warranty disclaimer are *) (* included in any copy of the software or any modification thereof or *) (* derivative work therefrom made by any person. *) (* *) (* This software is made available AS IS and Olivetti disclaims all *) (* warranties with respect to this software, whether expressed or implied *) (* under any law, including all implied warranties of merchantibility and *) (* fitness for any purpose. In no event shall Olivetti be liable for any *) (* damages whatsoever resulting from loss of use, data or profits or *) (* otherwise arising out of or in connection with the use or performance *) (* of this software. *) (***************************************************************************) IMPORT Text, HashText; IMPORT M3AST_AS; IMPORT M3AST_AS_F, M3AST_TM_F; IMPORT M3CId, M3Assert, M3CExpsMisc; PROCEDURE Enter(table: HashText.Table; t: Text.T; w: T) RAISES {}= VAR id: HashText.Id; BEGIN M3Assert.Check(HashText.Enter(table, t, id)); VAR new := NEW(REF T); BEGIN new^ := w; HashText.Associate(table_g, id, new); END; END Enter; PROCEDURE Initialize(): HashText.Table RAISES {}= VAR result := HashText.New(64); BEGIN Enter(result, "Plus", T.Plus); Enter(result, "Times", T.Times); Enter(result, "Minus", T.Minus); Enter(result, "Divide", T.Divide); Enter(result, "Mod", T.Mod); Enter(result, "LT", T.LT); Enter(result, "LE", T.LE); Enter(result, "GT", T.GT); Enter(result, "GE", T.GE); Enter(result, "And", T.And); Enter(result, "Or", T.Or); Enter(result, "Xor", T.Xor); Enter(result, "Not", T.Not); Enter(result, "Shift", T.Shift); Enter(result, "Rotate", T.Rotate); Enter(result, "Extract", T.Extract); Enter(result, "Insert", T.Insert); RETURN result; END Initialize; VAR table_g := Initialize(); word_g: M3CId.T := NIL; PROCEDURE IsWordCall(call: M3AST_AS.Call; VAR t: T): BOOLEAN RAISES {}= VAR defId: M3AST_AS.DEF_ID; BEGIN IF M3CExpsMisc.IsId(call.as_callexp, defId) AND ISTYPE(defId, M3AST_AS.Proc_id) THEN VAR hId: HashText.Id; BEGIN IF word_g = NIL THEN word_g := M3CId.Enter("Word") END; IF defId.tmp_unit_id.lx_symrep = word_g THEN IF HashText.Lookup(table_g, M3CId.ToText(defId.lx_symrep), hId) THEN t := NARROW(HashText.Value(table_g, hId), REF T)^; RETURN TRUE; ELSE RETURN FALSE; END; (* if *) ELSE RETURN FALSE; END; (* if *) END; ELSE RETURN FALSE; END; (* if *) END IsWordCall; PROCEDURE ArgCount(t: T): CARDINAL RAISES {}= BEGIN CASE t OF | T.Plus => RETURN 2; | T.Times => RETURN 2; | T.Minus => RETURN 2; | T.Divide => RETURN 2; | T.Mod => RETURN 2; | T.LT => RETURN 2; | T.LE => RETURN 2; | T.GT => RETURN 2; | T.GE => RETURN 2; | T.And => RETURN 2; | T.Or => RETURN 2; | T.Xor => RETURN 2; | T.Not => RETURN 1; | T.Shift => RETURN 2; | T.Rotate => RETURN 2; | T.Extract => RETURN 3; | T.Insert => RETURN 4; END; END ArgCount; BEGIN END M3CWordProcs.