|
|
1.117 paf 1: /** @file
1.118 paf 2: Parser: executor part of request class.
3:
1.378 moko 4: Copyright (c) 2001-2015 Art. Lebedev Studio (http://www.artlebedev.com)
1.218 paf 5: Author: Alexandr Petrosian <paf@design.ru> (http://paf.design.ru)
1.243 paf 6: */
1.118 paf 7:
1.152 paf 8: #include "pa_opcode.h"
1.8 paf 9: #include "pa_array.h"
1.11 paf 10: #include "pa_request.h"
1.15 paf 11: #include "pa_vstring.h"
1.22 paf 12: #include "pa_vhash.h"
1.167 parser 13: #include "pa_vvoid.h"
1.145 paf 14: #include "pa_vcode_frame.h"
1.321 misha 15: #include "pa_vmethod_frame.h"
1.38 paf 16: #include "pa_vobject.h"
1.49 paf 17: #include "pa_vdouble.h"
1.54 paf 18: #include "pa_vbool.h"
1.94 paf 19: #include "pa_vtable.h"
1.132 paf 20: #include "pa_vfile.h"
1.144 paf 21: #include "pa_vimage.h"
1.194 parser 22: #include "pa_wwrapper.h"
1.1 paf 23:
1.379 ! moko 24: volatile const char * IDENT_EXECUTE_C="$Id: execute.C,v 1.378 2015/10/26 01:21:58 moko Exp $" IDENT_PA_OPCODE_H IDENT_PA_OPERATION_H IDENT_PA_VCODE_FRAME_H IDENT_PA_WWRAPPER_H;
1.368 moko 25:
1.233 paf 26: //#define DEBUG_EXECUTE
1.157 parser 27:
28: #ifdef DEBUG_EXECUTE
1.1 paf 29: char *opcode_name[]={
1.49 paf 30: // literals
1.109 paf 31: "VALUE", "CURLY_CODE__STORE_PARAM", "EXPR_CODE__STORE_PARAM",
1.209 paf 32: "NESTED_CODE",
1.49 paf 33:
34: // actions
1.187 parser 35: "WITH_ROOT", "WITH_SELF", "WITH_READ", "WITH_WRITE",
1.328 misha 36: "VALUE__GET_CLASS",
1.182 parser 37: "CONSTRUCT_VALUE", "CONSTRUCT_EXPR", "CURLY_CODE__CONSTRUCT",
1.108 paf 38: "WRITE_VALUE", "WRITE_EXPR_RESULT", "STRING__WRITE",
1.328 misha 39: #ifdef OPTIMIZE_BYTECODE_GET_ELEMENT
40: "VALUE__GET_ELEMENT_OR_OPERATOR",
41: #else
42: "GET_ELEMENT_OR_OPERATOR",
43: #endif
44: "GET_ELEMENT",
1.346 misha 45: "GET_ELEMENT__WRITE",
46: #ifdef OPTIMIZE_BYTECODE_GET_ELEMENT
47: "VALUE__GET_ELEMENT",
48: "VALUE__GET_ELEMENT__WRITE",
1.347 misha 49: "WITH_ROOT__VALUE__GET_ELEMENT",
1.346 misha 50: #endif
1.335 misha 51: #ifdef OPTIMIZE_BYTECODE_GET_OBJECT_ELEMENT
52: "GET_OBJECT_ELEMENT",
53: "GET_OBJECT_ELEMENT__WRITE",
54: #endif
55: #ifdef OPTIMIZE_BYTECODE_GET_OBJECT_VAR_ELEMENT
56: "GET_OBJECT_VAR_ELEMENT",
57: "GET_OBJECT_VAR_ELEMENT__WRITE",
1.334 misha 58: #endif
1.345 misha 59: #ifdef OPTIMIZE_BYTECODE_GET_SELF_ELEMENT
60: "WITH_SELF__VALUE__GET_ELEMENT",
61: "WITH_SELF__VALUE__GET_ELEMENT__WRITE",
62: #endif
1.376 moko 63:
64: #ifdef FEATURE_GET_ELEMENT4CALL
65: "GET_ELEMENT4CALL",
66: #ifdef OPTIMIZE_BYTECODE_GET_OBJECT_ELEMENT
67: "GET_OBJECT_ELEMENT4CALL",
68: #endif
69: #ifdef OPTIMIZE_BYTECODE_GET_OBJECT_VAR_ELEMENT
70: "GET_OBJECT_VAR_ELEMENT4CALL",
71: #endif
72: #endif // FEATURE_GET_ELEMENT4CALL
73:
1.232 paf 74: "OBJECT_POOL", "STRING_POOL",
1.348 misha 75: "PREPARE_TO_CONSTRUCT_OBJECT",
76: "CONSTRUCT_OBJECT",
77: "CONSTRUCT_OBJECT__WRITE",
78: "PREPARE_TO_EXPRESSION",
1.232 paf 79: "CALL", "CALL__WRITE",
1.49 paf 80:
1.337 misha 81: #ifdef OPTIMIZE_BYTECODE_CONSTRUCT
1.344 misha 82: "WITH_ROOT__VALUE__CONSTRUCT_EXPR",
83: "WITH_ROOT__VALUE__CONSTRUCT_VALUE",
84: "WITH_WRITE__VALUE__CONSTRUCT_EXPR",
85: "WITH_WRITE__VALUE__CONSTRUCT_VALUE",
1.345 misha 86: "WITH_SELF__VALUE__CONSTRUCT_EXPR",
87: "WITH_SELF__VALUE__CONSTRUCT_VALUE",
1.337 misha 88: #endif
89:
1.372 misha 90: #ifdef OPTIMIZE_BYTECODE_GET_ELEMENT__SPECIAL
91: "GET_ELEMENT__SPECIAL",
92: "GET_ELEMENT__SPECIAL__WRITE",
93: #endif
1.49 paf 94: // expression ops: unary
1.148 paf 95: "NEG", "INV", "NOT", "DEF", "IN", "FEXISTS", "DEXISTS",
1.49 paf 96: // expression ops: binary
1.201 paf 97: "SUB", "ADD", "MUL", "DIV", "MOD", "INTDIV",
1.275 paf 98: "BIN_SL", "BIN_SR",
1.56 paf 99: "BIN_AND", "BIN_OR", "BIN_XOR",
100: "LOG_AND", "LOG_OR", "LOG_XOR",
1.49 paf 101: "NUM_LT", "NUM_GT", "NUM_LE", "NUM_GE", "NUM_EQ", "NUM_NE",
1.103 paf 102: "STR_LT", "STR_GT", "STR_LE", "STR_GE", "STR_EQ", "STR_NE",
103: "IS"
1.1 paf 104: };
105:
1.342 misha 106: const char* debug_value_to_cstr(Value& value){
107: const String* string=value.get_string();
108:
109: if(string)
110: return string->cstr();
111: else
112: if(value.is_bool())
113: return value.as_bool()?"<true>":"<false>";
114: else
115: return "<value>";
116: }
117:
1.297 paf 118: void va_debug_printf(SAPI_Info& sapi_info, const char* fmt,va_list args) {
1.127 paf 119: char buf[MAX_STRING];
120: vsnprintf(buf, MAX_STRING, fmt, args);
1.297 paf 121: SAPI::log(sapi_info, "%s", buf);
1.107 paf 122: }
123:
1.297 paf 124: void debug_printf(SAPI_Info& sapi_info, const char* fmt, ...) {
1.334 misha 125: va_list args;
126: va_start(args, fmt);
127: va_debug_printf(sapi_info, fmt, args);
128: va_end(args);
1.105 paf 129: }
130:
1.297 paf 131: void debug_dump(SAPI_Info& sapi_info, int level, ArrayOperation& ops) {
132: Array_iterator<Operation> i(ops);
1.190 parser 133: while(i.has_next()) {
1.323 misha 134: OP::OPCODE opcode=i.next().code;
1.1 paf 135:
1.337 misha 136: #if defined(OPTIMIZE_BYTECODE_GET_OBJECT_ELEMENT) || defined(OPTIMIZE_BYTECODE_GET_OBJECT_VAR_ELEMENT)
1.334 misha 137: if(
1.335 misha 138: 1==0
139: #ifdef OPTIMIZE_BYTECODE_GET_OBJECT_ELEMENT
140: || opcode==OP::OP_GET_OBJECT_ELEMENT
141: || opcode==OP::OP_GET_OBJECT_ELEMENT__WRITE
1.376 moko 142: #ifdef FEATURE_GET_ELEMENT4CALL
143: || opcode==OP::OP_GET_OBJECT_ELEMENT4CALL
144: #endif
1.335 misha 145: #endif
146: #ifdef OPTIMIZE_BYTECODE_GET_OBJECT_VAR_ELEMENT
147: || opcode==OP::OP_GET_OBJECT_VAR_ELEMENT
148: || opcode==OP::OP_GET_OBJECT_VAR_ELEMENT__WRITE
1.376 moko 149: #ifdef FEATURE_GET_ELEMENT4CALL
150: || opcode==OP::OP_GET_OBJECT_VAR_ELEMENT4CALL
151: #endif
1.335 misha 152: #endif
1.334 misha 153: ){
154: i.next(); // skip origin
155: Value& value1=*i.next().value;
156: i.next(); // skip origin
157: Value& value2=*i.next().value;
158: debug_printf(sapi_info,
159: "%*s%s"
160: " \"%s\" \"%s\"",
161: level*4, "", opcode_name[opcode],
1.342 misha 162: debug_value_to_cstr(value1), debug_value_to_cstr(value2));
1.334 misha 163: continue;
164: }
165: #endif
1.348 misha 166: if(
167: opcode==OP::OP_CONSTRUCT_OBJECT
168: || opcode==OP::OP_CONSTRUCT_OBJECT__WRITE
169: ){
170: i.next(); // skip origin
171: Value& value1=*i.next().value;
172: i.next(); // skip origin
173: Value& value2=*i.next().value;
174: debug_printf(sapi_info,
175: "%*s%s"
176: " \"%s\" \"%s\"",
177: level*4, "", opcode_name[opcode],
178: debug_value_to_cstr(value1), debug_value_to_cstr(value2));
179:
180: if(ArrayOperation* local_ops=i.next().ops)
181: debug_dump(sapi_info, level+1, *local_ops);
182: continue;
183: }
1.328 misha 184: if(
185: opcode==OP::OP_VALUE
186: || opcode==OP::OP_STRING__WRITE
187: || opcode==OP::OP_VALUE__GET_CLASS
188: #ifdef OPTIMIZE_BYTECODE_GET_ELEMENT
189: || opcode==OP::OP_VALUE__GET_ELEMENT
190: || opcode==OP::OP_VALUE__GET_ELEMENT__WRITE
191: || opcode==OP::OP_VALUE__GET_ELEMENT_OR_OPERATOR
1.347 misha 192: || opcode==OP::OP_WITH_ROOT__VALUE__GET_ELEMENT
1.328 misha 193: #endif
1.345 misha 194: #ifdef OPTIMIZE_BYTECODE_GET_SELF_ELEMENT
195: || opcode==OP::OP_WITH_SELF__VALUE__GET_ELEMENT
196: || opcode==OP::OP_WITH_SELF__VALUE__GET_ELEMENT__WRITE
197: #endif
1.342 misha 198: #ifdef OPTIMIZE_BYTECODE_CONSTRUCT
1.344 misha 199: || opcode==OP::OP_WITH_ROOT__VALUE__CONSTRUCT_EXPR
200: || opcode==OP::OP_WITH_ROOT__VALUE__CONSTRUCT_VALUE
201: || opcode==OP::OP_WITH_WRITE__VALUE__CONSTRUCT_EXPR
202: || opcode==OP::OP_WITH_WRITE__VALUE__CONSTRUCT_VALUE
1.345 misha 203: || opcode==OP::OP_WITH_SELF__VALUE__CONSTRUCT_EXPR
204: || opcode==OP::OP_WITH_SELF__VALUE__CONSTRUCT_VALUE
1.342 misha 205: #endif
1.328 misha 206: ) {
1.297 paf 207: Operation::Origin origin=i.next().origin;
208: Value& value=*i.next().value;
1.342 misha 209:
1.297 paf 210: debug_printf(sapi_info,
1.133 paf 211: "%*s%s"
212: " \"%s\" %s",
1.297 paf 213: level*4, "", opcode_name[opcode],
1.342 misha 214: debug_value_to_cstr(value), value.type());
1.133 paf 215: continue;
1.15 paf 216: }
1.348 misha 217:
1.297 paf 218: debug_printf(sapi_info, "%*s%s", level*4, "", opcode_name[opcode]);
1.1 paf 219:
1.297 paf 220: switch(opcode) {
1.323 misha 221: case OP::OP_CURLY_CODE__STORE_PARAM:
222: case OP::OP_EXPR_CODE__STORE_PARAM:
223: case OP::OP_CURLY_CODE__CONSTRUCT:
224: case OP::OP_NESTED_CODE:
1.346 misha 225: case OP::OP_OBJECT_POOL:
1.323 misha 226: case OP::OP_STRING_POOL:
227: case OP::OP_CALL:
228: case OP::OP_CALL__WRITE:
1.297 paf 229: if(ArrayOperation* local_ops=i.next().ops)
230: debug_dump(sapi_info, level+1, *local_ops);
1.1 paf 231: }
232: }
233: }
1.336 misha 234: #define DEBUG_PRINT_STR(str) debug_printf(sapi_info, str);
235: #define DEBUG_PRINT_STRING(value) debug_printf(sapi_info, " \"%s\" ", value.cstr());
1.342 misha 236: #define DEBUG_PRINT_VALUE_AND_TYPE(value) debug_printf(sapi_info, " \"%s\" %s", debug_value_to_cstr(value), value.type());
1.336 misha 237: #define DEBUG_PRINT_OPS(local_ops) \
238: debug_printf(sapi_info, \
239: " (%d)\n", local_ops?local_ops->count():0); \
240: if(local_ops) debug_dump(sapi_info, 1, *local_ops);
241:
242: #else
243: #define DEBUG_PRINT_STR(str)
244: #define DEBUG_PRINT_STRING(value)
1.342 misha 245: #define DEBUG_PRINT_VALUE_AND_TYPE(value)
1.336 misha 246: #define DEBUG_PRINT_OPS(local_ops)
1.157 parser 247: #endif
1.1 paf 248:
1.336 misha 249:
1.297 paf 250: // Request
251:
252: void Request::execute(ArrayOperation& ops) {
253: register Stack<StackItem>& stack=this->stack; // helps a lot on MSVC: 'esi'
1.159 parser 254:
1.304 paf 255: const String* debug_name=0; Operation::Origin debug_origin={0, 0, 0};
1.297 paf 256: try{
1.157 parser 257: #ifdef DEBUG_EXECUTE
1.297 paf 258: debug_printf(sapi_info, "source----------------------------\n");
259: debug_dump(sapi_info, 0, ops);
260: debug_printf(sapi_info, "execution-------------------------\n");
1.157 parser 261: #endif
1.297 paf 262: for(Array_iterator<Operation> i(ops); i.has_next(); ) {
1.322 misha 263: OP::OPCODE opcode=i.next().code;
1.293 paf 264:
1.157 parser 265: #ifdef DEBUG_EXECUTE
1.297 paf 266: debug_printf(sapi_info, "%d:%s", stack.top_index()+1, opcode_name[opcode]);
1.157 parser 267: #endif
1.11 paf 268:
1.297 paf 269: switch(opcode) {
1.51 paf 270: // param in next instruction
1.322 misha 271: case OP::OP_VALUE:
1.32 paf 272: {
1.297 paf 273: debug_origin=i.next().origin;
274: Value& value=*i.next().value;
1.342 misha 275:
276: DEBUG_PRINT_VALUE_AND_TYPE(value)
277:
1.297 paf 278: stack.push(value);
1.32 paf 279: break;
280: }
1.328 misha 281: case OP::OP_VALUE__GET_CLASS:
282: {
283: // maybe they do ^class:method[] call, remember the fact
284: wcontext->set_somebody_entered_some_class();
285:
286: debug_origin=i.next().origin;
1.372 misha 287: const String& name=*i.next().value->get_string(); debug_name=&name;
1.328 misha 288:
1.336 misha 289: DEBUG_PRINT_STRING(name)
1.328 misha 290:
1.358 misha 291: Value* class_value=get_class(name);
1.328 misha 292: if(!class_value)
293: throw Exception(PARSER_RUNTIME,
294: &name,
295: "class is undefined");
296:
297: stack.push(*class_value);
298: break;
299: }
1.372 misha 300:
301: #ifdef OPTIMIZE_BYTECODE_GET_ELEMENT__SPECIAL
302: case OP::OP_GET_ELEMENT__SPECIAL:
303: case OP::OP_GET_ELEMENT__SPECIAL__WRITE:
304: {
305: const String& name=stack.pop().string(); debug_name=&name;
306: Value& ncontext=stack.pop().value();
307:
308: Value* value=0;
309: if(VStateless_class* vclass=ncontext.get_class()){
310: if(name==class_element_name){
311: value=vclass;
312: } else if(name==class_name_element_name){
1.379 ! moko 313: value=new VString(*new String(vclass->type()));
1.372 misha 314: }
315: } else {
316: // Value
317: if(name==class_element_name){
318: value=&ncontext;
319: }else if(name==class_name_element_name){
320: value=new VString(*new String(ncontext.type()));
321: }
322: };
323: if(opcode==OP::OP_GET_ELEMENT__SPECIAL){
324: stack.push(*value);
325: } else {
326: write_assign_lang(*value);
327: }
328: break;
329: }
330: #endif
331:
1.51 paf 332: // OP_WITH
1.322 misha 333: case OP::OP_WITH_ROOT:
1.187 parser 334: {
1.297 paf 335: stack.push(*method_frame);
1.187 parser 336: break;
337: }
1.336 misha 338: case OP::OP_WITH_SELF:
1.37 paf 339: {
1.297 paf 340: stack.push(get_self());
1.37 paf 341: break;
342: }
1.336 misha 343: case OP::OP_WITH_READ:
1.15 paf 344: {
1.297 paf 345: stack.push(*rcontext);
1.20 paf 346: break;
347: }
1.336 misha 348: case OP::OP_WITH_WRITE:
1.20 paf 349: {
1.287 paf 350: if(wcontext==method_frame)
1.316 misha 351: throw Exception(PARSER_RUNTIME,
1.287 paf 352: 0,
353: "$.name outside of $name[...]");
354:
1.297 paf 355: stack.push(*wcontext);
1.20 paf 356: break;
357: }
1.37 paf 358:
1.51 paf 359: // OTHER ACTIONS BUT WITHs
1.337 misha 360:
361: #ifdef OPTIMIZE_BYTECODE_CONSTRUCT
1.347 misha 362: #define DO_CONSTRUCT(context, vvalue) { \
363: debug_origin=i.next().origin; \
364: const String& name=*i.next().value->get_string(); debug_name=&name; \
365: DEBUG_PRINT_STRING(name) \
366: Value& value=stack.pop().value(); \
367: put_element( context, name, vvalue ); \
368: break; \
369: }
370: #define DO_CONSTRUCT_VALUE(context) DO_CONSTRUCT(context, &value)
371: #define DO_CONSTRUCT_EXPR(context) { \
372: wcontext->set_in_expression(false); \
373: DO_CONSTRUCT(context, &value.as_expr_result()) \
374: }
375:
1.344 misha 376: case OP::OP_WITH_WRITE__VALUE__CONSTRUCT_EXPR:
1.347 misha 377: {
378: if(wcontext==method_frame)
379: throw Exception(PARSER_RUNTIME, 0, "$.name outside of $name[...]");
380: DO_CONSTRUCT_EXPR(*wcontext)
381: }
382:
1.344 misha 383: case OP::OP_WITH_WRITE__VALUE__CONSTRUCT_VALUE:
1.338 misha 384: {
385: if(wcontext==method_frame)
1.347 misha 386: throw Exception(PARSER_RUNTIME, 0, "$.name outside of $name[...]");
387: DO_CONSTRUCT_VALUE(*wcontext)
1.338 misha 388: }
1.345 misha 389:
1.347 misha 390: case OP::OP_WITH_ROOT__VALUE__CONSTRUCT_EXPR: DO_CONSTRUCT_EXPR(*method_frame)
1.337 misha 391:
1.347 misha 392: case OP::OP_WITH_ROOT__VALUE__CONSTRUCT_VALUE: DO_CONSTRUCT_VALUE(*method_frame)
1.337 misha 393:
1.347 misha 394: case OP::OP_WITH_SELF__VALUE__CONSTRUCT_EXPR: DO_CONSTRUCT_EXPR(get_self())
1.342 misha 395:
1.347 misha 396: case OP::OP_WITH_SELF__VALUE__CONSTRUCT_VALUE: DO_CONSTRUCT_VALUE(get_self())
1.345 misha 397:
1.340 misha 398: #endif // OPTIMIZE_BYTECODE_CONSTRUCT
1.337 misha 399:
1.344 misha 400: case OP::OP_CONSTRUCT_VALUE:
1.337 misha 401: {
1.344 misha 402: #ifdef OPTIMIZE_BYTECODE_CONSTRUCT
403: const String& name=stack.pop().string(); debug_name=&name;
404: Value& ncontext=stack.pop().value();
405: Value& value=stack.pop().value();
406: #else
407: Value& value=stack.pop().value();
408: const String& name=stack.pop().string(); debug_name=&name;
409: Value& ncontext=stack.pop().value();
410: #endif
411: put_element(ncontext, name, &value);
1.337 misha 412:
413: break;
414: }
415:
1.322 misha 416: case OP::OP_CONSTRUCT_EXPR:
1.80 paf 417: {
1.219 paf 418: // see OP_PREPARE_TO_EXPRESSION
419: wcontext->set_in_expression(false);
420:
1.344 misha 421: #ifdef OPTIMIZE_BYTECODE_CONSTRUCT
422: const String& name=stack.pop().string(); debug_name=&name;
423: Value& ncontext=stack.pop().value();
424: Value& expr=stack.pop().value();
425: #else
1.308 paf 426: Value& expr=stack.pop().value();
1.297 paf 427: const String& name=stack.pop().string(); debug_name=&name;
428: Value& ncontext=stack.pop().value();
1.344 misha 429: #endif
1.308 paf 430: Value& value=expr.as_expr_result();
1.329 misha 431: put_element(ncontext, name, &value);
1.80 paf 432: break;
433: }
1.337 misha 434:
1.322 misha 435: case OP::OP_CURLY_CODE__CONSTRUCT:
1.182 parser 436: {
1.297 paf 437: ArrayOperation& local_ops=*i.next().ops;
1.336 misha 438:
439: DEBUG_PRINT_OPS((&local_ops))
440:
1.326 misha 441: VJunction& value=*new VJunction(
1.297 paf 442: get_self(), 0,
1.257 paf 443: method_frame,
1.240 paf 444: rcontext,
445: wcontext,
1.312 paf 446: &local_ops);
1.238 paf 447:
1.326 misha 448: wcontext->attach_junction(&value);
449:
1.297 paf 450: const String& name=stack.pop().string(); debug_name=&name;
451: Value& ncontext=stack.pop().value();
1.371 moko 452: if(const VJunction* vjunction=ncontext.put_element(name, &value))
1.312 paf 453: if(vjunction!=PUT_ELEMENT_REPLACED_ELEMENT)
1.316 misha 454: throw Exception(PARSER_RUNTIME,
1.308 paf 455: 0,
456: "property value can not be code, use [] or () brackets");
457:
1.182 parser 458: break;
459: }
1.322 misha 460: case OP::OP_NESTED_CODE:
1.209 paf 461: {
1.297 paf 462: ArrayOperation& local_ops=*i.next().ops;
1.336 misha 463:
464: DEBUG_PRINT_OPS((&local_ops))
465:
1.297 paf 466: stack.push(local_ops);
1.209 paf 467: break;
468: }
1.322 misha 469: case OP::OP_WRITE_VALUE:
1.13 paf 470: {
1.297 paf 471: Value& value=stack.pop().value();
472: write_assign_lang(value);
1.86 paf 473: break;
474: }
1.322 misha 475: case OP::OP_WRITE_EXPR_RESULT:
1.108 paf 476: {
1.219 paf 477: // see OP_PREPARE_TO_EXPRESSION
478: wcontext->set_in_expression(false);
1.351 misha 479:
480: Value& value=stack.pop().value();
481: wcontext->write(value.as_expr_result());
1.108 paf 482: break;
483: }
1.322 misha 484: case OP::OP_STRING__WRITE:
1.86 paf 485: {
1.297 paf 486: i.next(); // ignore origin
487: Value* value=i.next().value;
1.336 misha 488:
489: const String& string_value=*value->get_string();
490:
491: DEBUG_PRINT_STRING(string_value)
492:
493: write_no_lang(string_value);
1.13 paf 494: break;
1.14 paf 495: }
1.328 misha 496:
497: #ifdef OPTIMIZE_BYTECODE_GET_ELEMENT
498: case OP::OP_VALUE__GET_ELEMENT_OR_OPERATOR:
499: {
500: debug_origin=i.next().origin;
501: const String& name=*i.next().value->get_string(); debug_name=&name;
502:
1.336 misha 503: DEBUG_PRINT_STRING(name)
504:
1.330 misha 505: if(Method* method=main_class.get_method(name)){ // looking operator of that name FIRST
506: if(!method->junction_template) method->junction_template=new VJunction(main_class, method);
507: stack.push(*method->junction_template);
508: break;
509: }
510: Value& value=get_element(*rcontext, name);
1.328 misha 511: stack.push(value);
512: break;
513: }
514: #else
1.322 misha 515: case OP::OP_GET_ELEMENT_OR_OPERATOR:
1.215 paf 516: {
1.297 paf 517: const String& name=stack.pop().string(); debug_name=&name;
518: Value& ncontext=stack.pop().value();
1.330 misha 519: if(Method* method=main_class.get_method(name)){ // looking operator of that name FIRST
520: if(!method->junction_template) method->junction_template=new VJunction(main_class, method);
521: stack.push(*method->junction_template);
522: break;
523: }
524: Value& value=get_element(ncontext, name);
1.297 paf 525: stack.push(value);
1.215 paf 526: break;
527: }
1.328 misha 528: #endif
529:
1.335 misha 530: #ifdef OPTIMIZE_BYTECODE_GET_OBJECT_ELEMENT
1.336 misha 531:
1.376 moko 532: #define DO_GET_OBJECT_ELEMENT(code) {\
533: debug_origin=i.next().origin; \
534: const String& context_name=*i.next().value->get_string(); debug_name=&context_name; \
535: DEBUG_PRINT_STRING(context_name) \
536: Value& object=get_element(*rcontext, context_name); \
537: debug_origin=i.next().origin; \
538: const String& field_name=*i.next().value->get_string(); debug_name=&field_name; \
539: DEBUG_PRINT_STRING(field_name) \
540: code; \
541: break; \
542: }
1.336 misha 543:
1.376 moko 544: case OP::OP_GET_OBJECT_ELEMENT: DO_GET_OBJECT_ELEMENT({
545: Value& value=get_element(object, field_name);
546: stack.push(value);
547: })
548: case OP::OP_GET_OBJECT_ELEMENT__WRITE: DO_GET_OBJECT_ELEMENT({
1.334 misha 549: Value& value=get_element(object, field_name);
1.376 moko 550: write_assign_lang(value);
551: })
552: #ifdef FEATURE_GET_ELEMENT4CALL
553: case OP::OP_GET_OBJECT_ELEMENT4CALL: DO_GET_OBJECT_ELEMENT({
554: Value& value=get_element4call(object, field_name);
555: stack.push(value);
556: })
557: #endif
1.335 misha 558: #endif
559:
560: #ifdef OPTIMIZE_BYTECODE_GET_OBJECT_VAR_ELEMENT
1.336 misha 561:
1.376 moko 562: #define DO_GET_OBJECT_VAR_ELEMENT(code) {\
563: debug_origin=i.next().origin; \
564: const String& context_name=*i.next().value->get_string(); debug_name=&context_name; \
565: DEBUG_PRINT_STRING(context_name) \
566: Value& object=get_element(*rcontext, context_name); \
567: debug_origin=i.next().origin; \
568: const String& var_name=*i.next().value->get_string(); debug_name=&var_name; \
569: DEBUG_PRINT_STRING(var_name) \
570: const String* field=&get_element(*rcontext, var_name).as_string(); \
571: code; \
572: break; \
573: }
1.335 misha 574:
1.376 moko 575: case OP::OP_GET_OBJECT_VAR_ELEMENT: DO_GET_OBJECT_VAR_ELEMENT({
576: Value& value=get_element(object, *field);
577: stack.push(value);
578: })
579: case OP::OP_GET_OBJECT_VAR_ELEMENT__WRITE: DO_GET_OBJECT_VAR_ELEMENT({
1.335 misha 580: Value& value=get_element(object, *field);
1.376 moko 581: write_assign_lang(value);
582: })
583: #ifdef FEATURE_GET_ELEMENT4CALL
584: case OP::OP_GET_OBJECT_VAR_ELEMENT4CALL: DO_GET_OBJECT_VAR_ELEMENT({
585: Value& value=get_element4call(object, *field);
586: stack.push(value);
587: })
588: #endif
589: #endif
1.335 misha 590:
1.376 moko 591: case OP::OP_GET_ELEMENT:
592: {
593: const String& name=stack.pop().string(); debug_name=&name;
594: Value& ncontext=stack.pop().value();
595: Value& value=get_element(ncontext, name);
596: stack.push(value);
1.334 misha 597: break;
598: }
599:
1.376 moko 600: #ifdef FEATURE_GET_ELEMENT4CALL
601: case OP::OP_GET_ELEMENT4CALL:
1.11 paf 602: {
1.297 paf 603: const String& name=stack.pop().string(); debug_name=&name;
604: Value& ncontext=stack.pop().value();
1.376 moko 605: Value& value=get_element4call(ncontext, name);
1.297 paf 606: stack.push(value);
1.17 paf 607: break;
608: }
1.376 moko 609: #endif
1.17 paf 610:
1.346 misha 611: case OP::OP_GET_ELEMENT__WRITE:
612: {
613: const String& name=stack.pop().string(); debug_name=&name;
614: Value& ncontext=stack.pop().value();
615: Value& value=get_element(ncontext, name);
616: write_assign_lang(value);
617: break;
618: }
619:
1.328 misha 620: #ifdef OPTIMIZE_BYTECODE_GET_ELEMENT
621: case OP::OP_VALUE__GET_ELEMENT:
622: {
623: debug_origin=i.next().origin;
624: const String& name=*i.next().value->get_string(); debug_name=&name;
625:
1.336 misha 626: DEBUG_PRINT_STRING(name)
1.328 misha 627:
1.330 misha 628: Value& value=get_element(*rcontext, name);
1.328 misha 629: stack.push(value);
630: break;
631: }
632:
633: case OP::OP_VALUE__GET_ELEMENT__WRITE:
634: {
635: debug_origin=i.next().origin;
636: const String& name=*i.next().value->get_string(); debug_name=&name;
637:
1.336 misha 638: DEBUG_PRINT_STRING(name)
1.328 misha 639:
1.330 misha 640: Value& value=get_element(*rcontext, name);
1.328 misha 641: write_assign_lang(value);
642: break;
643: }
1.347 misha 644:
645: case OP::OP_WITH_ROOT__VALUE__GET_ELEMENT:
646: {
647: debug_origin=i.next().origin;
648: const String& name=*i.next().value->get_string(); debug_name=&name;
649:
650: DEBUG_PRINT_STRING(name)
651:
652: Value& value=get_element(*method_frame, name);
653: stack.push(value);
654: break;
655: }
1.328 misha 656: #endif
1.32 paf 657:
1.345 misha 658: #ifdef OPTIMIZE_BYTECODE_GET_SELF_ELEMENT
659: case OP::OP_WITH_SELF__VALUE__GET_ELEMENT:
660: case OP::OP_WITH_SELF__VALUE__GET_ELEMENT__WRITE:
661: {
662: debug_origin=i.next().origin;
663: const String& name=*i.next().value->get_string(); debug_name=&name;
664:
665: DEBUG_PRINT_STRING(name)
666:
667: Value& value=get_element(get_self(), name);
668:
669: if(opcode==OP::OP_WITH_SELF__VALUE__GET_ELEMENT){
670: stack.push(value);
671: } else {
672: write_assign_lang(value);
673: }
674: break;
675: }
676: #endif
677:
1.322 misha 678: case OP::OP_OBJECT_POOL:
1.17 paf 679: {
1.297 paf 680: ArrayOperation& local_ops=*i.next().ops;
1.226 paf 681:
1.257 paf 682: WContext *saved_wcontext=wcontext;
1.297 paf 683: String::Language saved_lang=flang;
684: flang=String::L_PASS_APPENDED;
1.348 misha 685: #ifdef OPTIMIZE_SINGLE_STRING_WRITE
1.351 misha 686: WObjectPoolWrapper local(wcontext);
1.348 misha 687: #else
1.351 misha 688: WWrapper local(wcontext);
1.348 misha 689: #endif
1.226 paf 690: wcontext=&local;
691:
1.297 paf 692: execute(local_ops);
1.226 paf 693:
1.297 paf 694: stack.push(wcontext->result().as_value());
1.257 paf 695: flang=saved_lang;
696: wcontext=saved_wcontext;
1.13 paf 697: break;
1.15 paf 698: }
1.13 paf 699:
1.322 misha 700: case OP::OP_STRING_POOL:
1.49 paf 701: {
1.297 paf 702: ArrayOperation& local_ops=*i.next().ops;
1.226 paf 703:
1.257 paf 704: WContext *saved_wcontext=wcontext;
1.351 misha 705: WWrapper local(wcontext);
1.226 paf 706: wcontext=&local;
707:
1.297 paf 708: execute(local_ops);
1.226 paf 709:
1.49 paf 710: // from "$a $b" part of expression taking only string value,
711: // ignoring any other content of wcontext
1.367 moko 712: const String* string=wcontext->get_string();
713: Value* value=string ? new VString(*string) : new VString();
1.297 paf 714: stack.push(*value);
715:
1.257 paf 716: wcontext=saved_wcontext;
1.49 paf 717: break;
718: }
719:
1.51 paf 720: // CALL
1.322 misha 721: case OP::OP_CURLY_CODE__STORE_PARAM:
722: case OP::OP_EXPR_CODE__STORE_PARAM:
1.28 paf 723: {
1.237 paf 724: // code
1.297 paf 725: ArrayOperation& local_ops=*i.next().ops;
1.336 misha 726:
727: DEBUG_PRINT_OPS((&local_ops))
728:
1.237 paf 729: // when they evaluate expression parameter,
730: // the object expression result
731: // does not need to be written into calling frame
732: // it must go into any expressions using that parameter
733: // hence, we zero junction.wcontext here, and later
734: // in .process we would test that field
735: // in decision "which wwrapper to use"
1.326 misha 736: VJunction& value=*new VJunction(
1.297 paf 737: get_self(), 0,
1.257 paf 738: method_frame,
1.237 paf 739: rcontext,
1.322 misha 740: opcode==OP::OP_EXPR_CODE__STORE_PARAM?0:wcontext,
1.312 paf 741: &local_ops);
1.343 misha 742: #ifndef USE_DESTRUCTORS
1.326 misha 743: if (opcode!=OP::OP_EXPR_CODE__STORE_PARAM)
1.343 misha 744: wcontext->attach_junction(&value);
1.326 misha 745: #endif
1.237 paf 746: // store param
1.329 misha 747: stack.push(value);
1.29 paf 748: break;
749: }
750:
1.322 misha 751: case OP::OP_PREPARE_TO_EXPRESSION:
1.219 paf 752: {
753: wcontext->set_in_expression(true);
754: break;
755: }
756:
1.350 misha 757: #define METHOD_FRAME_ACTION(action) \
758: if(local_ops){ \
759: size_t first = stack.top_index(); \
760: execute(*local_ops); \
761: frame.store_params((Value**)stack.ptr(first), stack.top_index()-first); \
762: action; \
763: stack.set_top_index(first); \
764: } else { \
765: frame.empty_params(); \
766: action; \
767: }
768:
1.322 misha 769: case OP::OP_CALL:
1.29 paf 770: {
1.297 paf 771: ArrayOperation* local_ops=i.next().ops;
1.237 paf 772:
1.336 misha 773: DEBUG_PRINT_OPS(local_ops)
774: DEBUG_PRINT_STR("->\n")
775:
1.297 paf 776: Value& value=stack.pop().value();
1.237 paf 777:
1.297 paf 778: Junction* junction=value.get_junction();
779: if(!junction) {
780: if(value.is("void"))
1.316 misha 781: throw Exception(PARSER_RUNTIME,
1.297 paf 782: 0,
783: "undefined method");
784: else
1.316 misha 785: throw Exception(PARSER_RUNTIME,
1.297 paf 786: 0,
787: "is '%s', not a method or junction, can not call it",
788: value.type());
789: }
1.237 paf 790:
1.370 moko 791: Value *result;
792: {
793: VMethodFrame frame(*junction->method, method_frame, junction->self);
794: METHOD_FRAME_ACTION(op_call(frame));
795: result=&frame.result().as_value();
796: // VMethodFrame desctructor deletes junctions in stack params here
797: }
798: stack.push(*result);
1.332 misha 799:
1.336 misha 800: DEBUG_PRINT_STR("<-returned")
801:
1.332 misha 802: if(get_skip())
803: return;
804: if(get_interrupted()) {
805: set_interrupted(false);
806: throw Exception("parser.interrupted",
807: 0,
808: "execution stopped");
1.237 paf 809: }
1.332 misha 810: break;
811: }
1.220 paf 812:
1.332 misha 813: case OP::OP_CALL__WRITE:
814: {
815: ArrayOperation* local_ops=i.next().ops;
816:
1.336 misha 817: DEBUG_PRINT_OPS(local_ops)
818: DEBUG_PRINT_STR("->\n")
819:
1.332 misha 820: Value& value=stack.pop().value();
821:
822: Junction* junction=value.get_junction();
823: if(!junction) {
824: if(value.is("void"))
825: throw Exception(PARSER_RUNTIME,
826: 0,
827: "undefined method");
828: else
829: throw Exception(PARSER_RUNTIME,
830: 0,
831: "is '%s', not a method or junction, can not call it",
832: value.type());
833: }
834:
835: #ifdef OPTIMIZE_CALL
836: const Method& method=*junction->method;
1.353 misha 837: if(method.call_optimization==Method::CO_WITHOUT_FRAME){
1.332 misha 838: if(local_ops){ // store param code goes here
839: size_t first = stack.top_index();
840: execute(*local_ops);
841:
842: MethodParams method_params;
843: method_params.store_params((Value**)stack.ptr(first), stack.top_index()-first);
844: method.check_actual_numbered_params(junction->self, &method_params);
845: method.native_code(*this, method_params); // execute it
846:
847: stack.set_top_index(first);
848: } else {
849: MethodParams method_params;
850: method.check_actual_numbered_params(junction->self, &method_params);
851: method.native_code(*this, method_params); // execute it
852: }
1.353 misha 853: } else if(method.call_optimization==Method::CO_WITHOUT_WCONTEXT){
1.363 moko 854: VMethodFrame frame(method, method_frame, junction->self);
1.350 misha 855: METHOD_FRAME_ACTION(op_call_write(frame));
1.332 misha 856: } else
857: #endif // OPTIMIZE_CALL
858: {
1.363 moko 859: VMethodFrame frame(method, method_frame, junction->self);
860: METHOD_FRAME_ACTION(op_call(frame));
1.346 misha 861: write_pass_lang(frame.result());
1.332 misha 862: }
1.336 misha 863:
864: DEBUG_PRINT_STR("<-returned")
1.327 misha 865:
866: if(get_skip())
867: return;
868: if(get_interrupted()) {
869: set_interrupted(false);
870: throw Exception("parser.interrupted",
871: 0,
872: "execution stopped");
873: }
1.49 paf 874: break;
875: }
876:
1.348 misha 877: case OP::OP_CONSTRUCT_OBJECT:
878: case OP::OP_CONSTRUCT_OBJECT__WRITE:
879: {
880: debug_origin=i.next().origin;
881: Value& vclass_name=*i.next().value;
1.360 pretende 882: const String& class_name=*vclass_name.get_string(); debug_name=&class_name;
1.348 misha 883:
884: DEBUG_PRINT_STRING(class_name)
885:
1.358 misha 886: Value* class_value=get_class(class_name);
1.348 misha 887: if(!class_value)
888: throw Exception(PARSER_RUNTIME,
889: &class_name,
890: "class is undefined");
891:
892: debug_origin=i.next().origin;
893: Value& vconstructor_name=*i.next().value;
894: const String& constructor_name=*vconstructor_name.get_string(); debug_name=&constructor_name;
895:
896: DEBUG_PRINT_STRING(constructor_name)
897:
1.363 moko 898: Junction* constructor_junction=get_element(*class_value, constructor_name).get_junction();
899: if(!constructor_junction)
1.350 misha 900: throw Exception(PARSER_RUNTIME,
901: &constructor_name,
902: "constructor must be declared in class '%s'",
1.379 ! moko 903: class_value->type());
1.350 misha 904:
1.348 misha 905: ArrayOperation* local_ops=i.next().ops;
906: DEBUG_PRINT_OPS(local_ops)
907: DEBUG_PRINT_STR("->\n")
908:
1.370 moko 909: Value *result;
910: {
911: Value& object=construct(*class_value, *constructor_junction->method);
912: VConstructorFrame frame(*constructor_junction->method, method_frame, object);
913: METHOD_FRAME_ACTION(op_call(frame));
914: object.enable_default_setter();
915: result=&frame.result().as_value();
916: // VMethodFrame desctructor deletes junctions in stack params here
917: }
1.355 misha 918:
1.350 misha 919: if(opcode==OP::OP_CONSTRUCT_OBJECT)
1.370 moko 920: stack.push(*result);
1.350 misha 921: else
1.370 moko 922: write_pass_lang(*result);
1.348 misha 923:
924: DEBUG_PRINT_STR("<-returned")
925: break;
926: }
927:
1.55 paf 928: // expression ops: unary
1.322 misha 929: case OP::OP_NEG:
1.55 paf 930: {
1.297 paf 931: Value& a=stack.pop().value();
932: Value& value=*new VDouble(-a.as_double());
933: stack.push(value);
1.55 paf 934: break;
935: }
1.322 misha 936: case OP::OP_INV:
1.55 paf 937: {
1.297 paf 938: Value& a=stack.pop().value();
939: Value& value=*new VDouble(~a.as_int());
940: stack.push(value);
1.55 paf 941: break;
942: }
1.322 misha 943: case OP::OP_NOT:
1.55 paf 944: {
1.297 paf 945: Value& a=stack.pop().value();
1.327 misha 946: Value& value=VBool::get(!a.as_bool());
1.297 paf 947: stack.push(value);
1.55 paf 948: break;
949: }
1.322 misha 950: case OP::OP_DEF:
1.62 paf 951: {
1.297 paf 952: Value& a=stack.pop().value();
1.327 misha 953: Value& value=VBool::get(a.is_defined());
1.297 paf 954: stack.push(value);
1.62 paf 955: break;
956: }
1.322 misha 957: case OP::OP_IN:
1.62 paf 958: {
1.297 paf 959: Value& a=stack.pop().value();
960: const String& path=a.as_string();
1.327 misha 961: Value& value=VBool::get(request_info.uri && *request_info.uri && path.this_starts(request_info.uri));
1.297 paf 962: stack.push(value);
1.62 paf 963: break;
964: }
1.322 misha 965: case OP::OP_FEXISTS:
1.62 paf 966: {
1.297 paf 967: Value& a=stack.pop().value();
1.327 misha 968: Value& value=VBool::get(file_exist(absolute(a.as_string())));
1.297 paf 969: stack.push(value);
1.148 paf 970: break;
971: }
1.322 misha 972: case OP::OP_DEXISTS:
1.148 paf 973: {
1.297 paf 974: Value& a=stack.pop().value();
1.327 misha 975: Value& value=VBool::get(dir_exists(absolute(a.as_string())));
1.297 paf 976: stack.push(value);
1.62 paf 977: break;
978: }
1.55 paf 979:
980: // expression ops: binary
1.322 misha 981: case OP::OP_SUB:
1.53 paf 982: {
1.297 paf 983: Value& b=stack.pop().value(); Value& a=stack.pop().value();
984: Value& value=*new VDouble(a.as_double() - b.as_double());
985: stack.push(value);
1.53 paf 986: break;
987: }
1.322 misha 988: case OP::OP_ADD:
1.53 paf 989: {
1.297 paf 990: Value& b=stack.pop().value(); Value& a=stack.pop().value();
991: Value& value=*new VDouble(a.as_double() + b.as_double());
992: stack.push(value);
1.53 paf 993: break;
994: }
1.322 misha 995: case OP::OP_MUL:
1.49 paf 996: {
1.297 paf 997: Value& b=stack.pop().value(); Value& a=stack.pop().value();
998: Value& value=*new VDouble(a.as_double() * b.as_double());
999: stack.push(value);
1.53 paf 1000: break;
1001: }
1.322 misha 1002: case OP::OP_DIV:
1.53 paf 1003: {
1.297 paf 1004: Value& b=stack.pop().value(); Value& a=stack.pop().value();
1.170 parser 1005:
1.297 paf 1006: double a_double=a.as_double();
1007: double b_double=b.as_double();
1.170 parser 1008:
1.171 parser 1009: if(b_double == 0) {
1.297 paf 1010: //const String* problem_source=b.as_string();
1.223 paf 1011: throw Exception("number.zerodivision",
1.297 paf 1012: 0, //problem_source,
1.170 parser 1013: "Division by zero");
1.171 parser 1014: }
1.170 parser 1015:
1.297 paf 1016: Value& value=*new VDouble(a_double / b_double);
1017: stack.push(value);
1.54 paf 1018: break;
1019: }
1.322 misha 1020: case OP::OP_MOD:
1.55 paf 1021: {
1.297 paf 1022: Value& b=stack.pop().value(); Value& a=stack.pop().value();
1.170 parser 1023:
1.297 paf 1024: double a_double=a.as_double();
1025: double b_double=b.as_double();
1.170 parser 1026:
1.173 parser 1027: if(b_double == 0) {
1.297 paf 1028: //const String* problem_source=b.as_string();
1.223 paf 1029: throw Exception("number.zerodivision",
1.297 paf 1030: 0, //problem_source,
1.170 parser 1031: "Modulus by zero");
1.171 parser 1032: }
1.170 parser 1033:
1.297 paf 1034: Value& value=*new VDouble(fmod(a_double, b_double));
1035: stack.push(value);
1.201 paf 1036: break;
1037: }
1.322 misha 1038: case OP::OP_INTDIV:
1.201 paf 1039: {
1.297 paf 1040: Value& b=stack.pop().value(); Value& a=stack.pop().value();
1.201 paf 1041:
1.297 paf 1042: int a_int=a.as_int();
1043: int b_int=b.as_int();
1.201 paf 1044:
1045: if(b_int == 0) {
1.297 paf 1046: //const String* problem_source=b.as_string();
1.223 paf 1047: throw Exception("number.zerodivision",
1.297 paf 1048: 0, //problem_source,
1.201 paf 1049: "Division by zero");
1050: }
1051:
1.297 paf 1052: Value& value=*new VInt(a_int / b_int);
1053: stack.push(value);
1.55 paf 1054: break;
1055: }
1.322 misha 1056: case OP::OP_BIN_SL:
1.274 paf 1057: {
1.297 paf 1058: Value& b=stack.pop().value(); Value& a=stack.pop().value();
1059: Value& value=*new VInt(
1060: a.as_int() <<
1061: b.as_int());
1062: stack.push(value);
1.274 paf 1063: break;
1064: }
1.322 misha 1065: case OP::OP_BIN_SR:
1.274 paf 1066: {
1.297 paf 1067: Value& b=stack.pop().value(); Value& a=stack.pop().value();
1068: Value& value=*new VInt(
1069: a.as_int() >>
1070: b.as_int());
1071: stack.push(value);
1.274 paf 1072: break;
1073: }
1.322 misha 1074: case OP::OP_BIN_AND:
1.54 paf 1075: {
1.297 paf 1076: Value& b=stack.pop().value(); Value& a=stack.pop().value();
1077: Value& value=*new VInt(
1078: a.as_int() &
1079: b.as_int());
1080: stack.push(value);
1.54 paf 1081: break;
1082: }
1.322 misha 1083: case OP::OP_BIN_OR:
1.54 paf 1084: {
1.297 paf 1085: Value& b=stack.pop().value(); Value& a=stack.pop().value();
1086: Value& value=*new VInt(
1087: a.as_int() |
1088: b.as_int());
1089: stack.push(value);
1.55 paf 1090: break;
1091: }
1.322 misha 1092: case OP::OP_BIN_XOR:
1.56 paf 1093: {
1.297 paf 1094: Value& b=stack.pop().value(); Value& a=stack.pop().value();
1095: Value& value=*new VInt(
1096: a.as_int() ^
1097: b.as_int());
1098: stack.push(value);
1.56 paf 1099: break;
1100: }
1.322 misha 1101: case OP::OP_LOG_AND:
1.55 paf 1102: {
1.297 paf 1103: ArrayOperation& local_ops=stack.pop().ops(); Value& a=stack.pop().value();
1.263 paf 1104: bool result;
1.297 paf 1105: if(a.as_bool()) {
1106: execute(local_ops);
1107: Value& b=stack.pop().value();
1108: result=b.as_bool();
1.209 paf 1109: } else
1.263 paf 1110: result=false;
1.327 misha 1111: Value& value=VBool::get(result);
1.297 paf 1112: stack.push(value);
1.55 paf 1113: break;
1114: }
1.322 misha 1115: case OP::OP_LOG_OR:
1.55 paf 1116: {
1.297 paf 1117: ArrayOperation& local_ops=stack.pop().ops(); Value& a=stack.pop().value();
1.263 paf 1118: bool result;
1.297 paf 1119: if(a.as_bool())
1.263 paf 1120: result=true;
1.209 paf 1121: else {
1.297 paf 1122: execute(local_ops);
1123: Value& b=stack.pop().value();
1124: result=b.as_bool();
1.209 paf 1125: }
1.327 misha 1126: Value& value=VBool::get(result);
1.297 paf 1127: stack.push(value);
1.56 paf 1128: break;
1129: }
1.322 misha 1130: case OP::OP_LOG_XOR:
1.56 paf 1131: {
1.297 paf 1132: Value& b=stack.pop().value(); Value& a=stack.pop().value();
1.327 misha 1133: Value& value=VBool::get(a.as_bool() ^ b.as_bool());
1.297 paf 1134: stack.push(value);
1.55 paf 1135: break;
1136: }
1.322 misha 1137: case OP::OP_NUM_LT:
1.55 paf 1138: {
1.297 paf 1139: volatile double b_double=stack.pop().value().as_double();
1140: volatile double a_double=stack.pop().value().as_double();
1.327 misha 1141: Value& value=VBool::get(a_double<b_double);
1.297 paf 1142: stack.push(value);
1.55 paf 1143: break;
1144: }
1.322 misha 1145: case OP::OP_NUM_GT:
1.55 paf 1146: {
1.297 paf 1147: volatile double b_double=stack.pop().value().as_double();
1148: volatile double a_double=stack.pop().value().as_double();
1.327 misha 1149: Value& value=VBool::get(a_double>b_double);
1.297 paf 1150: stack.push(value);
1.55 paf 1151: break;
1152: }
1.322 misha 1153: case OP::OP_NUM_LE:
1.55 paf 1154: {
1.297 paf 1155: volatile double b_double=stack.pop().value().as_double();
1156: volatile double a_double=stack.pop().value().as_double();
1.327 misha 1157: Value& value=VBool::get(a_double<=b_double);
1.297 paf 1158: stack.push(value);
1.55 paf 1159: break;
1160: }
1.322 misha 1161: case OP::OP_NUM_GE:
1.55 paf 1162: {
1.297 paf 1163: volatile double b_double=stack.pop().value().as_double();
1164: volatile double a_double=stack.pop().value().as_double();
1.327 misha 1165: Value& value=VBool::get(a_double>=b_double);
1.297 paf 1166: stack.push(value);
1.55 paf 1167: break;
1168: }
1.322 misha 1169: case OP::OP_NUM_EQ:
1.55 paf 1170: {
1.297 paf 1171: volatile double b_double=stack.pop().value().as_double();
1172: volatile double a_double=stack.pop().value().as_double();
1.327 misha 1173: Value& value=VBool::get(a_double==b_double);
1.297 paf 1174: stack.push(value);
1.55 paf 1175: break;
1176: }
1.322 misha 1177: case OP::OP_NUM_NE:
1.55 paf 1178: {
1.297 paf 1179: volatile double b_double=stack.pop().value().as_double();
1180: volatile double a_double=stack.pop().value().as_double();
1.327 misha 1181: Value& value=VBool::get(a_double!=b_double);
1.297 paf 1182: stack.push(value);
1.54 paf 1183: break;
1184: }
1.322 misha 1185: case OP::OP_STR_LT:
1.58 paf 1186: {
1.297 paf 1187: Value& b=stack.pop().value(); Value& a=stack.pop().value();
1.327 misha 1188: Value& value=VBool::get(a.as_string() < b.as_string());
1.297 paf 1189: stack.push(value);
1.58 paf 1190: break;
1191: }
1.322 misha 1192: case OP::OP_STR_GT:
1.58 paf 1193: {
1.297 paf 1194: Value& b=stack.pop().value(); Value& a=stack.pop().value();
1.327 misha 1195: Value& value=VBool::get(a.as_string() > b.as_string());
1.297 paf 1196: stack.push(value);
1.58 paf 1197: break;
1198: }
1.322 misha 1199: case OP::OP_STR_LE:
1.58 paf 1200: {
1.297 paf 1201: Value& b=stack.pop().value(); Value& a=stack.pop().value();
1.327 misha 1202: Value& value=VBool::get(a.as_string() <= b.as_string());
1.297 paf 1203: stack.push(value);
1.58 paf 1204: break;
1205: }
1.322 misha 1206: case OP::OP_STR_GE:
1.54 paf 1207: {
1.297 paf 1208: Value& b=stack.pop().value(); Value& a=stack.pop().value();
1.327 misha 1209: Value& value=VBool::get(a.as_string() >= b.as_string());
1.297 paf 1210: stack.push(value);
1.58 paf 1211: break;
1212: }
1.322 misha 1213: case OP::OP_STR_EQ:
1.58 paf 1214: {
1.297 paf 1215: Value& b=stack.pop().value(); Value& a=stack.pop().value();
1.327 misha 1216: Value& value=VBool::get(a.as_string() == b.as_string());
1.297 paf 1217: stack.push(value);
1.58 paf 1218: break;
1219: }
1.322 misha 1220: case OP::OP_STR_NE:
1.58 paf 1221: {
1.297 paf 1222: Value& b=stack.pop().value(); Value& a=stack.pop().value();
1.327 misha 1223: Value& value=VBool::get(a.as_string() != b.as_string());
1.297 paf 1224: stack.push(value);
1.103 paf 1225: break;
1226: }
1.322 misha 1227: case OP::OP_IS:
1.103 paf 1228: {
1.297 paf 1229: Value& b=stack.pop().value(); Value& a=stack.pop().value();
1.327 misha 1230: Value& value=VBool::get(a.is(b.as_string().cstr()));
1.297 paf 1231: stack.push(value);
1.28 paf 1232: break;
1233: }
1234:
1.11 paf 1235: default:
1.223 paf 1236: throw Exception(0,
1.67 paf 1237: 0,
1.297 paf 1238: "invalid opcode %d", opcode);
1.11 paf 1239: }
1240: }
1.306 paf 1241: } catch(const Exception&) {
1.297 paf 1242: // record it to stack trace
1.301 paf 1243: if(debug_name)
1244: exception_trace.push(Trace(debug_name, debug_origin));
1.297 paf 1245: rethrow;
1246: }
1.1 paf 1247: }
1.17 paf 1248:
1.330 misha 1249: #define SAVE_CONTEXT \
1250: VMethodFrame *saved_method_frame=method_frame; \
1251: Value* saved_rcontext=rcontext; \
1252: WContext *saved_wcontext=wcontext;
1253:
1254: #define RESTORE_CONTEXT \
1255: wcontext=saved_wcontext; \
1256: rcontext=saved_rcontext; \
1257: method_frame=saved_method_frame;
1258:
1.363 moko 1259:
1260: Value& Request::construct(Value &class_value, const Method &method){
1261: VStateless_class& called_class=*class_value.get_class();
1262:
1263: if(method.call_type!=Method::CT_STATIC) {
1264: // this is a constructor call
1265: if(Value* result=called_class.create_new_value(fpool)) {
1.319 misha 1266: // some stateless_class creatable derivates
1.363 moko 1267: return *result;
1268: } else
1.319 misha 1269: throw Exception(PARSER_RUNTIME,
1270: 0, //&frame.name(),
1.363 moko 1271: "is not a constructor, system class '%s' can be constructed only implicitly",
1.379 ! moko 1272: called_class.type());
1.363 moko 1273: } else
1274: throw Exception(PARSER_RUNTIME,
1275: 0, //&frame.name(),
1.319 misha 1276: "method is static and can not be used as constructor");
1.363 moko 1277: }
1.319 misha 1278:
1.363 moko 1279: void Request::op_call(VMethodFrame& frame){
1.319 misha 1280: // see OP_PREPARE_TO_EXPRESSION
1281: frame.set_in_expression(wcontext->get_in_expression());
1282:
1.332 misha 1283: SAVE_CONTEXT
1284:
1.365 moko 1285: rcontext=wcontext=method_frame=&frame;
1.319 misha 1286:
1.363 moko 1287: Value& self=frame.self();
1288: const Method& method=frame.method;
1289: Method::Call_type call_type=self.get_class()==&self ? Method::CT_STATIC : Method::CT_DYNAMIC;
1.319 misha 1290:
1.332 misha 1291: if(method.call_type==Method::CT_ANY || method.call_type==call_type) { // allowed call type?
1292: if(method.native_code) { // native code?
1.363 moko 1293: method.check_actual_numbered_params(self, frame.numbered_params());
1.332 misha 1294: method.native_code(*this, *frame.numbered_params()); // execute it
1295: } else // parser code, execute it
1296: recoursion_checked_execute(*method.parser_code);
1297: } else
1298: throw Exception(PARSER_RUNTIME,
1299: 0,
1300: "is not allowed to be called %s",
1301: call_type==Method::CT_STATIC?"statically":"dynamically");
1.334 misha 1302:
1.330 misha 1303: RESTORE_CONTEXT
1.332 misha 1304: }
1305:
1306: void Request::op_call_write(VMethodFrame& frame){
1307: VMethodFrame *saved_method_frame=method_frame;
1308: Value* saved_rcontext=rcontext;
1.319 misha 1309:
1.332 misha 1310: rcontext=&frame;
1311: method_frame=&frame;
1312:
1.363 moko 1313: Value& self=frame.self();
1314: const Method& method=frame.method;
1315: Method::Call_type call_type=self.get_class()==&self ? Method::CT_STATIC : Method::CT_DYNAMIC;
1.332 misha 1316:
1.333 misha 1317: if(method.call_type==Method::CT_ANY || method.call_type==call_type) { // allowed call type?
1318: if(method.native_code) { // native code?
1.363 moko 1319: method.check_actual_numbered_params(self, frame.numbered_params());
1.333 misha 1320: method.native_code(*this, *frame.numbered_params()); // execute it
1321: } else // parser code, execute it
1322: recoursion_checked_execute(*method.parser_code);
1.332 misha 1323: } else
1324: throw Exception(PARSER_RUNTIME,
1325: 0,
1326: "is not allowed to be called %s",
1327: call_type==Method::CT_STATIC?"statically":"dynamically");
1328:
1329: rcontext=saved_rcontext;
1330: method_frame=saved_method_frame;
1.319 misha 1331: }
1332:
1.330 misha 1333: Value& Request::get_element(Value& ncontext, const String& name) {
1.376 moko 1334: #ifdef FEATURE_GET_ELEMENT4CALL
1335: Value* value=ncontext.get_element(name);
1336: return *(value ? &process_to_value(*value) : VVoid::get());
1337: }
1338:
1339: Value& Request::get_element4call(Value& ncontext, const String& name) {
1340: #endif
1.353 misha 1341: if(wcontext->get_somebody_entered_some_class()) // ^class:method
1342: if(VStateless_class *called_class=ncontext.get_class())
1343: if(VStateless_class *read_class=rcontext->get_class())
1.354 misha 1344: if(read_class->derived_from(*called_class)){ // current derived from called
1345: Value *value=called_class->get_element(get_self(), name);
1346: return *(value ? &process_to_value(*value) : VVoid::get());
1347: }
1.330 misha 1348:
1.376 moko 1349: #ifdef FEATURE_GET_ELEMENT4CALL
1350: Value* value=ncontext.get_element4call(name);
1351: #else
1.354 misha 1352: Value* value=ncontext.get_element(name);
1.376 moko 1353: #endif
1.330 misha 1354: return *(value ? &process_to_value(*value) : VVoid::get());
1.309 paf 1355: }
1356:
1.329 misha 1357: void Request::put_element(Value& ncontext, const String& name, Value* value) {
1.309 paf 1358: // put_element can return property-setting-junction
1.371 moko 1359: if(const VJunction* vjunction=ncontext.put_element(name, value))
1.312 paf 1360: if(vjunction!=PUT_ELEMENT_REPLACED_ELEMENT) {
1.363 moko 1361: const Junction& junction = vjunction->junction();
1.364 moko 1362: VConstructorFrame frame(*junction.method, method_frame /*caller*/, junction.self);
1.329 misha 1363:
1.352 misha 1364: size_t param_count=frame.method_params_count();
1.364 moko 1365:
1366: if(junction.auto_name){
1367: // default setter
1368: if(param_count!=2)
1369: throw Exception(PARSER_RUNTIME,
1370: 0,
1371: "default setter method must have TWO parameters (has %d parameters)", param_count);
1372:
1373: Value* params[2] = { new VString(*junction.auto_name), value };
1374: frame.store_params(params, 2);
1375:
1376: Temp_disable_default_setter temp(junction.self);
1.365 moko 1377: execute_method(frame);
1.364 moko 1378: } else {
1379: // setter
1380: if(param_count!=1)
1381: throw Exception(PARSER_RUNTIME,
1382: 0,
1383: "setter method must have ONE parameter (has %d parameters)", param_count);
1384:
1385: frame.store_params(&value, 1);
1.365 moko 1386: execute_method(frame);
1.364 moko 1387: }
1388: }
1389: }
1390:
1391: StringOrValue Request::process_getter(Junction& junction) {
1392: VMethodFrame frame(*junction.method, method_frame/*caller*/, junction.self);
1393: size_t param_count=frame.method_params_count();
1394:
1395: if(junction.auto_name){
1396: // default getter
1397: Value *param;
1398:
1399: if(param_count){
1400: if(param_count>1)
1.316 misha 1401: throw Exception(PARSER_RUNTIME,
1.309 paf 1402: 0,
1.364 moko 1403: "default getter method can't have more then 1 parameter (has %d parameters)", param_count);
1404: param=new VString(*junction.auto_name);
1405: frame.store_params(¶m, 1);
1406: } // no need for else frame.empty_params()
1407:
1408: Temp_disable_default_getter temp(junction.self);
1.365 moko 1409: execute_method(frame);
1.364 moko 1410: } else {
1411: // getter
1412: if(param_count!=0)
1413: throw Exception(PARSER_RUNTIME,
1414: 0,
1415: "getter method must have no parameters (has %d parameters)", param_count);
1416:
1417: // no need for frame.empty_params()
1.365 moko 1418: execute_method(frame);
1.364 moko 1419: }
1.309 paf 1420:
1.364 moko 1421: return frame.result();
1.34 paf 1422: }
1.70 paf 1423:
1.162 parser 1424: /** @param intercept_string
1.116 paf 1425: - true:
1426: they want result=string value,
1427: possible object result goes to wcontext
1428: - false:
1429: they want any result[string|object]
1430: nothing goes to wcontext.
1.125 paf 1431: used in @c (expression) params evaluation
1.224 paf 1432:
1.334 misha 1433: using the fact it's either string_ or value_ result requested to speed up checkes
1.116 paf 1434: */
1.364 moko 1435:
1.229 paf 1436: StringOrValue Request::process(Value& input_value, bool intercept_string) {
1.297 paf 1437: Junction* junction=input_value.get_junction();
1.307 paf 1438: if(junction) {
1439: if(junction->is_getter) { // is it a getter-junction?
1.375 moko 1440: return process(process_getter(*junction).as_value(), intercept_string);
1.307 paf 1441: }
1442:
1443: if(junction->code) { // is it a code-junction?
1444: // process it
1445: StringOrValue result;
1.336 misha 1446:
1447: DEBUG_PRINT_STR("ja->\n")
1.238 paf 1448:
1.307 paf 1449: if(!junction->method_frame)
1.316 misha 1450: throw Exception(PARSER_RUNTIME,
1.352 misha 1451: 0,
1452: "junction used outside of context");
1.240 paf 1453:
1.330 misha 1454: SAVE_CONTEXT
1.307 paf 1455:
1456: method_frame=junction->method_frame;
1457: rcontext=junction->rcontext;
1458:
1459: // for expression method params
1460: // wcontext is set 0
1461: // using the fact in decision "which wwrapper to use"
1462: bool using_code_frame=intercept_string && junction->wcontext;
1463: if(using_code_frame) {
1.318 misha 1464: // almost plain wwrapper about junction wcontext
1465:
1466: VCodeFrame local(*junction->wcontext);
1.307 paf 1467: wcontext=&local;
1468:
1469: // execute it
1470: recoursion_checked_execute(*junction->code);
1471:
1472: // CodeFrame soul:
1.318 misha 1473: result=wcontext->result();
1.307 paf 1474: } else {
1475: // plain wwrapper
1.351 misha 1476: WWrapper local(wcontext);
1.307 paf 1477: wcontext=&local;
1478:
1479: // execute it
1480: recoursion_checked_execute(*junction->code);
1481:
1482: result=wcontext->result();
1483: }
1484:
1.330 misha 1485: RESTORE_CONTEXT
1.207 paf 1486:
1.336 misha 1487: DEBUG_PRINT_STR("<-ja returned")
1488:
1.307 paf 1489: return result;
1490: }
1491:
1492: // it is then method-junction, do not explode it
1493: // just return it as we do for usual objects
1494: }
1495:
1496: return input_value;
1.85 paf 1497: }
1498:
1.332 misha 1499: void Request::process_write(Value& input_value) {
1500: Junction* junction=input_value.get_junction();
1501: if(junction) {
1.375 moko 1502: // no getter-junction check as process_write is called
1503: // to process method arguments, not from get_element
1.332 misha 1504:
1505: if(junction->code) { // is it a code-junction?
1506: // process it
1.336 misha 1507:
1508: DEBUG_PRINT_STR("ja->\n")
1509:
1.332 misha 1510: if(!junction->method_frame)
1511: throw Exception(PARSER_RUNTIME,
1512: 0,
1513: "junction used outside of context");
1514:
1515: SAVE_CONTEXT
1516:
1517: method_frame=junction->method_frame;
1518: rcontext=junction->rcontext;
1519:
1520: // for expression method params
1521: // wcontext is set 0
1522: // using the fact in decision "which wwrapper to use"
1523: #ifdef OPTIMIZE_CALL
1524: if(wcontext==junction->wcontext){
1525: // no wrappers for wcontext
1526: recoursion_checked_execute(*junction->code);
1527: RESTORE_CONTEXT
1528:
1529: } else
1530: #endif
1531: if(junction->wcontext) {
1532: // almost plain wwrapper about junction wcontext
1533: VCodeFrame local(*junction->wcontext);
1534: wcontext=&local;
1535:
1536: // execute it
1537: recoursion_checked_execute(*junction->code);
1538: RESTORE_CONTEXT
1539: write_pass_lang(local.result());
1540: } else {
1541: // plain wwrapper
1.351 misha 1542: WWrapper local(wcontext);
1.332 misha 1543: wcontext=&local;
1544:
1545: // execute it
1546: recoursion_checked_execute(*junction->code);
1547: RESTORE_CONTEXT
1548: write_pass_lang(local.result());
1549: }
1.336 misha 1550:
1551: DEBUG_PRINT_STR("<-ja returned")
1552:
1.332 misha 1553: return;
1554: }
1555:
1556: // it is then method-junction, do not explode it
1557: // just return it as we do for usual objects
1558: }
1559:
1560: write_pass_lang(input_value);
1561: }
1562:
1.365 moko 1563: void Request::execute_method(VMethodFrame& aframe) {
1.330 misha 1564: SAVE_CONTEXT
1.99 paf 1565:
1566: // initialize contexts
1.365 moko 1567: rcontext=wcontext=method_frame=&aframe;
1.99 paf 1568:
1569: // execute!
1.365 moko 1570: recoursion_checked_execute(*aframe.method.parser_code);
1.208 paf 1571:
1.330 misha 1572: RESTORE_CONTEXT
1.208 paf 1573: }
1574:
1.297 paf 1575: const String* Request::execute_method(Value& aself,
1.329 misha 1576: const Method& method, Value* optional_param,
1577: bool do_return_string) {
1.317 misha 1578:
1.363 moko 1579: VMethodFrame local_frame(method, method_frame/*caller*/, aself);
1.365 moko 1580:
1.329 misha 1581: if(optional_param && local_frame.method_params_count()>0) {
1582: local_frame.store_params(&optional_param, 1);
1.330 misha 1583: } else {
1584: local_frame.empty_params();
1.242 paf 1585: }
1.246 paf 1586:
1587: // prevent non-string writes for better error reporting
1.297 paf 1588: if(do_return_string)
1.357 misha 1589: local_frame.write(local_frame);
1.208 paf 1590:
1.365 moko 1591: execute_method(local_frame);
1.99 paf 1592:
1.365 moko 1593: return do_return_string ? local_frame.get_string() : 0;
1.242 paf 1594: }
1595:
1.297 paf 1596: Request::Execute_nonvirtual_method_result
1597: Request::execute_nonvirtual_method(VStateless_class& aclass,
1.330 misha 1598: const String& method_name,
1599: VString* optional_param,
1600: bool do_return_string) {
1.297 paf 1601: Execute_nonvirtual_method_result result;
1602: result.method=aclass.get_method(method_name);
1603: if(result.method)
1.317 misha 1604: result.string=execute_method(aclass, *result.method, optional_param, do_return_string);
1.297 paf 1605: return result;
1.99 paf 1606: }
1607:
1.297 paf 1608: const String* Request::execute_virtual_method(Value& aself,
1.330 misha 1609: const String& method_name) {
1.354 misha 1610: if(Value* value=aself.get_element(method_name))
1.297 paf 1611: if(Junction* junction=value->get_junction())
1612: if(const Method *method=junction->method)
1613: return execute_method(aself, *method, 0/*no params*/, true);
1.188 parser 1614:
1.176 parser 1615: return 0;
1616: }
1.362 misha 1617:
1618: const String* Request::get_method_filename(const Method* method){
1619: if(ArrayOperation* code=method->parser_code)
1620: if(code){
1621: Operation::Origin origin={0, 0, 0};
1622: Array_iterator<Operation> i(*code);
1623: while( i.has_next() ){
1624: switch( i.next().code ){
1625: case OP::OP_CURLY_CODE__STORE_PARAM:
1626: case OP::OP_EXPR_CODE__STORE_PARAM:
1627: case OP::OP_CURLY_CODE__CONSTRUCT:
1628: case OP::OP_NESTED_CODE:
1629: case OP::OP_OBJECT_POOL:
1630: case OP::OP_STRING_POOL:
1631: case OP::OP_CALL:
1632: case OP::OP_CALL__WRITE:
1633: {
1634: i.next(); // skip local ops
1635: i.next(); // skip next opcode
1636: // continue execution
1637: }
1638: case OP::OP_CONSTRUCT_OBJECT:
1639: case OP::OP_CONSTRUCT_OBJECT__WRITE:
1640: case OP::OP_VALUE:
1641: case OP::OP_STRING__WRITE:
1642: case OP::OP_VALUE__GET_CLASS:
1643: #ifdef OPTIMIZE_BYTECODE_GET_OBJECT_ELEMENT
1644: case OP::OP_GET_OBJECT_ELEMENT:
1645: case OP::OP_GET_OBJECT_ELEMENT__WRITE:
1646: #endif
1647: #ifdef OPTIMIZE_BYTECODE_GET_OBJECT_VAR_ELEMENT
1648: case OP::OP_GET_OBJECT_VAR_ELEMENT:
1649: case OP::OP_GET_OBJECT_VAR_ELEMENT__WRITE:
1650: #endif
1651: #ifdef OPTIMIZE_BYTECODE_GET_ELEMENT
1652: case OP::OP_VALUE__GET_ELEMENT:
1653: case OP::OP_VALUE__GET_ELEMENT__WRITE:
1654: case OP::OP_VALUE__GET_ELEMENT_OR_OPERATOR:
1655: case OP::OP_WITH_ROOT__VALUE__GET_ELEMENT:
1656: #endif
1657: #ifdef OPTIMIZE_BYTECODE_GET_SELF_ELEMENT
1658: case OP::OP_WITH_SELF__VALUE__GET_ELEMENT:
1659: case OP::OP_WITH_SELF__VALUE__GET_ELEMENT__WRITE:
1660: #endif
1.377 moko 1661:
1662: #ifdef FEATURE_GET_ELEMENT4CALL
1663: case OP::OP_GET_ELEMENT4CALL:
1664: #ifdef OPTIMIZE_BYTECODE_GET_OBJECT_ELEMENT
1665: case OP::OP_GET_OBJECT_ELEMENT4CALL:
1666: #endif
1667: #ifdef OPTIMIZE_BYTECODE_GET_OBJECT_VAR_ELEMENT
1668: case OP::OP_GET_OBJECT_VAR_ELEMENT4CALL:
1669: #endif
1670: #endif // FEATURE_GET_ELEMENT4CALL
1671:
1.362 misha 1672: #ifdef OPTIMIZE_BYTECODE_CONSTRUCT
1673: case OP::OP_WITH_ROOT__VALUE__CONSTRUCT_EXPR:
1674: case OP::OP_WITH_ROOT__VALUE__CONSTRUCT_VALUE:
1675: case OP::OP_WITH_WRITE__VALUE__CONSTRUCT_EXPR:
1676: case OP::OP_WITH_WRITE__VALUE__CONSTRUCT_VALUE:
1677: case OP::OP_WITH_SELF__VALUE__CONSTRUCT_EXPR:
1678: case OP::OP_WITH_SELF__VALUE__CONSTRUCT_VALUE:
1679: #endif
1680: {
1681: origin=i.next().origin;
1682: break;
1683: }
1.373 moko 1684: default: break;
1.362 misha 1685: }
1686: if(origin.file_no)
1687: return get_used_filename(origin.file_no);
1688: }
1689: }
1690: return 0;
1691: }
1692: