|
|
1.1 root 1: /*ident "@(#)ctrans:src/repr.c 1.4" */
2: /**************************************************************************
3:
4: C++ source for cfront, the C++ compiler front-end
5: written in the computer science research center of Bell Labs
6:
7: Copyright (c) 1984 AT&T, Inc. All Rights Reserved
8: THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF AT&T, INC.
9:
10: repr.c:
11:
12: *****************************************************************************/
13:
14: #include "cfront.h"
15:
16: char* oper_name(TOK op)
17: /*
18: return the string representation of operator "op"
19: */
20: {
21: switch (op) {
22: default: error('i',"oper_name(%k)",op);
23: case GNEW:
24: case NEW: return "__nw";
25: case GDELETE:
26: case DELETE: return "__dl";
27: case MUL: return "__ml";
28: case DIV: return "__dv";
29: case MOD: return "__md";
30: case UPLUS:
31: case PLUS: return "__pl";
32: case MINUS:
33: case UMINUS: return "__mi";
34: case LS: return "__ls";
35: case RS: return "__rs";
36: case EQ: return "__eq";
37: case NE: return "__ne";
38: case LT: return "__lt";
39: case GT: return "__gt";
40: case LE: return "__le";
41: case GE: return "__ge";
42: case AND:
43: case ADDROF: return "__ad";
44: case OR: return "__or";
45: case ER: return "__er";
46: case ANDAND: return "__aa";
47: case OROR: return "__oo";
48: case NOT: return "__nt";
49: case COMPL: return "__co";
50: case INCR: return "__pp";
51: case DECR: return "__mm";
52: case CALL: return "__cl";
53: case DEREF: return "__vc";
54: case ASSIGN: return "__as";
55: case REF: return "__rf";
56: case ASPLUS: return "__apl";
57: case ASMINUS: return "__ami";
58: case ASMUL: return "__amu";
59: case ASDIV: return "__adv";
60: case ASMOD: return "__amd";
61: case ASLS: return "__als";
62: case ASRS: return "__ars";
63: case ASAND: return "__aad";
64: case ASOR: return "__aor";
65: case ASER: return "__aer";
66: case CTOR: return "__ct";
67: case DTOR: return "__dt";
68: // operator T "__op"<signature of T>
69: // case SIZEOF: return "sizeof";
70: case CM: return "__cm";
71: case REFMUL: return "__rm";
72: // library functions:
73: // "_vec_delete"
74: // "_vec_new"
75: // "_main"
76: }
77: }
78:
79: #define new_op(ss,v) keys[v]=ss
80:
81: void otbl_init()
82: /*
83: operator representation table
84: */
85: {
86: new_op("->",REF);
87: new_op("." ,DOT);
88: new_op(".* or ->*" ,REFMUL);
89: new_op("mdot" ,REFMUL);
90: new_op("!" ,NOT);
91: new_op("~" ,COMPL);
92: new_op("++",INCR);
93: new_op("--",DECR);
94: new_op("*" ,MUL);
95: new_op("&" ,AND);
96: new_op("&" ,ADDROF);
97: new_op("&" ,G_ADDROF);
98: new_op("/" ,DIV);
99: new_op("%" ,MOD);
100: new_op("+" ,PLUS);
101: new_op("+" ,UPLUS);
102: new_op("-" ,MINUS);
103: new_op("-" ,UMINUS);
104: new_op("<<",LS);
105: new_op(">>",RS);
106: new_op("<" ,LT);
107: new_op(">" ,GT);
108: new_op("<=",LE);
109: new_op(">=",GE);
110: new_op("==",EQ);
111: new_op("!=",NE);
112: new_op("^" ,ER);
113: new_op("|" ,OR);
114: new_op("&&",ANDAND);
115: new_op("||",OROR);
116: new_op("?:" ,QUEST);
117: // new_op(":" ,COLON);
118: new_op("=" ,ASSIGN);
119: new_op("," ,CM);
120: new_op("," ,G_CM);
121:
122: new_op(";" ,SM);
123: new_op("{" ,LC);
124: new_op("}" ,RC);
125: new_op("(" ,LP);
126: new_op(")" ,RP);
127: new_op("[" ,LB);
128: new_op("]" ,RB);
129:
130: new_op("+=",ASPLUS);
131: new_op("-=",ASMINUS);
132: new_op("*=",ASMUL);
133: new_op("/=",ASDIV);
134: new_op("%=",ASMOD);
135: new_op("&=",ASAND);
136: new_op("|=",ASOR);
137: new_op("^=",ASER);
138: new_op(">>=",ASRS);
139: new_op("<<=",ASLS);
140:
141: // new_op("sizeof",SIZEOF);
142: // new_op("new",NEW);
143: // new_op("delete",DELETE);
144:
145: new_op("0" ,ZERO);
146: new_op("[]" ,DEREF);
147: new_op("expression list", ELIST);
148: new_op("initializer list", ILIST);
149: new_op("static initializer", STAT_INIT);
150: new_op("()", CALL);
151: new_op("generated function call",G_CALL);
152: new_op("inline function call",ICALL);
153: new_op("cast",CAST);
154: new_op("inline argument",ANAME);
155: new_op("text",TEXT);
156: new_op(".*",MEMPTR);
157:
158: new_op("class type", COBJ);
159: new_op("enum type", EOBJ);
160: new_op("union", ANON);
161:
162: new_op("function",FCT);
163: new_op("pointer",PTR);
164: new_op("reference",RPTR);
165: new_op("array",VEC);
166: new_op("identifier",ID);
167: new_op("name",NAME);
168: new_op("...",ELLIPSIS);
169: new_op("::",MEM);
170: new_op("type name",TYPE);
171: new_op("tname",TNAME);
172: new_op("{}",BLOCK);
173: new_op("pair",PAIR);
174: new_op("declaration",DCL);
175: new_op("character constant",CCON);
176: new_op("integer constant",ICON);
177: new_op("float constant",FCON);
178: new_op("integer value",IVAL);
179: new_op("string",STRING);
180: new_op("label",LABEL);
181: new_op("'class', 'struct', or 'union'",AGGR);
182: new_op(" argument",ARG);
183: new_op(" empty expression",DUMMY);
184: new_op(" ::new",GNEW);
185: new_op(" constructor call",VALUE);
186: new_op(" ::delete",GDELETE);
187: new_op(ansi_opt?" long double":" double",LDOUBLE);
188: new_op(" typedef",NESTED); // did not want to introduce new TOKEN
189: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.