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