|
|
1.1 root 1: /*ident "@(#)ctrans:src/repr.c 1.1.2.7" */
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("!" ,NOT);
89: new_op("~" ,COMPL);
90: new_op("++",INCR);
91: new_op("--",DECR);
92: new_op("*" ,MUL);
93: new_op("&" ,AND);
94: new_op("&" ,ADDROF);
95: new_op("&" ,G_ADDROF);
96: new_op("/" ,DIV);
97: new_op("%" ,MOD);
98: new_op("+" ,PLUS);
99: new_op("+" ,UPLUS);
100: new_op("-" ,MINUS);
101: new_op("-" ,UMINUS);
102: new_op("<<",LS);
103: new_op(">>",RS);
104: new_op("<" ,LT);
105: new_op(">" ,GT);
106: new_op("<=",LE);
107: new_op(">=",GE);
108: new_op("==",EQ);
109: new_op("!=",NE);
110: new_op("^" ,ER);
111: new_op("|" ,OR);
112: new_op("&&",ANDAND);
113: new_op("||",OROR);
114: new_op("?:" ,QUEST);
115: // new_op(":" ,COLON);
116: new_op("=" ,ASSIGN);
117: new_op("," ,CM);
118: new_op("," ,G_CM);
119:
120: new_op(";" ,SM);
121: new_op("{" ,LC);
122: new_op("}" ,RC);
123: new_op("(" ,LP);
124: new_op(")" ,RP);
125: new_op("[" ,LB);
126: new_op("]" ,RB);
127:
128: new_op("+=",ASPLUS);
129: new_op("-=",ASMINUS);
130: new_op("*=",ASMUL);
131: new_op("/=",ASDIV);
132: new_op("%=",ASMOD);
133: new_op("&=",ASAND);
134: new_op("|=",ASOR);
135: new_op("^=",ASER);
136: new_op(">>=",ASRS);
137: new_op("<<=",ASLS);
138:
139: // new_op("sizeof",SIZEOF);
140: // new_op("new",NEW);
141: // new_op("delete",DELETE);
142:
143: new_op("0" ,ZERO);
144: new_op("[]" ,DEREF);
145: new_op("expression list", ELIST);
146: new_op("()", CALL);
147: new_op("generated function call",G_CALL);
148: new_op("inline function call",ICALL);
149: new_op("cast",CAST);
150: new_op("inline argument",ANAME);
151: new_op(".*",MEMPTR);
152:
153: new_op("class", COBJ);
154: new_op("enum", EOBJ);
155: new_op("union", ANON);
156:
157: new_op("function",FCT);
158: new_op("pointer",PTR);
159: new_op("reference",RPTR);
160: new_op("array",VEC);
161: new_op("identifier",ID);
162: new_op("name",NAME);
163: new_op("...",ELLIPSIS);
164: new_op("::",MEM);
165: new_op("type name",TYPE);
166: new_op("{}",BLOCK);
167: new_op("pair",PAIR);
168: new_op("declaration",DCL);
169: new_op("character constant",CCON);
170: new_op("integer constant",ICON);
171: new_op("float constant",FCON);
172: new_op("integer value",IVAL);
173: new_op("string",STRING);
174: new_op("label",LABEL);
175: new_op("'class', 'struct', or 'union'",AGGR);
176: new_op(" argument",ARG);
177: new_op(" empty expression",DUMMY);
178: new_op(" ::new",GNEW);
179: new_op(" constructor call",VALUE);
180: new_op(" ::delete",GDELETE);
181: new_op(ansi_opt?" long double":" double",LDOUBLE);
182: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.