MODULE; IMPORT Text, TextRefTbl; IMPORT M3AST_AS; IMPORT M3AST_AS_F, M3AST_TM_F; IMPORT M3CId, M3Assert, M3CExpsMisc; PROCEDURE M3CWordProcs Enter (table: TextRefTbl.T; t: Text.T; w: T) RAISES {}= VAR new := NEW(REF T); BEGIN new^ := w; M3Assert.Check(NOT table.put(t, new)); END Enter; PROCEDUREInitialize (): TextRefTbl.T RAISES {}= VAR result := NEW(TextRefTbl.Default).init(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, "LeftShift", T.Shift); Enter(result, "RightShift", T.RightShift); Enter(result, "Rotate", T.Rotate); Enter(result, "LeftRotate", T.Rotate); Enter(result, "RightRotate", T.RightRotate); Enter(result, "Extract", T.Extract); Enter(result, "Insert", T.Insert); RETURN result; END Initialize; VAR table_g := Initialize(); word_g: M3CId.T := NIL; PROCEDUREIsWordCall (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: REFANY; BEGIN IF word_g = NIL THEN word_g := M3CId.Enter("Word") END; IF defId.tmp_unit_id.lx_symrep = word_g THEN IF table_g.get(M3CId.ToText(defId.lx_symrep), hId) THEN t := NARROW(hId, REF T)^; RETURN TRUE; ELSE RETURN FALSE; END; (* if *) ELSE RETURN FALSE; END; (* if *) END; ELSE RETURN FALSE; END; (* if *) END IsWordCall; PROCEDUREArgCount (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.RightShift => RETURN 2; | T.Rotate => RETURN 2; | T.RightRotate => RETURN 2; | T.Extract => RETURN 3; | T.Insert => RETURN 4; END; END ArgCount; BEGIN END M3CWordProcs.