|
|
| version 1.129, 2001/03/27 17:12:23 | version 1.136, 2001/04/03 05:23:41 |
|---|---|
| Line 21 | Line 21 |
| #include "pa_vdouble.h" | #include "pa_vdouble.h" |
| #include "pa_vbool.h" | #include "pa_vbool.h" |
| #include "pa_vtable.h" | #include "pa_vtable.h" |
| #include "pa_vfile.h" | |
| #include <stdio.h> | #include <stdio.h> |
| Line 58 char *opcode_name[]={ | Line 59 char *opcode_name[]={ |
| }; | }; |
| void va_log_printf(Pool& pool, const char *fmt,va_list args) { | void va_log_printf(Pool& pool, const char *fmt,va_list args) { |
| // return; | return; |
| char buf[MAX_STRING]; | char buf[MAX_STRING]; |
| vsnprintf(buf, MAX_STRING, fmt, args); | vsnprintf(buf, MAX_STRING, fmt, args); |
| SAPI::log(pool, "%s", buf); | SAPI::log(pool, "%s", buf); |
| Line 73 void log_printf(Pool& pool, const char * | Line 74 void log_printf(Pool& pool, const char * |
| void dump(Pool& pool, int level, const Array& ops) { | void dump(Pool& pool, int level, const Array& ops) { |
| if(0){ | if(0){ |
| int size=ops.size(); | int size=ops.quick_size(); |
| //log_printf(pool, "size=%d\n", size); | //log_printf(pool, "size=%d\n", size); |
| for(int i=0; i<size; i++) { | for(int i=0; i<size; i++) { |
| Operation op; | Operation op; |
| Line 82 void dump(Pool& pool, int level, const A | Line 83 void dump(Pool& pool, int level, const A |
| } | } |
| } | } |
| int size=ops.size(); | int size=ops.quick_size(); |
| //log_printf(pool, "size=%d\n", size); | //log_printf(pool, "size=%d\n", size); |
| for(int i=0; i<size; i++) { | for(int i=0; i<size; i++) { |
| Operation op; | Operation op; |
| op.cast=ops.quick_get(i); | op.cast=ops.quick_get(i); |
| log_printf(pool, "%*s%s", level*4, "", opcode_name[op.code]); | |
| if(op.code==OP_VALUE || op.code==OP_STRING__WRITE) { | if(op.code==OP_VALUE || op.code==OP_STRING__WRITE) { |
| Value *value=static_cast<Value *>(ops.quick_get(++i)); | Value *value=static_cast<Value *>(ops.quick_get(++i)); |
| log_printf(pool, " \"%s\" %s", value->get_string()->cstr(), value->type()); | log_printf(pool, |
| "%*s%s" | |
| " \"%s\" %s", | |
| level*4, "", opcode_name[op.code], | |
| value->get_string()->cstr(), value->type()); | |
| continue; | |
| } | } |
| //\log_printf(pool, "\n"); | log_printf(pool, "%*s%s", level*4, "", opcode_name[op.code]); |
| if(op.code==OP_CURLY_CODE__STORE_PARAM || op.code==OP_EXPR_CODE__STORE_PARAM) { | if(op.code==OP_CURLY_CODE__STORE_PARAM || op.code==OP_EXPR_CODE__STORE_PARAM) { |
| const Array *local_ops=reinterpret_cast<const Array *>(ops.quick_get(++i)); | const Array *local_ops=reinterpret_cast<const Array *>(ops.quick_get(++i)); |
| Line 109 void Request::execute(const Array& ops) | Line 114 void Request::execute(const Array& ops) |
| log_printf(pool(), "execution-------------------------\n"); | log_printf(pool(), "execution-------------------------\n"); |
| } | } |
| int size=ops.size(); | int size=ops.quick_size(); |
| //log_printf(pool(), "size=%d\n", size); | //log_printf(pool(), "size=%d\n", size); |
| for(int i=0; i<size; i++) { | for(int i=0; i<size; i++) { |
| Operation op; | Operation op; |
| Line 134 void Request::execute(const Array& ops) | Line 139 void Request::execute(const Array& ops) |
| log_printf(pool(), " (%d)\n", local_ops->size()); | log_printf(pool(), " (%d)\n", local_ops->size()); |
| dump(pool(), 1, *local_ops); | dump(pool(), 1, *local_ops); |
| // when called method of some object, specifying object literally, | |
| // e.g ^t.menu, code of curly params must be executed | |
| // in r/w context of that object. | |
| // otherwise in current r/w context. | |
| // | |
| // when they evaluate expression parameter, | // when they evaluate expression parameter, |
| // the object expression result | // the object expression result |
| // does not need to be written into calling frame | // does not need to be written into calling frame |
| Line 143 void Request::execute(const Array& ops) | Line 153 void Request::execute(const Array& ops) |
| // in decision "which wwrapper to use" | // in decision "which wwrapper to use" |
| Junction& j=*NEW Junction(pool(), | Junction& j=*NEW Junction(pool(), |
| *self, 0, 0, | *self, 0, 0, |
| root, frame, op.code==OP_EXPR_CODE__STORE_PARAM?0:frame, local_ops); | root, |
| wcontext->somebody_entered_some_object()>1? | |
| &frame->junction.self /* ^t.menu{} */:rcontext/* ^if() */, | |
| op.code==OP_EXPR_CODE__STORE_PARAM? | |
| 0:wcontext->somebody_entered_some_object()>1? | |
| frame/* ^t.menu{} */:wcontext/* ^if() */, | |
| local_ops); | |
| Value *value=NEW VJunction(j); | Value *value=NEW VJunction(j); |
| Line 153 void Request::execute(const Array& ops) | Line 169 void Request::execute(const Array& ops) |
| } | } |
| case OP_GET_CLASS: | case OP_GET_CLASS: |
| { | { |
| // maybe the do ^class:method[] call, remember the fact | // maybe they do ^class:method[] call, remember the fact |
| wcontext->set_somebody_entered_some_class(); | wcontext->set_somebody_entered_some_class(); |
| const String& name=POP_NAME(); | const String& name=POP_NAME(); |
| Line 230 void Request::execute(const Array& ops) | Line 246 void Request::execute(const Array& ops) |
| case OP_GET_ELEMENT: | case OP_GET_ELEMENT: |
| { | { |
| // maybe they do ^object.method[] call, remember the fact | |
| wcontext->inc_somebody_entered_some_object(); | |
| Value *value=get_element(); | Value *value=get_element(); |
| PUSH(value); | PUSH(value); |
| break; | break; |
| Line 350 void Request::execute(const Array& ops) | Line 369 void Request::execute(const Array& ops) |
| // some stateless_object derivates with constructors | // some stateless_object derivates with constructors |
| if(called_class==table_class) | if(called_class==table_class) |
| self=NEW VTable(pool()); | self=NEW VTable(pool()); |
| else if(called_class==file_class) | |
| self=NEW VFile(pool()); | |
| else // stateful object | else // stateful object |
| self=NEW VObject(pool(), *called_class); | self=NEW VObject(pool(), *called_class); |
| frame->write(*self, | frame->write(*self, |
| String::UL_NO // not used, always an object, not string | String::UL_CLEAN // not used, always an object, not string |
| ); | ); |
| } else | } else |
| self=&frame->junction.self; // no, static or simple dynamic call | self=&frame->junction.self; // no, static or simple dynamic call |
| Line 366 void Request::execute(const Array& ops) | Line 387 void Request::execute(const Array& ops) |
| Temp_alias temp_alias(*self->get_aliased(), *frame->junction.vclass); | Temp_alias temp_alias(*self->get_aliased(), *frame->junction.vclass); |
| const Method& method=*frame->junction.method; | const Method& method=*frame->junction.method; |
| if(method.native_code) { // native code? | Method::Call_type call_type= |
| method.check_actual_numbered_params( | called_class==self ? Method::CT_STATIC : Method::CT_DYNAMIC; |
| frame->junction.self, | if( |
| frame->name(), frame->numbered_params()); | method.call_type==Method::CT_ANY || |
| (*method.native_code)( | method.call_type==call_type) // allowed call type? |
| *this, | if(method.native_code) { // native code? |
| frame->name(), frame->numbered_params()); // execute it | method.check_actual_numbered_params( |
| } else // parser code | frame->junction.self, |
| execute(*method.parser_code); // execute it | frame->name(), frame->numbered_params()); |
| (*method.native_code)( | |
| *this, | |
| frame->name(), frame->numbered_params()); // execute it | |
| } else // parser code | |
| execute(*method.parser_code); // execute it | |
| else | |
| THROW(0, 0, | |
| &frame->name(), | |
| "is not allowed to be called %s", | |
| call_type==Method::CT_STATIC?"statically":"dynamically"); | |
| } | } |
| Value *value=wcontext->result(); | Value *value=wcontext->result(); |
| Line 617 void Request::execute(const Array& ops) | Line 649 void Request::execute(const Array& ops) |
| 0, | 0, |
| "unhandled '%s' opcode", opcode_name[op.code]); | "unhandled '%s' opcode", opcode_name[op.code]); |
| } | } |
| //\log_printf(pool(), "\n"); | |
| } | } |
| } | } |