Browse Source

Sol Part 29: Whitespace is a Character Too!

Graham Northup 6 years ago
parent
commit
77d2337ecb
13 changed files with 4833 additions and 4316 deletions
  1. 1
    0
      .gitignore
  2. 17
    14
      astprint.c
  3. 465
    355
      builtins.c
  4. 222
    219
      cdata.c
  5. 1
    1
      dsl
  6. 4
    2
      gc.c
  7. 1186
    1209
      lex.yy.c
  8. 104
    68
      object.c
  9. 2191
    1881
      parser.tab.c
  10. 498
    465
      runtime.c
  11. 36
    32
      solrun.c
  12. 76
    48
      state.c
  13. 32
    22
      util.c

+ 1
- 0
.gitignore View File

@@ -2,3 +2,4 @@ sol
2 2
 *.o
3 3
 stdout
4 4
 .submodule_stamp
5
+*.orig

+ 17
- 14
astprint.c View File

@@ -8,7 +8,10 @@ void prlev(sol_state_t *state, int lev, const char *fmt, ...) {
8 8
 	va_list vl;
9 9
 	int i;
10 10
 
11
-	for(i = 0; i < lev; i++) { sol_putchar(state, '|'); sol_putchar(state, ' '); }
11
+	for(i = 0; i < lev; i++) {
12
+		sol_putchar(state, '|');
13
+		sol_putchar(state, ' ');
14
+	}
12 15
 	va_start(vl, fmt);
13 16
 	sol_vprintf(state, fmt, vl);
14 17
 	va_end(vl);
@@ -67,18 +70,18 @@ void prst(sol_state_t *state, stmt_node *node, int lev) {
67 70
 			}
68 71
 			break;
69 72
 
70
-        case ST_RET:
71
-            prlev(state, lev, "Stmt<Ret>:");
72
-            prex(state, node->ret->ret, lev+1);
73
-            break;
73
+		case ST_RET:
74
+			prlev(state, lev, "Stmt<Ret>:");
75
+			prex(state, node->ret->ret, lev+1);
76
+			break;
74 77
 
75
-        case ST_CONT:
76
-            prlev(state, lev, "Stmt<Continue>");
77
-            break;
78
+		case ST_CONT:
79
+			prlev(state, lev, "Stmt<Continue>");
80
+			break;
78 81
 
79
-        case ST_BREAK:
80
-            prlev(state, lev, "Stmt<Break>");
81
-            break;
82
+		case ST_BREAK:
83
+			prlev(state, lev, "Stmt<Break>");
84
+			break;
82 85
 	}
83 86
 }
84 87
 
@@ -155,7 +158,7 @@ void prex(sol_state_t *state, expr_node *node, int lev) {
155 158
 					prlev(state, lev, "Op: /");
156 159
 					break;
157 160
 
158
-                case OP_MOD:
161
+				case OP_MOD:
159 162
 					prlev(state, lev, "Op: %");
160 163
 					break;
161 164
 
@@ -303,11 +306,11 @@ void prex(sol_state_t *state, expr_node *node, int lev) {
303 306
 }
304 307
 
305 308
 void st_print(sol_state_t *state, stmt_node *stmt) {
306
-    prst(state, stmt, 0);
309
+	prst(state, stmt, 0);
307 310
 }
308 311
 
309 312
 void ex_print(sol_state_t *state, expr_node *expr) {
310
-    prex(state, expr, 0);
313
+	prex(state, expr, 0);
311 314
 }
312 315
 
313 316
 /*int main(int argc, char **argv) {

+ 465
- 355
builtins.c
File diff suppressed because it is too large
View File


+ 222
- 219
cdata.c View File

@@ -14,257 +14,260 @@ sol_ops_t sol_cstruct_spec_ops;
14 14
 sol_ops_t sol_cstruct_ops;
15 15
 
16 16
 void sol_cstruct_init(void) {
17
-    sol_ops_init(&sol_cstruct_spec_ops);
18
-    sol_ops_init(&sol_cstruct_ops);
17
+	sol_ops_init(&sol_cstruct_spec_ops);
18
+	sol_ops_init(&sol_cstruct_ops);
19 19
 
20
-    sol_cstruct_ops.index = sol_f_cstruct_index;
21
-    sol_cstruct_ops.setindex = sol_f_cstruct_setindex;
22
-    sol_cstruct_is_init = 1;
20
+	sol_cstruct_ops.index = sol_f_cstruct_index;
21
+	sol_cstruct_ops.setindex = sol_f_cstruct_setindex;
22
+	sol_cstruct_is_init = 1;
23 23
 }
24 24
 
25 25
 sol_object_t *sol_new_cstruct_specs(sol_state_t *state) {
26
-    return sol_new_map(state);
26
+	return sol_new_map(state);
27 27
 }
28 28
 
29 29
 sol_object_t *sol_new_cstruct_spec(sol_state_t *state, sol_spec_t type) {
30
-    ENSURE();
31
-    sol_object_t *res = sol_new_cdata(state, NEW(sol_memspec_t), &sol_cstruct_spec_ops);
32
-    AS(res->cdata, sol_memspec_t)->type = type;
33
-    return res;
30
+	ENSURE();
31
+	sol_object_t *res = sol_new_cdata(state, NEW(sol_memspec_t), &sol_cstruct_spec_ops);
32
+	AS(res->cdata, sol_memspec_t)->type = type;
33
+	return res;
34 34
 }
35 35
 
36 36
 void sol_cstruct_add_member(sol_state_t *state, sol_object_t *specs, sol_object_t *key, sol_memtype_t memtype, int offset) {
37
-    sol_object_t *spec = sol_new_cstruct_spec(state, SOL_CS_MEMBER);
38
-    AS(spec->cdata, sol_memspec_t)->memtype = memtype;
39
-    AS(spec->cdata, sol_memspec_t)->offset = offset;
40
-    sol_map_set(state, specs, key, spec);
41
-    sol_obj_free(spec);
37
+	sol_object_t *spec = sol_new_cstruct_spec(state, SOL_CS_MEMBER);
38
+	AS(spec->cdata, sol_memspec_t)->memtype = memtype;
39
+	AS(spec->cdata, sol_memspec_t)->offset = offset;
40
+	sol_map_set(state, specs, key, spec);
41
+	sol_obj_free(spec);
42 42
 }
43 43
 
44 44
 void sol_cstruct_add_member_name(sol_state_t *state, sol_object_t *specs, char *name, sol_memtype_t memtype, int offset) {
45
-    sol_object_t *spec = sol_new_cstruct_spec(state, SOL_CS_MEMBER);
46
-    AS(spec->cdata, sol_memspec_t)->memtype = memtype;
47
-    AS(spec->cdata, sol_memspec_t)->offset = offset;
48
-    sol_map_set_name(state, specs, name, spec);
49
-    sol_obj_free(spec);
45
+	sol_object_t *spec = sol_new_cstruct_spec(state, SOL_CS_MEMBER);
46
+	AS(spec->cdata, sol_memspec_t)->memtype = memtype;
47
+	AS(spec->cdata, sol_memspec_t)->offset = offset;
48
+	sol_map_set_name(state, specs, name, spec);
49
+	sol_obj_free(spec);
50 50
 }
51 51
 
52 52
 void sol_cstruct_add_pointer(sol_state_t *state, sol_object_t *pspecs, sol_object_t *key, sol_object_t *specs, int offset) {
53
-    sol_object_t *spec = sol_new_cstruct_spec(state, SOL_CS_MEMBER);
54
-    AS(spec->cdata, sol_memspec_t)->memtype = SOL_MT_PTR;
55
-    AS(spec->cdata, sol_memspec_t)->offset = offset;
56
-    AS(spec->cdata, sol_memspec_t)->specs = pspecs;
57
-    sol_map_set(state, specs, key, spec);
58
-    sol_obj_free(spec);
53
+	sol_object_t *spec = sol_new_cstruct_spec(state, SOL_CS_MEMBER);
54
+	AS(spec->cdata, sol_memspec_t)->memtype = SOL_MT_PTR;
55
+	AS(spec->cdata, sol_memspec_t)->offset = offset;
56
+	AS(spec->cdata, sol_memspec_t)->specs = pspecs;
57
+	sol_map_set(state, specs, key, spec);
58
+	sol_obj_free(spec);
59 59
 }
60 60
 
61 61
 void sol_cstruct_add_pointer_name(sol_state_t *state, sol_object_t *pspecs, char *name, sol_object_t *specs, int offset) {
62
-    sol_object_t *spec = sol_new_cstruct_spec(state, SOL_CS_MEMBER);
63
-    AS(spec->cdata, sol_memspec_t)->memtype = SOL_MT_PTR;
64
-    AS(spec->cdata, sol_memspec_t)->offset = offset;
65
-    AS(spec->cdata, sol_memspec_t)->specs = pspecs;
66
-    sol_map_set_name(state, specs, name, spec);
67
-    sol_obj_free(spec);
62
+	sol_object_t *spec = sol_new_cstruct_spec(state, SOL_CS_MEMBER);
63
+	AS(spec->cdata, sol_memspec_t)->memtype = SOL_MT_PTR;
64
+	AS(spec->cdata, sol_memspec_t)->offset = offset;
65
+	AS(spec->cdata, sol_memspec_t)->specs = pspecs;
66
+	sol_map_set_name(state, specs, name, spec);
67
+	sol_obj_free(spec);
68 68
 }
69 69
 
70 70
 void sol_cstruct_add_func(sol_state_t *state, sol_object_t *specs, sol_object_t *key, sol_cfunc_t cfunc) {
71
-    sol_object_t *spec = sol_new_cstruct_spec(state, SOL_CS_CFUNC);
72
-    AS(spec->cdata, sol_memspec_t)->cfunc = cfunc;
73
-    sol_map_set(state, specs, key, spec);
74
-    sol_obj_free(spec);
71
+	sol_object_t *spec = sol_new_cstruct_spec(state, SOL_CS_CFUNC);
72
+	AS(spec->cdata, sol_memspec_t)->cfunc = cfunc;
73
+	sol_map_set(state, specs, key, spec);
74
+	sol_obj_free(spec);
75 75
 }
76 76
 
77 77
 void sol_cstruct_add_func_name(sol_state_t *state, sol_object_t *specs, char *name, sol_cfunc_t cfunc) {
78
-    sol_object_t *spec = sol_new_cstruct_spec(state, SOL_CS_CFUNC);
79
-    AS(spec->cdata, sol_memspec_t)->cfunc = cfunc;
80
-    sol_map_set_name(state, specs, name, spec);
81
-    sol_obj_free(spec);
78
+	sol_object_t *spec = sol_new_cstruct_spec(state, SOL_CS_CFUNC);
79
+	AS(spec->cdata, sol_memspec_t)->cfunc = cfunc;
80
+	sol_map_set_name(state, specs, name, spec);
81
+	sol_obj_free(spec);
82 82
 }
83 83
 
84 84
 sol_object_t *sol_new_cstruct(sol_state_t *state, void *data, sol_object_t *specs) {
85
-    sol_object_t *res = sol_new_cdata(state, NEW(sol_cstruct_t), &sol_cstruct_ops);
86
-    AS(res->cdata, sol_cstruct_t)->data = data;
87
-    AS(res->cdata, sol_cstruct_t)->specs = sol_incref(specs);
88
-    return res;
85
+	sol_object_t *res = sol_new_cdata(state, NEW(sol_cstruct_t), &sol_cstruct_ops);
86
+	AS(res->cdata, sol_cstruct_t)->data = data;
87
+	AS(res->cdata, sol_cstruct_t)->specs = sol_incref(specs);
88
+	return res;
89 89
 }
90 90
 
91 91
 sol_object_t *sol_f_cstruct_index(sol_state_t *state, sol_object_t *args) {
92
-    sol_object_t *cstructobj = sol_list_get_index(state, args, 0), *idx = sol_list_get_index(state, args, 1);
93
-    sol_cstruct_t *cstruct = cstructobj->cdata;
94
-    sol_object_t *specobj = sol_map_get(state, cstruct->specs, idx), *res = NULL;
95
-    sol_memspec_t *spec;
96
-    char cbuf[2] = {0, 0};
97
-    if(sol_is_none(state, specobj)) {
98
-        sol_obj_free(specobj);
99
-        sol_obj_free(idx);
100
-        sol_obj_free(cstructobj);
101
-        return sol_set_error_string(state, "No such CStruct index");
102
-    }
103
-    spec = specobj->cdata;
104
-    switch(spec->type) {
105
-        case SOL_CS_MEMBER:
106
-            switch(spec->memtype) {
107
-                case SOL_MT_INT:
108
-                    res = sol_new_int(state, AT(cstruct->data, int, spec->offset));
109
-                    break;
110
-
111
-                case SOL_MT_INT8:
112
-                    res = sol_new_int(state, AT(cstruct->data, int8_t, spec->offset));
113
-                    break;
114
-
115
-                case SOL_MT_INT16:
116
-                    res = sol_new_int(state, AT(cstruct->data, int16_t, spec->offset));
117
-                    break;
118
-
119
-                case SOL_MT_INT32:
120
-                    res = sol_new_int(state, AT(cstruct->data, int32_t, spec->offset));
121
-                    break;
122
-
123
-                case SOL_MT_INT64:
124
-                    res = sol_new_int(state, AT(cstruct->data, int64_t, spec->offset));
125
-                    break;
126
-
127
-                case SOL_MT_UINT:
128
-                    res = sol_new_int(state, AT(cstruct->data, unsigned int, spec->offset));
129
-                    break;
130
-
131
-                case SOL_MT_UINT8:
132
-                    res = sol_new_int(state, AT(cstruct->data, uint8_t, spec->offset));
133
-                    break;
134
-
135
-                case SOL_MT_UINT16:
136
-                    res = sol_new_int(state, AT(cstruct->data, uint16_t, spec->offset));
137
-                    break;
138
-
139
-                case SOL_MT_UINT32:
140
-                    res = sol_new_int(state, AT(cstruct->data, uint32_t, spec->offset));
141
-                    break;
142
-
143
-                /*case SOL_MT_UINT64:
144
-                    res = sol_new_int(state, AT(cstruct->data, uint64_t, spec->offset));
145
-                    break;*/
146
-
147
-                case SOL_MT_FLOAT:
148
-                    res = sol_new_float(state, AT(cstruct->data, float, spec->offset));
149
-                    break;
150
-
151
-                case SOL_MT_DOUBLE:
152
-                    res = sol_new_float(state, AT(cstruct->data, double, spec->offset));
153
-                    break;
154
-
155
-                case SOL_MT_CHAR:
156
-                    cbuf[0] = AT(cstruct->data, char, spec->offset);
157
-                    res = sol_new_string(state, cbuf);
158
-                    break;
159
-
160
-                case SOL_MT_CSTR:
161
-                    res = sol_new_string(state, AT(cstruct->data, char *, spec->offset));
162
-                    break;
163
-
164
-                case SOL_MT_CFUNC:
165
-                    res = sol_new_cfunc(state, AT(cstruct->data, sol_cfunc_t, spec->offset));
166
-                    break;
167
-
168
-                case SOL_MT_PTR:
169
-                    res = sol_new_cstruct(state, AT(cstruct->data, void *, spec->offset), spec->specs);
170
-                    break;
171
-            }
172
-            break;
173
-
174
-        case SOL_CS_CFUNC:
175
-            res = sol_new_cfunc(state, spec->cfunc);
176
-            break;
177
-    }
178
-    if(!res) res = sol_incref(state->None);
179
-    return res;
92
+	sol_object_t *cstructobj = sol_list_get_index(state, args, 0), *idx = sol_list_get_index(state, args, 1);
93
+	sol_cstruct_t *cstruct = cstructobj->cdata;
94
+	sol_object_t *specobj = sol_map_get(state, cstruct->specs, idx), *res = NULL;
95
+	sol_memspec_t *spec;
96
+	char cbuf[2] = {0, 0};
97
+	if(sol_is_none(state, specobj)) {
98
+		sol_obj_free(specobj);
99
+		sol_obj_free(idx);
100
+		sol_obj_free(cstructobj);
101
+		return sol_set_error_string(state, "No such CStruct index");
102
+	}
103
+	spec = specobj->cdata;
104
+	switch(spec->type) {
105
+		case SOL_CS_MEMBER:
106
+			switch(spec->memtype) {
107
+				case SOL_MT_INT:
108
+					res = sol_new_int(state, AT(cstruct->data, int, spec->offset));
109
+					break;
110
+
111
+				case SOL_MT_INT8:
112
+					res = sol_new_int(state, AT(cstruct->data, int8_t, spec->offset));
113
+					break;
114
+
115
+				case SOL_MT_INT16:
116
+					res = sol_new_int(state, AT(cstruct->data, int16_t, spec->offset));
117
+					break;
118
+
119
+				case SOL_MT_INT32:
120
+					res = sol_new_int(state, AT(cstruct->data, int32_t, spec->offset));
121
+					break;
122
+
123
+				case SOL_MT_INT64:
124
+					res = sol_new_int(state, AT(cstruct->data, int64_t, spec->offset));
125
+					break;
126
+
127
+				case SOL_MT_UINT:
128
+					res = sol_new_int(state, AT(cstruct->data, unsigned int, spec->offset));
129
+					break;
130
+
131
+				case SOL_MT_UINT8:
132
+					res = sol_new_int(state, AT(cstruct->data, uint8_t, spec->offset));
133
+					break;
134
+
135
+				case SOL_MT_UINT16:
136
+					res = sol_new_int(state, AT(cstruct->data, uint16_t, spec->offset));
137
+					break;
138
+
139
+				case SOL_MT_UINT32:
140
+					res = sol_new_int(state, AT(cstruct->data, uint32_t, spec->offset));
141
+					break;
142
+
143
+					/*case SOL_MT_UINT64:
144
+					    res = sol_new_int(state, AT(cstruct->data, uint64_t, spec->offset));
145
+					    break;*/
146
+
147
+				case SOL_MT_FLOAT:
148
+					res = sol_new_float(state, AT(cstruct->data, float, spec->offset));
149
+					break;
150
+
151
+				case SOL_MT_DOUBLE:
152
+					res = sol_new_float(state, AT(cstruct->data, double, spec->offset));
153
+					break;
154
+
155
+				case SOL_MT_CHAR:
156
+					cbuf[0] = AT(cstruct->data, char, spec->offset);
157
+					res = sol_new_string(state, cbuf);
158
+					break;
159
+
160
+				case SOL_MT_CSTR:
161
+					res = sol_new_string(state, AT(cstruct->data, char *, spec->offset));
162
+					break;
163
+
164
+				case SOL_MT_CFUNC:
165
+					res = sol_new_cfunc(state, AT(cstruct->data, sol_cfunc_t, spec->offset));
166
+					break;
167
+
168
+				case SOL_MT_PTR:
169
+					res = sol_new_cstruct(state, AT(cstruct->data, void *, spec->offset), spec->specs);
170
+					break;
171
+			}
172
+			break;
173
+
174
+		case SOL_CS_CFUNC:
175
+			res = sol_new_cfunc(state, spec->cfunc);
176
+			break;
177
+	}
178
+	if(!res) {
179
+		res = sol_incref(state->None);
180
+	}
181
+	return res;
180 182
 }
