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