source: liacs/coco/assignment4/IOperator.h@ 62

Last change on this file since 62 was 2, checked in by Rick van der Zwet, 15 years ago

Initial import of data of old repository ('data') worth keeping (e.g. tracking
means of URL access statistics)

File size: 4.5 KB
Line 
1/*
2 * IOperator.h - Declaration of the IOperator enum type
3 *
4 * Part of the assignment of the Compiler Construction course
5 * LIACS, Leiden University
6 */
7
8#ifndef _IOPERATOR_H_
9#define _IOPERATOR_H_
10
11// Operator of an IStatement
12// Several conventions are used. First, operators that deal with integers have
13// a _I suffix. Operators that deal with reals have a _R suffix. When there is
14// no real-type equivalent for a certain operator (e.g., the modulo operator),
15// no suffix is added.
16// Second, each IOperator has a signature, which is specified between brackets,
17// e.g. [1-r] or [12r]. This signature indicates which of the operand1,
18// operand2 and result fields have to be filled in. For each (class of)
19// IOperators, a more elaborate description about what has to be filled in is
20// given below.
21
22typedef enum __ioperator {
23 /* Meta */
24 IOP_UNKNOWN, // [---] (yet) Unknown operation
25
26 /* Subprogram entry
27 operand1 should refer to the corresponding Symbol_Subprogram object */
28 IOP_SUBPROG, // [1--] Subprogram
29
30 /* Subprogram return
31 operand1 should contain the value that has to be returned */
32 IOP_RETURN, // [---] Procedure return
33 IOP_RETURN_I, // [1--] Integer function return
34 IOP_RETURN_R, // [1--] Real function return
35
36 /* Parameter passing (caller side)
37 operand1 actual parameter value or Symbol object */
38 IOP_PARAM_I, // [1--] Integer parameter
39 IOP_PARAM_R, // [1--] Real parameter
40
41 /* Subprogram call
42 operand1 should refer to the corresponding Symbol object
43 result receives the result of a function call */
44 IOP_PROCCALL, // [1--] Procedure call
45 IOP_FUNCCALL, // [1-r] Function call
46
47 /* Label
48 operand1 should refer to the corresponding Symbol object */
49 IOP_LABEL, // [1--] Label
50
51 /* Goto
52 operand1 should refer to the corresponding Symbol object; note that
53 the Symbol pointed to should be of type ST_LABEL */
54 IOP_GOTO, // [1--] Goto a label
55
56 /* Variable assignment (copy value)
57 operand1 the source operand
58 result the destination operand (pointer to a Symbol object) */
59 IOP_ASSIGN_I, // [1-r] Integer assignment
60 IOP_ASSIGN_R, // [1-r] Real assignment
61
62 /* Branching
63 operand1 the first source operand
64 operand2 the second source operand
65 result should refer to the target Symbol object; note that
66 the Symbol pointed to must be of type ST_LABEL */
67 IOP_BEQ_I, // [12r] = operator for integers
68 IOP_BLT_I, // [12r] < operator for integers
69 IOP_BGT_I, // [12r] > operator for integers
70 IOP_BLE_I, // [12r] <= operator for integers
71 IOP_BGE_I, // [12r] >= operator for integers
72 IOP_BNE_I, // [12r] <> operator for integers
73 IOP_BEQ_R, // [12r] = operator for reals
74 IOP_BLT_R, // [12r] < operator for reals
75 IOP_BGT_R, // [12r] > operator for reals
76 IOP_BLE_R, // [12r] <= operator for reals
77 IOP_BGE_R, // [12r] >= operator for reals
78 IOP_BNE_R, // [12r] <> operator for reals
79
80 /* Binary arithmetic operators
81 operand1 the first source operand
82 operand2 the second source operand
83 result the destination operand (refers to a Symbol object) */
84 IOP_ADD_I, // [12r] Integer addition
85 IOP_ADD_R, // [12r] Real addition
86 IOP_SUB_I, // [12r] Integer substraction
87 IOP_SUB_R, // [12r] Real substraction
88 IOP_MUL_I, // [12r] Integer multiplication
89 IOP_MUL_R, // [12r] Real multiplication
90 IOP_DIV_I, // [12r] Integer division
91 IOP_DIV_R, // [12r] Real division
92 IOP_MOD, // [12r] Modulo
93 IOP_AND, // [12r] AND operation
94 IOP_OR, // [12r] OR operation
95
96 /* Unary arithmetic operators
97 operand1 the source operand
98 result the destination operand (refers to a Symbol object) */
99 IOP_NOT, // [1-r] NOT operation
100 IOP_UNARY_MINUS_I, // [1-r] Unary integer minus
101 IOP_UNARY_MINUS_R, // [1-r] Unary real minus
102
103 /* Coercion
104 operand1 the source operand
105 result the destination operand (refers to a Symbol object) */
106 IOP_INT_TO_REAL // [1-r] Int to Real coercion
107} IOperator;
108
109
110char *IOperatorToString(IOperator op);
111
112
113#endif
Note: See TracBrowser for help on using the repository browser.