181 183
 
182 184
 sol_object_t *sol_f_cstruct_setindex(sol_state_t *state, sol_object_t *args) {
183
-    sol_object_t *cstructobj = sol_list_get_index(state, args, 0), *idx = sol_list_get_index(state, args, 1), *val = sol_list_get_index(state, args, 2);
184
-    sol_cstruct_t *cstruct = cstructobj->cdata;
185
-    sol_object_t *specobj = sol_map_get(state, cstruct->specs, idx);
186
-    sol_memspec_t *spec;
187
-    char cbuf[2] = {0, 0};
188
-    if(sol_is_none(state, specobj)) {
189
-        sol_obj_free(specobj);
190
-        sol_obj_free(idx);
191
-        sol_obj_free(cstructobj);
192
-        return sol_set_error_string(state, "No such CStruct index");
193
-    }
194
-    spec = specobj->cdata;
195
-    switch(spec->type) {
196
-        case SOL_CS_MEMBER:
197
-            switch(spec->memtype) {
198
-                case SOL_MT_INT:
199
-                    AT(cstruct->data, int, spec->offset) = sol_cast_int(state, val)->ival;
200
-                    break;
201
-
202
-                case SOL_MT_INT8:
203
-                    AT(cstruct->data, int8_t, spec->offset) = sol_cast_int(state, val)->ival;
204
-                    break;
205
-
206
-                case SOL_MT_INT16:
207
-                    AT(cstruct->data, int16_t, spec->offset) = sol_cast_int(state, val)->ival;
208
-                    break;
209
-
210
-                case SOL_MT_INT32:
211
-                    AT(cstruct->data, int32_t, spec->offset) = sol_cast_int(state, val)->ival;
212
-                    break;
213
-
214
-                case SOL_MT_INT64:
215
-                    AT(cstruct->data, int64_t, spec->offset) = sol_cast_int(state, val)->ival;
216
-                    break;
217
-
218
-                case SOL_MT_UINT:
219
-                    AT(cstruct->data, unsigned int, spec->offset) = sol_cast_int(state, val)->ival;
220
-                    break;
221
-
222
-                case SOL_MT_UINT8:
223
-                    AT(cstruct->data, uint8_t, spec->offset) = sol_cast_int(state, val)->ival;
224
-                    break;
225
-
226
-                case SOL_MT_UINT16:
227
-                    AT(cstruct->data, uint16_t, spec->offset) = sol_cast_int(state, val)->ival;
228
-                    break;
229
-
230
-                case SOL_MT_UINT32:
231
-                    AT(cstruct->data, uint32_t, spec->offset) = sol_cast_int(state, val)->ival;
232
-                    break;
233
-
234
-                /*case SOL_MT_UINT64:
235
-                    AT(cstruct->data, uint64_t, spec->offset) = sol_cast_int(state, val)->ival;
236
-                    break;*/
237
-
238
-                case SOL_MT_FLOAT:
239
-                    AT(cstruct->data, float, spec->offset) = sol_cast_float(state, val)->fval;
240
-                    break;
241
-
242
-                case SOL_MT_DOUBLE:
243
-                    AT(cstruct->data, double, spec->offset) = sol_cast_float(state, val)->fval;
244
-                    break;
245
-
246
-                case SOL_MT_CHAR:
247
-                    AT(cstruct->data, char, spec->offset) = sol_cast_string(state, val)->str[0];
248
-                    break;
249
-
250
-                case SOL_MT_CSTR:
251
-                    AT(cstruct->data, char *, spec->offset) = strdup(sol_cast_string(state, val)->str);
252
-                    break;
253
-
254
-                case SOL_MT_CFUNC:
255
-                    return sol_set_error_string(state, "Can't assign CFunc members");
256
-                    break;
257
-
258
-                case SOL_MT_PTR:
259
-                    if(!sol_is_cdata(val) || spec->specs != AS(val->cdata, sol_cstruct_t)->specs)
260
-                        return sol_set_error_string(state, "Invalid type for PTR assignment");
261
-                    AT(cstruct->data, void *, spec->offset) = AS(val->cdata, sol_cstruct_t)->data;
262
-            }
263
-            break;
264
-
265
-        case SOL_CS_CFUNC:
266
-            return sol_set_error_string(state, "Can't assign CFunc members");
267
-            break;
268
-    }
269
-    return sol_incref(state->None);
185
+	sol_object_t *cstructobj = sol_list_get_index(state, args, 0), *idx = sol_list_get_index(state, args, 1), *val = sol_list_get_index(state, args, 2);
186
+	sol_cstruct_t *cstruct = cstructobj->cdata;
187
+	sol_object_t *specobj = sol_map_get(state, cstruct->specs, idx);
188
+	sol_memspec_t *spec;
189
+	char cbuf[2] = {0, 0};
190
+	if(sol_is_none(state, specobj)) {
191
+		sol_obj_free(specobj);
192
+		sol_obj_free(idx);
193
+		sol_obj_free(cstructobj);
194
+		return sol_set_error_string(state, "No such CStruct index");
195
+	}
196
+	spec = specobj->cdata;
197
+	switch(spec->type) {
198
+		case SOL_CS_MEMBER:
199
+			switch(spec->memtype) {
200
+				case SOL_MT_INT:
201
+					AT(cstruct->data, int, spec->offset) = sol_cast_int(state, val)->ival;
202
+					break;
203
+
204
+				case SOL_MT_INT8:
205
+					AT(cstruct->data, int8_t, spec->offset) = sol_cast_int(state, val)->ival;
206
+					break;
207
+
208
+				case SOL_MT_INT16:
209
+					AT(cstruct->data, int16_t, spec->offset) = sol_cast_int(state, val)->ival;
210
+					break;
211
+
212
+				case SOL_MT_INT32:
213
+					AT(cstruct->data, int32_t, spec->offset) = sol_cast_int(state, val)->ival;
214
+					break;
215
+
216
+				case SOL_MT_INT64:
217
+					AT(cstruct->data, int64_t, spec->offset) = sol_cast_int(state, val)->ival;
218
+					break;
219
+
220
+				case SOL_MT_UINT:
221
+					AT(cstruct->data, unsigned int, spec->offset) = sol_cast_int(state, val)->ival;
222
+					break;
223
+
224
+				case SOL_MT_UINT8:
225
+					AT(cstruct->data, uint8_t, spec->offset) = sol_cast_int(state, val)->ival;
226
+					break;
227
+
228
+				case SOL_MT_UINT16:
229
+					AT(cstruct->data, uint16_t, spec->offset) = sol_cast_int(state, val)->ival;
230
+					break;
231
+
232
+				case SOL_MT_UINT32:
233
+					AT(cstruct->data, uint32_t, spec->offset) = sol_cast_int(state, val)->ival;
234
+					break;
235
+
236
+					/*case SOL_MT_UINT64:
237
+					    AT(cstruct->data, uint64_t, spec->offset) = sol_cast_int(state, val)->ival;
238
+					    break;*/
239
+
240
+				case SOL_MT_FLOAT:
241
+					AT(cstruct->data, float, spec->offset) = sol_cast_float(state, val)->fval;
242
+					break;
243
+
244
+				case SOL_MT_DOUBLE:
245
+					AT(cstruct->data, double, spec->offset) = sol_cast_float(state, val)->fval;
246
+					break;
247
+
248
+				case SOL_MT_CHAR:
249
+					AT(cstruct->data, char, spec->offset) = sol_cast_string(state, val)->str[0];
250
+					break;
251
+
252
+				case SOL_MT_CSTR:
253
+					AT(cstruct->data, char *, spec->offset) = strdup(sol_cast_string(state, val)->str);
254
+					break;
255
+
256
+				case SOL_MT_CFUNC:
257
+					return sol_set_error_string(state, "Can't assign CFunc members");
258
+					break;
259
+
260
+				case SOL_MT_PTR:
261
+					if(!sol_is_cdata(val) || spec->specs != AS(val->cdata, sol_cstruct_t)->specs) {
262
+						return sol_set_error_string(state, "Invalid type for PTR assignment");
263
+					}
264
+					AT(cstruct->data, void *, spec->offset) = AS(val->cdata, sol_cstruct_t)->data;
265
+			}
266
+			break;
267
+
268
+		case SOL_CS_CFUNC:
269
+			return sol_set_error_string(state, "Can't assign CFunc members");
270
+			break;
271
+	}
272
+	return sol_incref(state->None);
270 273
 }

+ 1
- 1
dsl

@@ -1 +1 @@
1
-Subproject commit 10976abb77cee1f9beb6514a80e38e950bca9a0d
1
+Subproject commit aff43d13d92bc83038bf675afbcaf5304be5acf5

+ 4
- 2
gc.c View File

@@ -35,8 +35,10 @@ void sol_obj_free(sol_object_t *obj) {
35 35
 }
36 36
 
37 37
 void sol_obj_release(sol_object_t *obj) {
38
-    if(obj->ops->free) obj->ops->free(NULL, obj);
39
-    free(obj);
38
+	if(obj->ops->free) {
39
+		obj->ops->free(NULL, obj);
40
+	}
41
+	free(obj);
40 42
 }
41 43
 
42 44
 #endif

+ 1186
- 1209
lex.yy.c
File diff suppressed because it is too large
View File


+ 104
- 68
object.c View File

