|
|
| version 1.92, 2001/03/12 09:08:51 | version 1.97, 2001/03/12 21:18:01 |
|---|---|
| Line 17 | Line 17 |
| #include "pa_vobject.h" | #include "pa_vobject.h" |
| #include "pa_vdouble.h" | #include "pa_vdouble.h" |
| #include "pa_vbool.h" | #include "pa_vbool.h" |
| #include "pa_vtable.h" | |
| #include <stdio.h> | #include <stdio.h> |
| Line 274 void Request::execute(const Array& ops) | Line 275 void Request::execute(const Array& ops) |
| if(!junction) | if(!junction) |
| THROW(0,0, | THROW(0,0, |
| &value->name(), | &value->name(), |
| "type is '%s', can not call it (must be method or junction)", | "(%s) uncallable, must be method or junction", |
| value->type()); | value->type()); |
| VMethodFrame *frame=NEW VMethodFrame(pool(), *junction); | VMethodFrame *frame=NEW VMethodFrame(pool(), *junction); |
| Line 308 void Request::execute(const Array& ops) | Line 309 void Request::execute(const Array& ops) |
| self=rcontext; // class dynamic call | self=rcontext; // class dynamic call |
| else // no, not me or relative of mine (total stranger) | else // no, not me or relative of mine (total stranger) |
| if(wcontext->constructing()) { // constructing? | if(wcontext->constructing()) { // constructing? |
| // yes, constructor call: $some(^class:method(..)) | // yes, constructor call: $some[^class:method[..]] |
| self=NEW VObject(pool(), *called_class); | if(called_class->name()==TABLE_CLASS_NAME) |
| self=NEW VTable(pool()); | |
| else | |
| self=NEW VObject(pool(), *called_class); | |
| frame->write(*self, | frame->write(*self, |
| String::Untaint_lang::NO // not used, always an object, not string | String::Untaint_lang::NO // not used, always an object, not string |
| ); | ); |
| Line 356 void Request::execute(const Array& ops) | Line 360 void Request::execute(const Array& ops) |
| case OP_INV: | case OP_INV: |
| { | { |
| Value *operand=POP(); | Value *operand=POP(); |
| Value *value=NEW VDouble(pool(), ~static_cast<int>(operand->get_double())); | Value *value=NEW VDouble(pool(), ~(int)operand->get_double()); |
| PUSH(value); | PUSH(value); |
| break; | break; |
| } | } |
| Line 422 void Request::execute(const Array& ops) | Line 426 void Request::execute(const Array& ops) |
| { | { |
| Value *b=POP(); Value *a=POP(); | Value *b=POP(); Value *a=POP(); |
| Value *value=NEW VDouble(pool(), | Value *value=NEW VDouble(pool(), |
| static_cast<int>(a->get_double()) % | (int)a->get_double() % |
| static_cast<int>(b->get_double())); | (int)b->get_double()); |
| PUSH(value); | PUSH(value); |
| break; | break; |
| } | } |
| Line 431 void Request::execute(const Array& ops) | Line 435 void Request::execute(const Array& ops) |
| { | { |
| Value *b=POP(); Value *a=POP(); | Value *b=POP(); Value *a=POP(); |
| Value *value=NEW VDouble(pool(), | Value *value=NEW VDouble(pool(), |
| static_cast<int>(a->get_double()) & | (int)a->get_double() & |
| static_cast<int>(b->get_double())); | (int)b->get_double()); |
| PUSH(value); | PUSH(value); |
| break; | break; |
| } | } |
| Line 440 void Request::execute(const Array& ops) | Line 444 void Request::execute(const Array& ops) |
| { | { |
| Value *b=POP(); Value *a=POP(); | Value *b=POP(); Value *a=POP(); |
| Value *value=NEW VDouble(pool(), | Value *value=NEW VDouble(pool(), |
| static_cast<int>(a->get_double()) | | (int)a->get_double() | |
| static_cast<int>(b->get_double())); | (int)b->get_double()); |
| PUSH(value); | PUSH(value); |
| break; | break; |
| } | } |
| Line 449 void Request::execute(const Array& ops) | Line 453 void Request::execute(const Array& ops) |
| { | { |
| Value *b=POP(); Value *a=POP(); | Value *b=POP(); Value *a=POP(); |
| Value *value=NEW VDouble(pool(), | Value *value=NEW VDouble(pool(), |
| static_cast<int>(a->get_double()) ^ | (int)a->get_double() ^ |
| static_cast<int>(b->get_double())); | (int)b->get_double()); |
| PUSH(value); | PUSH(value); |
| break; | break; |
| } | } |
| Line 642 Value& Request::process(Value& value, co | Line 646 Value& Request::process(Value& value, co |
| } | } |
| char *Request::execute_static_method(VClass& vclass, String& method_name, bool return_cstr) { | char *Request::execute_static_method(VClass& vclass, String& method_name, bool return_cstr) { |
| if(Value *value=vclass.get_element(method_name)) { // found some 'METHOD_NAME' element | if(const Method *method=vclass.get_method(method_name)) { |
| if(Junction *junction=value->get_junction()) {// it even has junction! | PUSH(self); |
| if(const Method *method=junction->method) { // and junction is method-junction! call it | PUSH(root); |
| PUSH(self); | PUSH(rcontext); |
| PUSH(root); | PUSH(wcontext); |
| PUSH(rcontext); | |
| PUSH(wcontext); | // initialize contexts |
| root=rcontext=self=&vclass; | |
| // initialize contexts | wcontext=NEW WWrapper(pool(), &vclass, false /* not constructing */); |
| root=rcontext=self=&vclass; | |
| wcontext=NEW WWrapper(pool(), &vclass, false /* not constructing */); | // execute! |
| execute(*method->parser_code); | |
| // execute! | |
| execute(*method->parser_code); | // result |
| char *result; | |
| // result | if(return_cstr) |
| char *result; | result=wcontext->get_string()->cstr(); // chars |
| if(return_cstr) | else |
| result=wcontext->get_string()->cstr(); // chars | result=0; // ignore result |
| else | |
| result=0; // ignore result | wcontext=static_cast<WContext *>(POP()); |
| rcontext=POP(); | |
| wcontext=static_cast<WContext *>(POP()); | root=POP(); |
| rcontext=POP(); | self=static_cast<VAliased *>(POP()); |
| root=POP(); | |
| self=static_cast<VAliased *>(POP()); | // return |
| return result; | |
| // return | |
| return result; | |
| } | |
| } | |
| } | } |
| return 0; | return 0; |
| } | } |