Add methods for converting between Collections (asBag, asSet, etc)
[panda.git] / src / st-node.h
blobc2ba5dfd250dce6476d7cc68d9a462302fe8e990
1 /*
2 * st-node.h
4 * Copyright (c) 2008 Vincent Geddes
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to deal
8 * in the Software without restriction, including without limitation the rights
9 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 * copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 * THE SOFTWARE.
25 #ifndef __ST_NODE_H__
26 #define __ST_NODE_H__
28 #include <st-types.h>
29 #include <st-utils.h>
31 typedef enum
33 ST_METHOD_NODE,
34 ST_BLOCK_NODE,
35 ST_VARIABLE_NODE,
36 ST_ASSIGN_NODE,
37 ST_RETURN_NODE,
38 ST_MESSAGE_NODE,
39 ST_CASCADE_NODE,
40 ST_LITERAL_NODE,
42 } st_node_type;
44 typedef enum
46 ST_UNARY_PRECEDENCE,
47 ST_BINARY_PRECEDENCE,
48 ST_KEYWORD_PRECEDENCE,
50 } STMessagePrecedence;
52 typedef struct st_node st_node;
54 struct st_node
56 st_node_type type;
57 int line;
58 st_node *next;
60 union {
62 struct {
63 STMessagePrecedence precedence;
64 int primitive;
65 st_oop selector;
66 st_node *statements;
67 st_node *temporaries;
68 st_node *arguments;
70 } method;
72 struct {
73 STMessagePrecedence precedence;
74 bool is_statement;
75 st_oop selector;
76 st_node *receiver;
77 st_node *arguments;
79 bool super_send;
81 } message;
83 struct {
84 char *name;
86 } variable;
88 struct {
89 st_oop value;
91 } literal;
93 struct {
94 st_node *assignee;
95 st_node *expression;
97 } assign;
99 struct {
100 st_node *expression;
102 } retrn;
104 struct {
105 st_node *statements;
106 st_node *temporaries;
107 st_node *arguments;
109 } block;
111 struct {
112 st_node *receiver;
113 st_list *messages;
114 bool is_statement;
116 } cascade;
122 st_node *st_node_new (st_node_type type);
124 st_node *st_node_list_append (st_node *list, st_node *node);
126 st_node *st_node_list_at (st_node *list, st_uint index);
128 st_uint st_node_list_length (st_node *list);
130 void st_print_method_node (st_node *method);
132 void st_node_destroy (st_node *node);
134 #endif /* __ST_NODE_H__ */