@@ -9,7 +9,9 @@
9 9
 
10 10
 sol_object_t *sol_cast_int(sol_state_t *state, sol_object_t *obj) {
11 11
 	sol_object_t *res, *ls;
12
-	if(sol_is_int(obj)) return sol_incref(obj);
12
+	if(sol_is_int(obj)) {
13
+		return sol_incref(obj);
14
+	}
13 15
 	ls = sol_new_list(state);
14 16
 	sol_list_insert(state, ls, 0, obj);
15 17
 	res = obj->ops->toint(state, ls);
@@ -19,7 +21,9 @@ sol_object_t *sol_cast_int(sol_state_t *state, sol_object_t *obj) {
19 21
 
20 22
 sol_object_t *sol_cast_float(sol_state_t *state, sol_object_t *obj) {
21 23
 	sol_object_t *res, *ls;
22
-	if(sol_is_float(obj)) return sol_incref(obj);
24
+	if(sol_is_float(obj)) {
25
+		return sol_incref(obj);
26
+	}
23 27
 	ls = sol_new_list(state);
24 28
 	sol_list_insert(state, ls, 0, obj);
25 29
 	res = obj->ops->tofloat(state, ls);
@@ -29,7 +33,9 @@ sol_object_t *sol_cast_float(sol_state_t *state, sol_object_t *obj) {
29 33
 
30 34
 sol_object_t *sol_cast_string(sol_state_t *state, sol_object_t *obj) {
31 35
 	sol_object_t *res, *ls;
32
-	if(sol_is_string(obj)) return sol_incref(obj);
36
+	if(sol_is_string(obj)) {
37
+		return sol_incref(obj);
38
+	}
33 39
 	ls = sol_new_list(state);
34 40
 	sol_list_insert(state, ls, 0, obj);
35 41
 	res = obj->ops->tostring(state, ls);
@@ -61,7 +67,9 @@ sol_object_t *sol_new_singlet(sol_state_t *state, const char *name) {
61 67
 // And, now, for the rest of the checked stuff...
62 68
 
63 69
 void sol_init_object(sol_state_t *state, sol_object_t *obj) {
64
-	if(obj->ops->init) obj->ops->init(state, obj);
70
+	if(obj->ops->init) {
71
+		obj->ops->init(state, obj);
72
+	}
65 73
 }
66 74
 
67 75
 sol_object_t *sol_new_int(sol_state_t *state, long i) {
@@ -159,22 +167,30 @@ sol_object_t *sol_list_sublist(sol_state_t *state, sol_object_t *list, int idx)
159 167
 }
160 168
 
161 169
 sol_object_t *sol_list_get_index(sol_state_t *state, sol_object_t *list, int idx) {
162
-	if(idx<0 || idx>=dsl_seq_len(list->seq)) return sol_incref(state->None);
170
+	if(idx<0 || idx>=dsl_seq_len(list->seq)) {
171
+		return sol_incref(state->None);
172
+	}
163 173
 	return sol_incref(AS_OBJ(dsl_seq_get(list->seq, idx)));
164 174
 }
165 175
 
166 176
 void sol_list_set_index(sol_state_t *state, sol_object_t *list, int idx, sol_object_t *obj) {
167
-	if(idx<0 || idx>=dsl_seq_len(list->seq)) return;
177
+	if(idx<0 || idx>=dsl_seq_len(list->seq)) {
178
+		return;
179
+	}
168 180
 	dsl_seq_set(list->seq, idx, obj);
169 181
 }
170 182
 
171 183
 void sol_list_insert(sol_state_t *state, sol_object_t *list, int idx, sol_object_t *obj) {
172
-	if(idx<0 || idx>dsl_seq_len(list->seq)) return;
184
+	if(idx<0 || idx>dsl_seq_len(list->seq)) {
185
+		return;
186
+	}
173 187
 	dsl_seq_insert(list->seq, idx, obj);
174 188
 }
175 189
 
176 190
 sol_object_t *sol_list_remove(sol_state_t *state, sol_object_t *list, int idx) {
177
-	if(idx<0 || idx>=dsl_seq_len(list->seq)) return sol_incref(state->None);
191
+	if(idx<0 || idx>=dsl_seq_len(list->seq)) {
192
+		return sol_incref(state->None);
193
+	}
178 194
 	return dsl_seq_remove(list->seq, idx);
179 195
 }
180 196
 
@@ -198,13 +214,13 @@ sol_object_t *sol_list_truncate(sol_state_t *state, sol_object_t *list, int len)
198 214
 }
199 215
 
200 216
 void sol_list_append(sol_state_t *state, sol_object_t *dest, sol_object_t *src) {
201
-    dsl_seq *oldseq = dest->seq;
217
+	dsl_seq *oldseq = dest->seq;
202 218
 	dest->seq = dsl_seq_append(dest->seq, src->seq);
203 219
 	dsl_free_seq(oldseq);
204 220
 }
205 221
 
206 222
 sol_object_t *sol_f_list_free(sol_state_t *state, sol_object_t *list) {
207
-    dsl_free_seq(list->seq);
223
+	dsl_free_seq(list->seq);
208 224
 	return list;
209 225
 }
210 226
 
@@ -254,29 +270,31 @@ int sol_validate_list(sol_state_t *state, sol_object_t *list) {
254 270
 }*/
255 271
 
256 272
 sol_object_t *sol_new_map(sol_state_t *state) {
257
-    sol_object_t *map = sol_alloc_object(state);
258
-    map->type = SOL_MAP;
259
-    map->ops = &(state->MapOps);
260
-    map->seq = dsl_seq_new_array(NULL, &(state->obfuncs));
273
+	sol_object_t *map = sol_alloc_object(state);
274
+	map->type = SOL_MAP;
275
+	map->ops = &(state->MapOps);
276
+	map->seq = dsl_seq_new_array(NULL, &(state->obfuncs));
261 277
 	sol_init_object(state, map);
262
-    return map;
278
+	return map;
263 279
 }
264 280
 
265 281
 sol_object_t *sol_map_from_seq(sol_state_t *state, dsl_seq *seq) {
266
-    sol_object_t *map = sol_alloc_object(state);
267
-    if(sol_has_error(state)) return sol_incref(state->None);
268
-    map->type = SOL_MAP;
269
-    map->ops = &(state->MapOps);
270
-    map->seq = seq;
271
-    return map;
282
+	sol_object_t *map = sol_alloc_object(state);
283
+	if(sol_has_error(state)) {
284
+		return sol_incref(state->None);
285
+	}
286
+	map->type = SOL_MAP;
287
+	map->ops = &(state->MapOps);
288
+	map->seq = seq;
289
+	return map;
272 290
 }
273 291
 
274 292
 int sol_map_len(sol_state_t *state, sol_object_t *map) {
275
-    return dsl_seq_len(map->seq);
293
+	return dsl_seq_len(map->seq);
276 294
 }
277 295
 
278 296
 sol_object_t *sol_map_mcell(sol_state_t *state, sol_object_t *map, sol_object_t *key) {
279
-    sol_object_t *list, *cmp, *icmp, *res = NULL;
297
+	sol_object_t *list, *cmp, *icmp, *res = NULL;
280 298
 	dsl_seq_iter *iter;
281 299
 	if(!sol_is_map(map)) {
282 300
 		printf("WARNING: Attempt to index non-map as map\n");
@@ -289,24 +307,24 @@ sol_object_t *sol_map_mcell(sol_state_t *state, sol_object_t *map, sol_object_t
289 307
 		sol_obj_free(list);
290 308
 		return sol_incref(state->None);
291 309
 	}
292
-    sol_list_insert(state, list, 0, key);
310
+	sol_list_insert(state, list, 0, key);
293 311
 	sol_list_insert(state, list, 1, state->None);
294
-    if(!dsl_seq_iter_is_invalid(iter)) do {
295
-		sol_list_set_index(state, list, 1, AS_OBJ(dsl_seq_iter_at(iter))->key);
296
-		cmp = key->ops->cmp(state, list);
297
-		icmp = sol_cast_int(state, cmp);
298
-		sol_obj_free(cmp);
299
-		if(icmp->ival == 0) {
300
-			res = AS_OBJ(dsl_seq_iter_at(iter));
301
-		}
302
-		sol_obj_free(icmp);
303
-	} while(dsl_seq_iter_next(iter));
312
+	if(!dsl_seq_iter_is_invalid(iter)) do {
313
+			sol_list_set_index(state, list, 1, AS_OBJ(dsl_seq_iter_at(iter))->key);
314
+			cmp = key->ops->cmp(state, list);
315
+			icmp = sol_cast_int(state, cmp);
316
+			sol_obj_free(cmp);
317
+			if(icmp->ival == 0) {
318
+				res = AS_OBJ(dsl_seq_iter_at(iter));
319
+			}
320
+			sol_obj_free(icmp);
321
+		} while(dsl_seq_iter_next(iter));
304 322
 	dsl_free_seq_iter(iter);
305 323
 	sol_obj_free(list);
306 324
 	if(res) {
307 325
 		return res;
308 326
 	}
309
-    return sol_incref(state->None);
327
+	return sol_incref(state->None);
310 328
 }
311 329
 
312 330
 int sol_map_has(sol_state_t *state, sol_object_t *map, sol_object_t *key) {
@@ -317,8 +335,8 @@ int sol_map_has(sol_state_t *state, sol_object_t *map, sol_object_t *key) {
317 335
 }
318 336
 
319 337
 sol_object_t *sol_map_get(sol_state_t *state, sol_object_t *map, sol_object_t *key) {
320
-    sol_object_t *mcell = sol_map_mcell(state, map, key);
321
-    if(sol_is_none(state, mcell)) {
338
+	sol_object_t *mcell = sol_map_mcell(state, map, key);
339
+	if(sol_is_none(state, mcell)) {
322 340
 		return mcell;
323 341
 	}
324 342
 	return sol_incref(mcell->val);
@@ -332,7 +350,7 @@ sol_object_t *sol_map_get_name(sol_state_t *state, sol_object_t *map, char *name
332 350
 }
333 351
 
334 352
 void sol_map_set(sol_state_t *state, sol_object_t *map, sol_object_t *key, sol_object_t *val) {
335
-    sol_object_t *mcell =sol_map_mcell(state, map, key), *newcell, *temp;
353
+	sol_object_t *mcell =sol_map_mcell(state, map, key), *newcell, *temp;
336 354
 	if(sol_is_none(state, mcell)) {
337 355
 		newcell = sol_alloc_object(state);
338 356
 		newcell->type = SOL_MCELL;
@@ -355,7 +373,7 @@ void sol_map_set_name(sol_state_t *state, sol_object_t *map, char *name, sol_obj
355 373
 }
356 374
 
357 375
 void sol_map_set_existing(sol_state_t *state, sol_object_t *map, sol_object_t *key, sol_object_t *val) {
358
-    sol_object_t *mcell =sol_map_mcell(state, map, key), *temp;
376
+	sol_object_t *mcell =sol_map_mcell(state, map, key), *temp;
359 377
 	if(!sol_is_none(state, mcell)) {
360 378
 		temp = mcell->val;
361 379
 		mcell->val = sol_incref(val);
@@ -364,22 +382,22 @@ void sol_map_set_existing(sol_state_t *state, sol_object_t *map, sol_object_t *k
364 382
 }
365 383
 
366 384
 sol_object_t *sol_map_copy(sol_state_t *state, sol_object_t *map) {
367
-    return sol_map_from_seq(state, dsl_seq_copy(map->seq));
385
+	return sol_map_from_seq(state, dsl_seq_copy(map->seq));
368 386
 }
369 387
 
370 388
 void sol_map_merge(sol_state_t *state, sol_object_t *dest, sol_object_t *src) {
371
-    dsl_seq_iter *iter = dsl_new_seq_iter(src->seq);
389
+	dsl_seq_iter *iter = dsl_new_seq_iter(src->seq);
372 390
 	if(!dsl_seq_iter_is_invalid(iter)) do {
373
-		sol_map_set(state, dest, AS_OBJ(dsl_seq_iter_at(iter))->key, AS_OBJ(dsl_seq_iter_at(iter))->val);
374
-	} while(dsl_seq_iter_next(iter));
391
+			sol_map_set(state, dest, AS_OBJ(dsl_seq_iter_at(iter))->key, AS_OBJ(dsl_seq_iter_at(iter))->val);
392
+		} while(dsl_seq_iter_next(iter));
375 393
 	dsl_free_seq_iter(iter);
376 394
 }
377 395
 
378 396
 void sol_map_merge_existing(sol_state_t *state, sol_object_t *dest, sol_object_t *src) {
379
-    dsl_seq_iter *iter = dsl_new_seq_iter(src->seq);
397
+	dsl_seq_iter *iter = dsl_new_seq_iter(src->seq);
380 398
 	if(!dsl_seq_iter_is_invalid(iter)) do {
381
-		sol_map_set_existing(state, dest, AS_OBJ(dsl_seq_iter_at(iter))->key, AS_OBJ(dsl_seq_iter_at(iter))->val);
382
-	} while(dsl_seq_iter_next(iter));
399
+			sol_map_set_existing(state, dest, AS_OBJ(dsl_seq_iter_at(iter))->key, AS_OBJ(dsl_seq_iter_at(iter))->val);
400
+		} while(dsl_seq_iter_next(iter));
383 401
 	dsl_free_seq_iter(iter);
384 402
 }
385 403
 
@@ -397,13 +415,17 @@ void sol_map_invert(sol_state_t *state, sol_object_t *map) {
397 415
 }
398 416
 
399 417
 sol_object_t *sol_f_map_free(sol_state_t *state, sol_object_t *map) {
400
-    dsl_free_seq(map->seq);
401
-    return map;
418
+	dsl_free_seq(map->seq);
419
+	return map;
402 420
 }
403 421
 
404 422
 sol_object_t *sol_f_mcell_free(sol_state_t *state, sol_object_t *mcell) {
405
-	if(mcell->key) sol_obj_free(mcell->key);
406
-	if(mcell->val) sol_obj_free(mcell->val);
423
+	if(mcell->key) {
424
+		sol_obj_free(mcell->key);
425
+	}
426
+	if(mcell->val) {
427
+		sol_obj_free(mcell->val);
428
+	}
407 429
 	return mcell;
408 430
 }
409 431
 
@@ -429,21 +451,21 @@ sol_object_t *sol_f_mcell_free(sol_state_t *state, sol_object_t *mcell) {
429 451
 }*/
430 452
 
431 453
 sol_object_t *sol_new_cfunc(sol_state_t *state, sol_cfunc_t cfunc) {
432
-    sol_object_t *res = sol_alloc_object(state);
433
-    res->type = SOL_CFUNCTION;
434
-    res->ops = &(state->CFuncOps);
435
-    res->cfunc = cfunc;
454
+	sol_object_t *res = sol_alloc_object(state);
455
+	res->type = SOL_CFUNCTION;
456
+	res->ops = &(state->CFuncOps);
457
+	res->cfunc = cfunc;
436 458
 	sol_init_object(state, res);
437
-    return res;
459
+	return res;
438 460
 }
439 461
 
440 462
 sol_object_t *sol_new_cdata(sol_state_t *state, void *cdata, sol_ops_t *ops) {
441
-    sol_object_t *res = sol_alloc_object(state);
442
-    res->type = SOL_CDATA;
443
-    res->ops = ops;
444
-    res->cdata = cdata;
463
+	sol_object_t *res = sol_alloc_object(state);
464
+	res->type = SOL_CDATA;
465
+	res->ops = ops;
466
+	res->cdata = cdata;
445 467
 	sol_init_object(state, res);
446
-    return res;
468
+	return res;
447 469
 }
448 470
 
449 471
 sol_object_t *sol_new_buffer(sol_state_t *state, void *buffer, ssize_t sz, sol_owntype_t own, sol_freefunc_t freef, sol_movefunc_t movef) {
@@ -464,7 +486,7 @@ sol_object_t *sol_f_buffer_free(sol_state_t *state, sol_object_t *buf) {
464 486
 		case OWN_FREE:
465 487
 			free(buf->buffer);
466 488
 			break;
467
-			
489
+
468 490
 		case OWN_CALLF:
469 491
 			buf->freef(buf->buffer, buf->sz);
470 492
 			break;
@@ -515,7 +537,9 @@ size_t sol_stream_printf(sol_state_t *state, sol_object_t *stream, const char *f
515 537
 	va_list va;
516 538
 	size_t res;
517 539
 	if(!(stream->modes & MODE_WRITE)) {
518
-		if(state) sol_obj_free(sol_set_error_string(state, "Write to non-writable stream"));
540
+		if(state) {
541
+			sol_obj_free(sol_set_error_string(state, "Write to non-writable stream"));
542
+		}
519 543
 		return 0;
520 544
 	}
521 545
 	va_start(va, fmt);
@@ -526,7 +550,9 @@ size_t sol_stream_printf(sol_state_t *state, sol_object_t *stream, const char *f
526 550
 
527 551
 size_t sol_stream_vprintf(sol_state_t *state, sol_object_t *stream, const char *fmt, va_list va) {
528 552
 	if(!(stream->modes & MODE_WRITE)) {
529
-		if(state) sol_obj_free(sol_set_error_string(state, "Write to non-writable stream"));
553
+		if(state) {
554
+			sol_obj_free(sol_set_error_string(state, "Write to non-writable stream"));
555
+		}
530 556
 		return 0;
531 557
 	}
532 558
 	return vfprintf(stream->stream, fmt, va);
@@ -536,7 +562,9 @@ size_t sol_stream_scanf(sol_state_t *state, sol_object_t *stream, const char *fm
536 562
 	va_list va;
537 563
 	size_t res;
538 564
 	if(!(stream->modes & MODE_READ)) {
539
-		if(state) sol_obj_free(sol_set_error_string(state, "Read from non-readable stream"));
565
+		if(state) {
566
+			sol_obj_free(sol_set_error_string(state, "Read from non-readable stream"));
567
+		}
540 568
 		return 0;
541 569
 	}
542 570
 	va_start(va, fmt);
@@ -547,7 +575,9 @@ size_t sol_stream_scanf(sol_state_t *state, sol_object_t *stream, const char *fm
547 575
 
548 576
 size_t sol_stream_fread(sol_state_t *state, sol_object_t *stream, char *buffer, size_t sz, size_t memb) {
549 577
 	if(!(stream->modes & MODE_READ)) {
550
-		if(state) sol_obj_free(sol_set_error_string(state, "Read from non-readable stream"));
578
+		if(state) {
579
+			sol_obj_free(sol_set_error_string(state, "Read from non-readable stream"));
580
+		}
551 581
 		return 0;
552 582
 	}
553 583
 	return fread(buffer, sz, memb, stream->stream);
@@ -555,7 +585,9 @@ size_t sol_stream_fread(sol_state_t *state, sol_object_t *stream, char *buffer,
555 585
 
556 586
 size_t sol_stream_fwrite(sol_state_t *state, sol_object_t *stream, char *buffer, size_t sz, size_t memb) {
557 587
 	if(!(stream->modes & MODE_WRITE)) {
558
-		if(state) sol_obj_free(sol_set_error_string(state, "Write to non-writable stream"));
588
+		if(state) {
589
+			sol_obj_free(sol_set_error_string(state, "Write to non-writable stream"));
590
+		}
559 591
 		return 0;
560 592
 	}
561 593
 	return fwrite(buffer, sz, memb, stream->stream);
@@ -563,7 +595,9 @@ size_t sol_stream_fwrite(sol_state_t *state, sol_object_t *stream, char *buffer,
563 595
 
564 596
 char *sol_stream_fgets(sol_state_t *state, sol_object_t *stream, char *buffer, size_t sz) {
565 597
 	if(!(stream->modes & MODE_READ)) {
566
-		if(state) sol_obj_free(sol_set_error_string(state, "Read from non-readable stream"));
598
+		if(state) {
599
+			sol_obj_free(sol_set_error_string(state, "Read from non-readable stream"));
600
+		}
567 601
 		return NULL;
568 602
 	}
569 603
 	return fgets(buffer, sz, stream->stream);
@@ -571,7 +605,9 @@ char *sol_stream_fgets(sol_state_t *state, sol_object_t *stream, char *buffer, s
571 605
 
572 606
 int sol_stream_fputc(sol_state_t *state, sol_object_t *stream, int ch) {
573 607
 	if(!(stream->modes & MODE_WRITE)) {
574
-		if(state) sol_obj_free(sol_set_error_string(state, "Write to non-writable stream"));
608
+		if(state) {
609
+			sol_obj_free(sol_set_error_string(state, "Write to non-writable stream"));
610
+		}
575 611
 		return 0;
576 612
 	}
577 613
 	return fputc(ch, stream->stream);

+ 2191
- 1881
parser.tab.c
File diff suppressed because it is too large
View File


+ 498
- 465
runtime.c
File diff suppressed because it is too large
View File


+ 36
- 32
solrun.c View File

@@ -3,49 +3,53 @@
3 3
 #include "parser.tab.h"
4 4
 
5 5
 int main(int argc, char **argv) {
6
-    stmt_node *program;
7
-    sol_state_t state;
8
-    char *c;
9
-    int printtree = 0;
6
+	stmt_node *program;
7
+	sol_state_t state;
8
+	char *c;
9
+	int printtree = 0;
10 10
 	FILE *prgstream = stdin;
11 11
 
12
-    if(argc>1) {
13
-        c = argv[1];
14
-        while(*c) {
15
-            switch(*c) {
16
-                case 'd':
17
-                    yydebug = 1;
18
-                    break;
19
-
20
-                case 't':
21
-                    printtree = 1;
22
-                    break;
23
-					
12
+	if(argc>1) {
13
+		c = argv[1];
14
+		while(*c) {
15
+			switch(*c) {
16
+				case 'd':
17
+					yydebug = 1;
18
+					break;
19
+
20
+				case 't':
21
+					printtree = 1;
22
+					break;
23
+
24 24
 				case 'r':
25 25
 					if(argc<2) {
26 26
 						printf("r option requires file\n");
27 27
 						return 1;
28 28
 					}
29 29
 					prgstream = fopen(argv[2], "r");
30
-            }
31
-            c++;
32
-        }
33
-    }
34
-    
35
-    if(!prgstream) {
30
+			}
31
+			c++;
32
+		}
33
+	}
34
+
35
+	if(!prgstream) {
36 36
 		printf("No input program (check filenames)\n");
37 37
 		return 1;
38 38
 	}
39 39
 
40
-    program = sol_compile_file(prgstream);
41
-	
42
-	if(prgstream!=stdin) fclose(prgstream);
40
+	program = sol_compile_file(prgstream);
41
+
42
+	if(prgstream!=stdin) {
43
+		fclose(prgstream);
44
+	}
43 45
 
44 46
 	sol_state_init(&state);
45
-    if(printtree) st_print(&state, program);
47
+	if(printtree) {
48
+		st_print(&state, program);
49
+	}
46 50
 
47
-    if(program) {
48
-        sol_exec(&state, program);
51
+	if(program) {
52
+		sol_exec(&state, program);
49 53
 		if(sol_has_error(&state)) {
50 54
 			printf("Error: ");
51 55
 			ob_print(state.error);
@@ -53,10 +57,10 @@ int main(int argc, char **argv) {
53 57
 		}
54 58
 		//st_free(program);
55 59
 		sol_state_cleanup(&state);
56
-        return 0;
57
-    }
60
+		return 0;
61
+	}
58 62
 
59
-    printf("NULL program (probably a syntax error)\n");
63
+	printf("NULL program (probably a syntax error)\n");
60 64
 
61
-    return 1;
65
+	return 1;
62 66
 }

+ 76
- 48
state.c View File

@@ -15,9 +15,15 @@ int sol_state_init(sol_state_t *state) {
15 15
 	state->sflag = SF_NORMAL;
16 16
 
17 17
 	// If any of the following fail, some very weird things are happening.
18
-	if(!(state->None = sol_new_singlet(state, "None"))) goto cleanup;
19
-	if(!(state->OutOfMemory = sol_new_singlet(state, "OutOfMemory"))) goto cleanup;
20
-	if(!(state->StopIteration = sol_new_singlet(state, "StopIteration"))) goto cleanup;
18
+	if(!(state->None = sol_new_singlet(state, "None"))) {
19
+		goto cleanup;
20
+	}
21
+	if(!(state->OutOfMemory = sol_new_singlet(state, "OutOfMemory"))) {
22
+		goto cleanup;
23
+	}
24
+	if(!(state->StopIteration = sol_new_singlet(state, "StopIteration"))) {
25
+		goto cleanup;
26
+	}
21 27
 
22 28
 	// We can now use the normal error reporting mechanism, now
23 29
 	// that errors are distinguishable. Set that up now.
@@ -25,7 +31,7 @@ int sol_state_init(sol_state_t *state) {
25 31
 	//Initialize all of the builtin operations
26 32
 	//(these ones are technically already pointed to by None/OOM)
27 33
 	sol_ops_init(&(state->NullOps));
28
-	
34
+
29 35
 	state->SingletOps = state->NullOps;
30 36
 	state->IntOps = state->NullOps;
31 37
 	state->FloatOps = state->NullOps;
@@ -40,10 +46,10 @@ int sol_state_init(sol_state_t *state) {
40 46
 	state->DyLibOps = state->NullOps;
41 47
 	state->DySymOps = state->NullOps;
42 48
 	state->StreamOps = state->NullOps;
43
-	
49
+
44 50
 	state->SingletOps.tname = "singlet";
45 51
 	state->SingletOps.tostring = sol_f_singlet_tostring;
46
-	
52
+
47 53
 	state->IntOps.tname = "int";
48 54
 	state->IntOps.add = sol_f_int_add;
49 55
 	state->IntOps.sub = sol_f_int_sub;
@@ -60,7 +66,7 @@ int sol_state_init(sol_state_t *state) {
60 66
 	state->IntOps.toint = sol_f_int_toint;
61 67
 	state->IntOps.tofloat = sol_f_int_tofloat;
62 68
 	state->IntOps.tostring = sol_f_int_tostring;
63
-	
69
+
64 70
 	state->FloatOps.tname = "float";
65 71
 	state->FloatOps.add = sol_f_float_add;
66 72
 	state->FloatOps.sub = sol_f_float_sub;
@@ -70,7 +76,7 @@ int sol_state_init(sol_state_t *state) {
70 76
 	state->FloatOps.toint = sol_f_float_toint;
71 77
 	state->FloatOps.tofloat = sol_f_float_tofloat;
72 78
 	state->FloatOps.tostring = sol_f_float_tostring;
73
-	
79
+
74 80
 	state->StringOps.tname = "string";
75 81
 	state->StringOps.add = sol_f_str_add;
76 82
 	state->StringOps.mul = sol_f_str_mul;
@@ -83,7 +89,7 @@ int sol_state_init(sol_state_t *state) {
83 89
 	state->StringOps.tostring = sol_f_str_tostring;
84 90
 	state->StringOps.repr = sol_f_str_repr;
85 91
 	state->StringOps.free = sol_f_str_free;
86
-	
92
+
87 93
 	state->ListOps.tname = "list";
88 94
 	state->ListOps.add = sol_f_list_add;
89 95
 	state->ListOps.mul = sol_f_list_mul;
@@ -94,7 +100,7 @@ int sol_state_init(sol_state_t *state) {
94 100
 	state->ListOps.iter = sol_f_list_iter;
95 101
 	state->ListOps.tostring = sol_f_list_tostring;
96 102
 	state->ListOps.free = sol_f_list_free;
97
-	
103
+
98 104
 	state->MapOps.tname = "map";
99 105
 	state->MapOps.add = sol_f_map_add;
100 106
 	state->MapOps.call = sol_f_map_call;
@@ -105,63 +111,69 @@ int sol_state_init(sol_state_t *state) {
105 111
 	state->MapOps.tostring = sol_f_map_tostring;
106 112
 	state->MapOps.repr = sol_f_map_repr;
107 113
 	state->MapOps.free = sol_f_map_free;
108
-	
114
+
109 115
 	state->MCellOps.tname = "mcell";
110 116
 	state->MCellOps.tostring = sol_f_mcell_tostring;
111 117
 	state->MCellOps.free = sol_f_mcell_free;
112
-	
118
+
113 119
 	state->FuncOps.tname = "function";
114 120
 	state->FuncOps.call = sol_f_func_call;
115 121
 	state->FuncOps.index = sol_f_func_index;
116 122
 	state->FuncOps.setindex = sol_f_func_setindex;
117 123
 	state->FuncOps.tostring = sol_f_func_tostring;
118
-	
124
+
119 125
 	state->CFuncOps.tname = "cfunction";
120 126
 	state->CFuncOps.call = sol_f_cfunc_call;
121 127
 	state->CFuncOps.tostring = sol_f_cfunc_tostring;
122
-	
128
+
123 129
 	state->ASTNodeOps.tname = "astnode";
124 130
 	state->ASTNodeOps.call = sol_f_astnode_call;
125 131
 	state->ASTNodeOps.index = sol_f_astnode_index;
126 132
 	state->ASTNodeOps.setindex = sol_f_astnode_setindex;
127 133
 	state->ASTNodeOps.tostring = sol_f_astnode_tostring;
128
-	
134
+
129 135
 	state->BufferOps.tname = "buffer";
130 136
 	state->BufferOps.index = sol_f_buffer_index;
131 137
 	state->BufferOps.tostring = sol_f_buffer_tostring;
132 138
 	state->BufferOps.free = sol_f_buffer_free;
133
-	
139
+
134 140
 	state->DyLibOps.tname = "dylib";
135 141
 	state->DyLibOps.index = sol_f_dylib_index;
136 142
 	state->DyLibOps.free = sol_f_dylib_free;
137 143
 	state->DyLibOps.tostring = sol_f_dylib_tostring;
138
-	
144
+
139 145
 	state->DySymOps.tname = "dysym";
140 146
 	state->DySymOps.call = sol_f_dysym_call;
141 147
 	state->DySymOps.index = sol_f_dysym_index;
142 148
 	state->DySymOps.setindex = sol_f_dysym_setindex;
143 149
 	state->DySymOps.tostring = sol_f_dysym_tostring;
144
-	
150
+
145 151
 	state->StreamOps.tname = "stream";
146 152
 	state->StreamOps.blsh = sol_f_stream_blsh;
147 153
 	state->StreamOps.brsh = sol_f_stream_brsh;
148 154
 	state->StreamOps.index = sol_f_stream_index;
149 155
 	state->StreamOps.free = sol_f_stream_free;
150 156
 	state->StreamOps.tostring = sol_f_stream_tostring;
151
-	
157
+
152 158
 	state->obfuncs.copy = (dsl_copier) sol_obj_acquire;
153 159
 	state->obfuncs.destr = (dsl_destructor) sol_obj_free;
154 160
 
155 161
 	state->error = state->None;
156 162
 	state->scopes = sol_new_list(state);
157
-	if(sol_has_error(state)) goto cleanup;
163
+	if(sol_has_error(state)) {
164
+		goto cleanup;
165
+	}
158 166
 	globals = sol_new_map(state);
159 167
 	state->modules = sol_new_map(state);
160 168
 	state->methods = sol_new_map(state);
161
-	if(sol_has_error(state)) goto cleanup;
169
+	if(sol_has_error(state)) {
170
+		goto cleanup;
171
+	}
162 172
 	sol_list_insert(state, state->scopes, 0, globals);
163 173
 	sol_obj_free(globals);
164
-	if(sol_has_error(state)) goto cleanup;
174
+	if(sol_has_error(state)) {
175
+		goto cleanup;
176
+	}
165 177
 	// I'm going to buffer all of these together because I can.
166 178
 	sol_map_set_name(state, globals, "OutOfMemory", state->OutOfMemory);
167 179
 	sol_map_set_name(state, globals, "StopIteration", state->StopIteration);
@@ -182,7 +194,7 @@ int sol_state_init(sol_state_t *state) {
182 194
 	sol_map_set_name(state, globals, "parse", sol_new_cfunc(state, sol_f_parse));
183 195
 	sol_map_set_name(state, globals, "ord", sol_new_cfunc(state, sol_f_ord));
184 196
 	sol_map_set_name(state, globals, "chr", sol_new_cfunc(state, sol_f_chr));
185
-	
197
+
186 198
 	mod = sol_new_map(state);
187 199
 	sol_map_set_name(state, mod, "getref", sol_new_cfunc(state, sol_f_debug_getref));
188 200
 	sol_map_set_name(state, mod, "setref", sol_new_cfunc(state, sol_f_debug_setref));
@@ -194,14 +206,14 @@ int sol_state_init(sol_state_t *state) {
194 206
 	sol_map_set_name(state, mod, "hexversion", sol_new_int(state, HEXVER));
195 207
 	sol_register_module_name(state, "debug", mod);
196 208
 	sol_obj_free(mod);
197
-	
209
+
198 210
 	mod = sol_new_map(state);
199 211
 	sol_map_set_name(state, mod, "str", sol_new_cfunc(state, sol_f_iter_str));
200 212
 	sol_map_set_name(state, mod, "list", sol_new_cfunc(state, sol_f_iter_list));
201 213
 	sol_map_set_name(state, mod, "map", sol_new_cfunc(state, sol_f_iter_map));
202 214
 	sol_register_module_name(state, "iter", mod);
203 215
 	sol_obj_free(mod);
204
-	
216
+
205 217
 	mod = sol_new_map(state);
206 218
 	sol_map_set_name(state, mod, "ST_EXPR", sol_new_int(state, ST_EXPR));
207 219
 	sol_map_set_name(state, mod, "ST_IFELSE", sol_new_int(state, ST_IFELSE));
@@ -251,7 +263,7 @@ int sol_state_init(sol_state_t *state) {
251 263
 	sol_map_invert(state, mod);
252 264
 	sol_map_set_name(state, mod, "print", sol_new_cfunc(state, sol_f_ast_print));
253 265
 	sol_register_module_name(state, "ast", mod);
254
-	
266
+
255 267
 	btype = sol_new_map(state);
256 268
 	sol_map_set_name(state, btype, "none", sol_new_int(state, BUF_NONE));
257 269
 	sol_map_set_name(state, btype, "uint8", sol_new_int(state, BUF_UINT8));
@@ -273,7 +285,7 @@ int sol_state_init(sol_state_t *state) {
273 285
 	sol_map_set_name(state, btype, "cstr", sol_new_int(state, BUF_CSTR));
274 286
 	sol_map_set_name(state, btype, "ptr", sol_new_int(state, BUF_PTR));
275 287
 	sol_map_invert(state, btype);
276
-	
288
+
277 289
 	bsize = sol_new_map(state);
278 290
 	sol_map_set_name(state, bsize, "uint8", sol_new_int(state, sizeof(uint8_t)));
279 291
 	sol_map_set_name(state, bsize, "uint16", sol_new_int(state, sizeof(uint16_t)));
@@ -293,7 +305,7 @@ int sol_state_init(sol_state_t *state) {
293 305
 	sol_map_set_name(state, bsize, "double", sol_new_int(state, sizeof(double)));
294 306
 	sol_map_set_name(state, bsize, "cstr", sol_new_int(state, sizeof(char *)));
295 307
 	sol_map_set_name(state, bsize, "ptr", sol_new_int(state, sizeof(void *)));
296
-	
308
+
297 309
 	bobj = sol_new_map(state);
298 310
 	sol_map_set_name(state, bobj, "SOL_SINGLET", sol_new_int(state, SOL_SINGLET));
299 311
 	sol_map_set_name(state, bobj, "SOL_INTEGER", sol_new_int(state, SOL_INTEGER));
@@ -312,7 +324,7 @@ int sol_state_init(sol_state_t *state) {
312 324
 	sol_map_set_name(state, bobj, "SOL_STREAM", sol_new_int(state, SOL_STREAM));
313 325
 	sol_map_set_name(state, bobj, "SOL_CDATA", sol_new_int(state, SOL_CDATA));
314 326
 	sol_map_invert(state, bobj);
315
-	
327
+
316 328
 	mod = sol_new_map(state);
317 329
 	sol_map_set_name(state, mod, "new", sol_new_cfunc(state, sol_f_buffer_new));
318 330
 	sol_map_set_name(state, mod, "fromstring", sol_new_cfunc(state, sol_f_buffer_fromstring));
@@ -326,7 +338,7 @@ int sol_state_init(sol_state_t *state) {
326 338
 	sol_obj_free(bobj);
327 339
 	sol_obj_free(bsize);
328 340
 	sol_obj_free(btype);
329
-	
341
+
330 342
 	mod = sol_new_map(state);
331 343
 	sol_map_set_name(state, mod, "MODE_READ", sol_new_int(state, MODE_READ));
332 344
 	sol_map_set_name(state, mod, "MODE_WRITE", sol_new_int(state, MODE_WRITE));
@@ -344,7 +356,7 @@ int sol_state_init(sol_state_t *state) {
344 356
 	sol_map_set_name(state, mod, "open", sol_new_cfunc(state, sol_f_stream_open));
345 357
 	sol_register_module_name(state, "io", mod);
346 358
 	sol_obj_free(mod);
347
-	
359
+
348 360
 	meths = sol_new_map(state);
349 361
 	sol_map_set_name(state, meths, "get", sol_new_cfunc(state, sol_f_buffer_get));
350 362
 	sol_map_set_name(state, meths, "set", sol_new_cfunc(state, sol_f_buffer_set));
@@ -362,7 +374,7 @@ int sol_state_init(sol_state_t *state) {
362 374
 	sol_map_set_name(state, meths, "filter", sol_new_cfunc(state, sol_f_list_filter));
363 375
 	sol_register_methods_name(state, "list", meths);
364 376
 	sol_obj_free(meths);
365
-	
377
+
366 378
 	meths = sol_new_map(state);
367 379
 	sol_map_set_name(state, meths, "read", sol_new_cfunc(state, sol_f_stream_read));
368 380
 	sol_map_set_name(state, meths, "write", sol_new_cfunc(state, sol_f_stream_write));
@@ -372,20 +384,22 @@ int sol_state_init(sol_state_t *state) {
372 384
 	sol_map_set_name(state, meths, "eof", sol_new_cfunc(state, sol_f_stream_eof));
373 385
 	sol_register_methods_name(state, "stream", meths);
374 386
 	sol_obj_free(meths);
375
-	
387
+
376 388
 	meths = sol_new_map(state);
377 389
 	sol_map_set_name(state, meths, "sub", sol_new_cfunc(state, sol_f_str_sub));
378 390
 	sol_map_set_name(state, meths, "split", sol_new_cfunc(state, sol_f_str_split));
379 391
 	sol_map_set_name(state, meths, "find", sol_new_cfunc(state, sol_f_str_find));
380 392
 	sol_register_methods_name(state, "string", meths);
381 393
 	sol_obj_free(meths);
382
-	
383
-	if(sol_has_error(state)) goto cleanup;
394
+
395
+	if(sol_has_error(state)) {
396
+		goto cleanup;
397
+	}
384 398
 
385 399
 	// We're all set!
386 400
 	return 1;
387 401
 
388
-	cleanup:
402
+cleanup:
389 403
 	sol_obj_free(state->None);
390 404
 	sol_obj_free(state->OutOfMemory);
391 405
 	sol_obj_free(state->StopIteration);
@@ -398,7 +412,9 @@ void sol_state_cleanup(sol_state_t *state) {
398 412
 	sol_obj_free(state->None);
399 413
 	sol_obj_free(state->OutOfMemory);
400 414
 	sol_obj_free(state->StopIteration);
401
-	if(state->ret) sol_obj_free(state->ret);
415
+	if(state->ret) {
416
+		sol_obj_free(state->ret);
417
+	}
402 418
 	sol_obj_free(state->modules);
403 419
 	sol_obj_free(state->methods);
404 420
 }
@@ -422,7 +438,7 @@ sol_object_t *sol_state_resolve(sol_state_t *state, sol_object_t *key) {
422 438
 	}
423 439
 	dsl_free_seq_iter(iter);
424 440
 	sol_obj_free(args);
425
-	
441
+
426 442
 	temp = sol_get_module(state, key);
427 443
 	if(!sol_is_none(state, temp)) {
428 444
 		return temp;
@@ -434,7 +450,9 @@ sol_object_t *sol_state_resolve(sol_state_t *state, sol_object_t *key) {
434 450
 sol_object_t *sol_state_resolve_name(sol_state_t *state, const char *name) {
435 451
 	sol_object_t *key = sol_new_string(state, name), *temp;
436 452
 
437
-	if(sol_has_error(state)) return sol_incref(state->None);
453
+	if(sol_has_error(state)) {
454
+		return sol_incref(state->None);
455
+	}
438 456
 
439 457
 	temp = sol_state_resolve(state, key);
440 458
 	sol_obj_free(key);
@@ -467,7 +485,9 @@ void sol_state_assign(sol_state_t *state, sol_object_t *key, sol_object_t *val)
467 485
 void sol_state_assign_name(sol_state_t *state, const char *name, sol_object_t *val) {
468 486
 	sol_object_t *key = sol_new_string(state, name);
469 487
 
470
-	if(sol_has_error(state)) return;
488
+	if(sol_has_error(state)) {
489
+		return;
490
+	}
471 491
 
472 492
 	sol_state_assign(state, key, val);
473 493
 	sol_obj_free(key);
@@ -482,7 +502,7 @@ void sol_state_assign_l(sol_state_t *state, sol_object_t *key, sol_object_t *val
482 502
 		sol_set_error_string(state, "Local state does not exist");
483 503
 		return;
484 504
 	}
485
-	
505
+
486 506
 	args=sol_new_list(state);
487 507
 	sol_list_insert(state, args, 0, cur);
488 508
 	sol_list_insert(state, args, 1, key);
@@ -494,18 +514,20 @@ void sol_state_assign_l(sol_state_t *state, sol_object_t *key, sol_object_t *val
494 514
 void sol_state_assign_l_name(sol_state_t *state, const char *name, sol_object_t *val) {
495 515
 	sol_object_t *key = sol_new_string(state, name);
496 516
 
497
-	if(sol_has_error(state)) return;
517
+	if(sol_has_error(state)) {
518
+		return;
519
+	}
498 520
 
499 521
 	sol_state_assign_l(state, key, val);
500 522
 	sol_obj_free(key);
501 523
 }
502 524
 
503 525
 void sol_state_push_scope(sol_state_t *state, sol_object_t *scope) {
504
-    sol_list_push(state, state->scopes, scope);
526
+	sol_list_push(state, state->scopes, scope);
505 527
 }
506 528
 
507 529
 sol_object_t *sol_state_pop_scope(sol_state_t *state) {
508
-    return sol_list_pop(state, state->scopes);
530
+	return sol_list_pop(state, state->scopes);
509 531
 }
510 532
 
511 533
 sol_object_t *sol_get_error(sol_state_t *state) {
@@ -521,7 +543,9 @@ sol_object_t *sol_set_error(sol_state_t *state, sol_object_t *err) {
521 543
 sol_object_t *sol_set_error_string(sol_state_t *state, const char *serr) {
522 544
 	sol_object_t *err = sol_new_string(state, serr), *res;
523 545
 
524
-	if(sol_has_error(state)) return sol_incref(state->None);
546
+	if(sol_has_error(state)) {
547
+		return sol_incref(state->None);
548
+	}
525 549
 
526 550
 	res = sol_set_error(state, err);
527 551
 	sol_obj_free(err);
@@ -537,7 +561,9 @@ void sol_clear_error(sol_state_t *state) {
537 561
 }
538 562
 
539 563
 void sol_init_traceback(sol_state_t *state) {
540
-	if(state->traceback) sol_obj_free(state->traceback);
564
+	if(state->traceback) {
565
+		sol_obj_free(state->traceback);
566
+	}
541 567
 	state->traceback = sol_new_list(state);
542 568
 }
543 569
 
@@ -551,7 +577,9 @@ void sol_add_traceback(sol_state_t *state, sol_object_t *node) {
551 577
 }
552 578
 
553 579
 sol_object_t *sol_traceback(sol_state_t *state) {
554
-	if(state->traceback) return sol_incref(state->traceback);
580
+	if(state->traceback) {
581
+		return sol_incref(state->traceback);
582
+	}
555 583
 	return sol_incref(state->None);
556 584
 }
557 585
 
@@ -622,7 +650,7 @@ sol_object_t *sol_get_stderr(sol_state_t *state) {
622 650
 
623 651
 void sol_ops_init(sol_ops_t *ops) {
624 652
 	ops->tname = "unknown";
625
-    ops->add = sol_f_not_impl;
653
+	ops->add = sol_f_not_impl;
626 654
 	ops->sub = sol_f_not_impl;
627 655
 	ops->mul = sol_f_not_impl;
628 656
 	ops->div = sol_f_not_impl;

+ 32
- 22
util.c View File

@@ -3,31 +3,41 @@
3 3
 #include <stdarg.h>
4 4
 
5 5
 sol_object_t *sol_util_call(sol_state_t *state, sol_object_t *func, int *error, int elems, ...) {
6
-    va_list va;
7
-    sol_object_t *args = sol_new_list(state), *res = NULL;
8
-    int i;
6
+	va_list va;
7
+	sol_object_t *args = sol_new_list(state), *res = NULL;
8
+	int i;
9 9
 
10
-    if(sol_has_error(state)) return sol_incref(state->None);
11
-    if(error) *error = 0;
10
+	if(sol_has_error(state)) {
11
+		return sol_incref(state->None);
12
+	}
13
+	if(error) {
14
+		*error = 0;
15
+	}
12 16
 
13
-    sol_list_insert(state, args, 0, func);
17
+	sol_list_insert(state, args, 0, func);
14 18
 
15
-    va_start(va, elems);
16
-    for(i=0; i<elems; i++) {
17
-        sol_list_insert(state, args, i+1, va_arg(va, sol_object_t *));
18
-    }
19
-    va_end(va);
19
+	va_start(va, elems);
20
+	for(i=0; i<elems; i++) {
21
+		sol_list_insert(state, args, i+1, va_arg(va, sol_object_t *));
22
+	}
23
+	va_end(va);
20 24
 
21
-    if(!func->ops->call) return sol_incref(state->None);
22
-    res = func->ops->call(state, args);
23
-    if(!res) res = sol_incref(state->None);
24
-    if(sol_has_error(state)) {
25
-        sol_object_t *err = sol_get_error(state);
26
-        sol_clear_error(state);
27
-        sol_obj_free(res);
28
-        if(error) *error = 1;
29
-        res = err;
30
-    }
25
+	if(!func->ops->call) {
26
+		return sol_incref(state->None);
27
+	}
28
+	res = func->ops->call(state, args);
29
+	if(!res) {
30
+		res = sol_incref(state->None);
31
+	}
32
+	if(sol_has_error(state)) {
33
+		sol_object_t *err = sol_get_error(state);
34
+		sol_clear_error(state);
35
+		sol_obj_free(res);
36
+		if(error) {
37
+			*error = 1;
38
+		}
39
+		res = err;
40
+	}
31 41
 
32
-    return res;
42
+	return res;
33 43
 }

Loading…
Cancel
Save