|
|
1.1 root 1: /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
2:
3: /*
4: $Header: b1com.c,v 1.4 85/08/22 16:48:13 timo Exp $
5: */
6:
7: /************************************************************************/
8: /* B compounds */
9: /* plus Hows Funs and other odd types that don't fit anywhere else */
10: /* */
11: /* A compound is modelled as a sequence of len values, its fields. */
12: /* */
13: /************************************************************************/
14:
15: #include "b.h"
16: #include "b1obj.h"
17: #include "b2nod.h"
18:
19: /* NODES */
20:
21: Visible typenode nodetype(v) parsetree v; {
22: return Is_parsetree(v) ? Nodetype(v) : Nonode;
23: }
24:
25: Hidden value
26: mk_ptn(type, len) /* make parsetree node */
27: typenode type;
28: intlet len;
29: {
30: parsetree v= (parsetree) grab_ptn((len<<8) | type);
31: *Branch(v, len)= *Branch(v, len+1)= NilTree;
32: return v;
33: }
34:
35: Visible parsetree
36: node1(type)
37: typenode type;
38: {
39: return mk_ptn(type, 0);
40: }
41:
42: Visible parsetree
43: node2(type, a1)
44: typenode type; value a1;
45: {
46: parsetree v= mk_ptn(type, 1); value *p= Ats(v);
47: *p++= a1;
48: return v;
49: }
50:
51: Visible parsetree
52: node3(type, a1, a2)
53: typenode type; value a1, a2;
54: {
55: parsetree v= mk_ptn(type, 2); value *p= Ats(v);
56: *p++= a1; *p++= a2;
57: return v;
58: }
59:
60: Visible parsetree
61: node4(type, a1, a2, a3)
62: typenode type; value a1, a2, a3;
63: {
64: parsetree v= mk_ptn(type, 3); value *p= Ats(v);
65: *p++= a1; *p++= a2; *p++= a3;
66: return v;
67: }
68:
69: Visible parsetree
70: node5(type, a1, a2, a3, a4)
71: typenode type; value a1, a2, a3, a4;
72: {
73: parsetree v= mk_ptn(type, 4); value *p= Ats(v);
74: *p++= a1; *p++= a2; *p++= a3; *p++= a4;
75: return v;
76: }
77:
78: Visible parsetree
79: node6(type, a1, a2, a3, a4,a5)
80: typenode type; value a1, a2, a3, a4, a5;
81: {
82: parsetree v= mk_ptn(type, 5); value *p= Ats(v);
83: *p++= a1; *p++= a2; *p++= a3; *p++= a4; *p++= a5;
84: return v;
85: }
86:
87: Visible parsetree
88: node8(type, a1, a2, a3, a4, a5, a6, a7)
89: typenode type; value a1, a2, a3, a4, a5, a6, a7;
90: {
91: parsetree v= mk_ptn(type, 7); value *p= Ats(v);
92: *p++= a1; *p++= a2; *p++= a3; *p++= a4; *p++= a5; *p++= a6; *p++= a7;
93: return v;
94: }
95:
96: Visible parsetree
97: node9(type, a1, a2, a3, a4, a5, a6, a7, a8)
98: typenode type; value a1, a2, a3, a4, a5, a6, a7, a8;
99: {
100: parsetree v= mk_ptn(type, 8); value *p= Ats(v);
101: *p++= a1; *p++= a2; *p++= a3; *p++= a4; *p++= a5; *p++= a6;
102: *p++= a7; *p++= a8;
103: return v;
104: }
105:
106: /* OTHER TYPES */
107:
108: Visible loc
109: mk_simploc(id, en)
110: basidf id; env en;
111: {
112: loc l= grab_sim();
113: (*Ats(l))= copy(id); (*(Ats(l)+1))= (value) en;
114: return l;
115: }
116:
117: Visible loc
118: mk_trimloc(R, B, C)
119: loc R; value B, C;
120: {
121: loc l= grab_tri(); trimloc *ll= (trimloc *)Ats(l);
122: ll->R= copy(R); ll->B= copy(B); ll->C= copy(C);
123: return l;
124: }
125:
126: Visible loc
127: mk_tbseloc(R, K)
128: loc R; value K;
129: {
130: loc l= grab_tse(); tbseloc *ll= (tbseloc *)Ats(l);
131: ll->R= copy(R); ll->K= copy(K);
132: return l;
133: }
134:
135: Visible fun
136: mk_fun(adic, pre, unit, filed)
137: literal adic; intlet pre; parsetree unit; bool filed;
138: {
139: fun f= grab_fun(); funprd *ff= (funprd *)Ats(f);
140: ff->adic= adic; ff->pre= pre; ff->unit= unit;
141: ff->unparsed= Yes; ff->filed= filed;
142: ff->code= NilTree;
143: return f;
144: }
145:
146: Visible prd
147: mk_prd(adic, pre, unit, filed)
148: literal adic; intlet pre; parsetree unit; bool filed;
149: {
150: prd p= grab_prd(); funprd *pp= (funprd *)Ats(p);
151: pp->adic= adic; pp->pre= pre; pp->unit= unit;
152: pp->unparsed= Yes; pp->filed= filed;
153: pp->code= NilTree;
154: return p;
155: }
156:
157: Visible value
158: mk_how(unit, filed)
159: parsetree unit; bool filed;
160: {
161: value h= grab_how(); how *hh= (how *)Ats(h);
162: hh->unit= unit; hh->unparsed= Yes; hh->filed= filed;
163: hh->code= NilTree;
164: return h;
165: }
166:
167: Visible value
168: mk_ref(rp)
169: parsetree rp;
170: {
171: value r= grab_ref();
172: *Ats(r)= copy(rp);
173: return r;
174: }
175:
176: Visible value
177: mk_per(v)
178: value v;
179: {
180: value p= grab_per();
181: *Ats(p)= copy(v);
182: return p;
183: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.