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