@@ -22,8 +22,8 @@ open Globals
22
22
open Setup
23
23
open Ord
24
24
25
- let rec exprBoolean out_chan stem (syms :shash ) op expr1 expr2 =
26
- op (exprConst out_chan stem syms expr1) (exprConst out_chan stem syms expr2)
25
+ let rec exprBoolean out_chan (syms :shash ) op expr1 expr2 =
26
+ op (exprConst out_chan syms expr1) (exprConst out_chan syms expr2)
27
27
28
28
and widthnum expbase (str :string ) =
29
29
let base = ref 10
@@ -66,54 +66,46 @@ and shash_chain_find (syms:shash) nam = match syms with
66
66
| Shash symr -> if Hashtbl. mem symr.syms nam then Hashtbl. find symr.syms nam else shash_chain_find symr.nxt nam
67
67
| EndShash -> failwith " Not found"
68
68
69
- and exprConst out_chan stem (syms :shash ) expr = Stack. push (stem, 67 , expr) stk; let rslt = ( match expr with
69
+ and exprConst out_chan (syms :shash ) expr = Stack. push (67 , expr) stk; let rslt = ( match expr with
70
70
| INT n -> n
71
71
| HEXNUM str -> snd(widthnum 16 str)
72
- | TRIPLE (TIMES, expr1 , expr2 ) -> (exprConst out_chan stem syms expr1) * (exprConst out_chan stem syms expr2)
73
- | TRIPLE (PLUS, expr1 , expr2 ) -> (exprConst out_chan stem syms expr1) + (exprConst out_chan stem syms expr2)
74
- | TRIPLE (MINUS, expr1 , expr2 ) -> (exprConst out_chan stem syms expr1) - (exprConst out_chan stem syms expr2)
75
- | TRIPLE (P_EQUAL, expr1 , expr2 ) -> if (exprBoolean out_chan stem syms (= )) expr1 expr2 then 1 else 0
76
- | TRIPLE (P_NOTEQUAL, expr1 , expr2 ) -> if (exprBoolean out_chan stem syms (<> )) expr1 expr2 then 1 else 0
77
- | TRIPLE (LESS, expr1 , expr2 ) -> if (exprBoolean out_chan stem syms (< )) expr1 expr2 then 1 else 0
78
- | TRIPLE (GREATER, expr1 , expr2 ) -> if (exprBoolean out_chan stem syms (> )) expr1 expr2 then 1 else 0
79
- | TRIPLE (P_LTE, expr1 , expr2 ) -> if (exprBoolean out_chan stem syms (< = )) expr1 expr2 then 1 else 0
80
- | TRIPLE (P_GTE, expr1 , expr2 ) -> if (exprBoolean out_chan stem syms (> = )) expr1 expr2 then 1 else 0
72
+ | TRIPLE (TIMES, expr1 , expr2 ) -> (exprConst out_chan syms expr1) * (exprConst out_chan syms expr2)
73
+ | TRIPLE (PLUS, expr1 , expr2 ) -> (exprConst out_chan syms expr1) + (exprConst out_chan syms expr2)
74
+ | TRIPLE (MINUS, expr1 , expr2 ) -> (exprConst out_chan syms expr1) - (exprConst out_chan syms expr2)
75
+ | TRIPLE (P_EQUAL, expr1 , expr2 ) -> if (exprBoolean out_chan syms (= )) expr1 expr2 then 1 else 0
76
+ | TRIPLE (P_NOTEQUAL, expr1 , expr2 ) -> if (exprBoolean out_chan syms (<> )) expr1 expr2 then 1 else 0
77
+ | TRIPLE (LESS, expr1 , expr2 ) -> if (exprBoolean out_chan syms (< )) expr1 expr2 then 1 else 0
78
+ | TRIPLE (GREATER, expr1 , expr2 ) -> if (exprBoolean out_chan syms (> )) expr1 expr2 then 1 else 0
79
+ | TRIPLE (P_LTE, expr1 , expr2 ) -> if (exprBoolean out_chan syms (< = )) expr1 expr2 then 1 else 0
80
+ | TRIPLE (P_GTE, expr1 , expr2 ) -> if (exprBoolean out_chan syms (> = )) expr1 expr2 then 1 else 0
81
81
| DOUBLE (CONCAT, TLIST [left ; right ]) -> Printf. fprintf (fst out_chan) " Concat expr not yet implemented, value 1 assumed\n " ; 1
82
82
83
- | ID id -> let pth = stem^ id in begin
84
- if shash_chain_mem syms pth == false then begin
85
- if shash_chain_mem syms id == false then begin
86
- (* unhandled out_chan 81 expr; *)
87
- Printf. fprintf (fst out_chan) " constant %s not declared, value 1 assumed\n " pth;
83
+ | ID id -> begin
84
+ if shash_chain_mem syms id == false then begin
85
+ Printf. fprintf (fst out_chan) " constant %s not declared, value 1 assumed\n " id;
88
86
1
89
87
end
90
- else
88
+ else
91
89
match (shash_chain_find syms id).sigattr with
92
- | Sigparam pexpr -> exprConst out_chan stem syms pexpr
90
+ | Sigparam pexpr -> exprConst out_chan syms pexpr
93
91
| Sigarray x -> Printf. fprintf (fst out_chan) " %s not a constant or for variable, value 1 assumed\n " id; 1
94
92
| _ -> unhandled out_chan 89 expr; 1
95
93
end
96
- else
97
- match (shash_chain_find syms pth).sigattr with
98
- | Sigparam pexpr -> exprConst out_chan stem syms pexpr
99
- | Sigarray x -> Printf. fprintf (fst out_chan) " %s not a constant or for variable, value 1 assumed\n " pth; 1
100
- | _ -> unhandled out_chan 95 expr; 1
101
- end
102
94
| TRIPLE (FUNCREF, ID id , TLIST args ) -> Printf. fprintf (fst out_chan) " %s is a function, value 1 assumed\n " id; 1
103
- | QUADRUPLE (PARTSEL, arg , INT hi , INT lo ) -> (exprConst out_chan stem syms arg) lsr lo
95
+ | QUADRUPLE (PARTSEL, arg , INT hi , INT lo ) -> (exprConst out_chan syms arg) lsr lo
104
96
| TRIPLE (P_SLEFT, INT 1 , ID id ) -> Printf. fprintf (fst out_chan) " Const expression 1<<%s is too complicated, value 1 assumed\n " id; 1
105
97
| _ -> unhandled out_chan 97 expr; 1 ) in
106
98
ignore(Stack. pop stk);
107
99
rslt
108
100
109
- let iwidth out_chan stem syms wid = match wid with
110
- | RANGE (expr1 , expr2 ) -> (exprConst out_chan stem syms expr1,exprConst out_chan stem syms expr2)
101
+ let iwidth out_chan syms wid = match wid with
102
+ | RANGE (expr1 , expr2 ) -> (exprConst out_chan syms expr1,exprConst out_chan syms expr2)
111
103
| UNKNOWN -> (0 ,0 )
112
104
| SCALAR -> (0 ,0 )
113
105
| EMPTY -> (0 ,0 )
114
106
| _ -> unhandled out_chan 56 wid; (- 1 ,- 1 )
115
107
116
- let maxwidth out_chan stem syms neww = let w = iwidth out_chan stem syms neww in
108
+ let maxwidth out_chan syms neww = let w = iwidth out_chan syms neww in
117
109
1 + (max (fst w) (snd w))
118
110
119
111
let show_set s = TokSet. iter (fun e -> Printf. printf " %s " (str_token e)) s;;
@@ -128,7 +120,7 @@ let show_chk_sig nam syma siga =
128
120
let show_sig_attr syms id s = match s.sigattr with
129
121
| Sigarray attrs -> (
130
122
match s.width with
131
- | RANGE range -> let (hi,lo) = iwidth (stderr,Format. err_formatter) " " syms s.width in
123
+ | RANGE range -> let (hi,lo) = iwidth (stderr,Format. err_formatter) syms s.width in
132
124
if not ((TokSet. mem IMPLICIT s.symattr)|| (TokSet. mem MEMORY s.symattr)) then
133
125
( try for i = hi downto lo do
134
126
show_chk_sig (id^ " [" ^ (string_of_int i)^ " ]" ) s.symattr attrs.(i)
0 commit comments