|
|
| version 1.59, 2001/03/07 10:10:50 | version 1.63, 2001/03/07 13:54:48 |
|---|---|
| Line 80 void dump(int level, const Array& ops) { | Line 80 void dump(int level, const Array& ops) { |
| dump(level+1, *local_ops); | dump(level+1, *local_ops); |
| } | } |
| } | } |
| fflush(stderr); | |
| } | } |
| void Request::execute(const Array& ops) { | void Request::execute(const Array& ops) { |
| Line 94 void Request::execute(const Array& ops) | Line 95 void Request::execute(const Array& ops) |
| 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); |
| fprintf(stderr, "%d:%s", stack.top(), opcode_name[op.code]); | fprintf(stderr, "%d:%s", stack.top()+1, opcode_name[op.code]); fflush(stderr); |
| switch(op.code) { | switch(op.code) { |
| // param in next instruction | // param in next instruction |
| Line 107 void Request::execute(const Array& ops) | Line 108 void Request::execute(const Array& ops) |
| } | } |
| case OP_CODE: | case OP_CODE: |
| { | { |
| VMethodFrame *frame=static_cast<VMethodFrame *>(stack[stack.top()]); | |
| const Array *local_ops=reinterpret_cast<const Array *>(ops.quick_get(++i)); | const Array *local_ops=reinterpret_cast<const Array *>(ops.quick_get(++i)); |
| fprintf(stderr, " (%d)\n", local_ops->size()); | fprintf(stderr, " (%d)\n", local_ops->size()); |
| dump(1, *local_ops); | dump(1, *local_ops); |
| // TODO: rcontext junction должен быть контекстом вызываемого объекта | |
| // чтобы вот эти конструкции орудовали одними полями внутри {} : | |
| // $var{$field} | |
| // ^var.menu{$field} | |
| // поскольку они суть одно и то же, и так удобнее | |
| Junction& j=*NEW Junction(pool(), | Junction& j=*NEW Junction(pool(), |
| *self, 0, 0, | *self, 0, 0, |
| root,rcontext,wcontext,local_ops); | rcontext, frame, frame, local_ops); |
| Value *value=NEW VJunction(j); | Value *value=NEW VJunction(j); |
| value->set_name(frame->name()); | |
| PUSH(value); | PUSH(value); |
| break; | break; |
| } | } |
| Line 247 void Request::execute(const Array& ops) | Line 246 void Request::execute(const Array& ops) |
| value->type()); | value->type()); |
| //unless(method) method=operators.get_method[...;code/native_code](name) | //unless(method) method=operators.get_method[...;code/native_code](name) |
| VMethodFrame *frame=NEW VMethodFrame(pool(), *junction); | VMethodFrame *frame=NEW VMethodFrame(pool(), *junction); |
| frame->set_name(junction->self.name()); | |
| PUSH(frame); | PUSH(frame); |
| break; | break; |
| } | } |
| Line 296 void Request::execute(const Array& ops) | Line 296 void Request::execute(const Array& ops) |
| rcontext=POP(); | rcontext=POP(); |
| root=POP(); | root=POP(); |
| self=static_cast<VAliased *>(POP()); | self=static_cast<VAliased *>(POP()); |
| wcontext->write(value); | |
| PUSH(value); | |
| fprintf(stderr, "<-returned"); | fprintf(stderr, "<-returned"); |
| break; | break; |
| } | } |
| Line 312 void Request::execute(const Array& ops) | Line 313 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(), |
| ~static_cast<int>(operand->get_double())); | |
| PUSH(value); | PUSH(value); |
| break; | break; |
| } | } |
| Line 323 void Request::execute(const Array& ops) | Line 325 void Request::execute(const Array& ops) |
| PUSH(value); | PUSH(value); |
| break; | break; |
| } | } |
| //todo: def in fexists | case OP_DEF: |
| { | |
| Value *operand=POP(); | |
| Value *value=NEW VBool(pool(), operand->get_defined()); | |
| PUSH(value); | |
| break; | |
| } | |
| case OP_IN: | |
| { | |
| Value *operand=POP(); | |
| Value *value=NEW VBool(pool(), true/*TODO*/); | |
| PUSH(value); | |
| break; | |
| } | |
| case OP_FEXISTS: | |
| { | |
| Value *operand=POP(); | |
| Value *value=NEW VBool(pool(), true/*TODO*/); | |
| PUSH(value); | |
| break; | |
| } | |
| // expression ops: binary | // expression ops: binary |
| case OP_SUB: | case OP_SUB: |
| { | { |
| Value *b=POP(); | Value *b=POP(); Value *a=POP(); |
| Value *a=POP(); | Value *value=NEW VDouble(pool(), a->get_double() - b->get_double()); |
| Value *value=NEW VDouble(pool(), | |
| a->get_double() - | |
| b->get_double()); | |
| PUSH(value); | PUSH(value); |
| break; | break; |
| } | } |
| case OP_ADD: | case OP_ADD: |
| { | { |
| Value *b=POP(); | Value *b=POP(); Value *a=POP(); |
| Value *a=POP(); | Value *value=NEW VDouble(pool(), a->get_double() + b->get_double()); |
| Value *value=NEW VDouble(pool(), | |
| a->get_double() + | |
| b->get_double()); | |
| PUSH(value); | PUSH(value); |
| break; | break; |
| } | } |
| case OP_MUL: | case OP_MUL: |
| { | { |
| Value *b=POP(); | Value *b=POP(); Value *a=POP(); |
| Value *a=POP(); | Value *value=NEW VDouble(pool(), a->get_double() * b->get_double()); |
| Value *value=NEW VDouble(pool(), | |
| a->get_double() * | |
| b->get_double()); | |
| PUSH(value); | PUSH(value); |
| break; | break; |
| } | } |
| case OP_DIV: | case OP_DIV: |
| { | { |
| Value *b=POP(); | Value *b=POP(); Value *a=POP(); |
| Value *a=POP(); | Value *value=NEW VDouble(pool(), a->get_double() / b->get_double()); |
| Value *value=NEW VDouble(pool(), | |
| a->get_double() / | |
| b->get_double()); | |
| PUSH(value); | PUSH(value); |
| break; | break; |
| } | } |
| case OP_MOD: | case OP_MOD: |
| { | { |
| Value *b=POP(); | Value *b=POP(); Value *a=POP(); |
| Value *a=POP(); | |
| Value *value=NEW VDouble(pool(), | Value *value=NEW VDouble(pool(), |
| static_cast<int>(a->get_double()) % | static_cast<int>(a->get_double()) % |
| static_cast<int>(b->get_double())); | static_cast<int>(b->get_double())); |
| Line 378 void Request::execute(const Array& ops) | Line 387 void Request::execute(const Array& ops) |
| } | } |
| case OP_BIN_AND: | case OP_BIN_AND: |
| { | { |
| Value *b=POP(); | Value *b=POP(); Value *a=POP(); |
| Value *a=POP(); | |
| Value *value=NEW VDouble(pool(), | Value *value=NEW VDouble(pool(), |
| static_cast<int>(a->get_double()) & | static_cast<int>(a->get_double()) & |
| static_cast<int>(b->get_double())); | static_cast<int>(b->get_double())); |
| Line 388 void Request::execute(const Array& ops) | Line 396 void Request::execute(const Array& ops) |
| } | } |
| case OP_BIN_OR: | case OP_BIN_OR: |
| { | { |
| Value *b=POP(); | Value *b=POP(); Value *a=POP(); |
| Value *a=POP(); | |
| Value *value=NEW VDouble(pool(), | Value *value=NEW VDouble(pool(), |
| static_cast<int>(a->get_double()) | | static_cast<int>(a->get_double()) | |
| static_cast<int>(b->get_double())); | static_cast<int>(b->get_double())); |
| Line 398 void Request::execute(const Array& ops) | Line 405 void Request::execute(const Array& ops) |
| } | } |
| case OP_BIN_XOR: | case OP_BIN_XOR: |
| { | { |
| Value *b=POP(); | Value *b=POP(); Value *a=POP(); |
| Value *a=POP(); | |
| Value *value=NEW VDouble(pool(), | Value *value=NEW VDouble(pool(), |
| static_cast<int>(a->get_double()) ^ | static_cast<int>(a->get_double()) ^ |
| static_cast<int>(b->get_double())); | static_cast<int>(b->get_double())); |
| Line 408 void Request::execute(const Array& ops) | Line 414 void Request::execute(const Array& ops) |
| } | } |
| case OP_LOG_AND: | case OP_LOG_AND: |
| { | { |
| Value *b=POP(); | Value *b=POP(); Value *a=POP(); |
| Value *a=POP(); | Value *value=NEW VBool(pool(), a->get_bool() && b->get_bool()); |
| Value *value=NEW VBool(pool(), | |
| a->get_bool() && | |
| b->get_bool()); | |
| PUSH(value); | PUSH(value); |
| break; | break; |
| } | } |
| case OP_LOG_OR: | case OP_LOG_OR: |
| { | { |
| Value *b=POP(); | Value *b=POP(); Value *a=POP(); |
| Value *a=POP(); | Value *value=NEW VBool(pool(), a->get_bool() || b->get_bool()); |
| Value *value=NEW VBool(pool(), | |
| a->get_bool() || | |
| b->get_bool()); | |
| PUSH(value); | PUSH(value); |
| break; | break; |
| } | } |
| case OP_LOG_XOR: | case OP_LOG_XOR: |
| { | { |
| Value *b=POP(); | Value *b=POP(); Value *a=POP(); |
| Value *a=POP(); | Value *value=NEW VBool(pool(), a->get_bool() ^ b->get_bool()); |
| Value *value=NEW VBool(pool(), | |
| a->get_bool() ^ | |
| b->get_bool()); | |
| PUSH(value); | PUSH(value); |
| break; | break; |
| } | } |
| case OP_NUM_LT: | case OP_NUM_LT: |
| { | { |
| Value *b=POP(); | Value *b=POP(); Value *a=POP(); |
| Value *a=POP(); | Value *value=NEW VBool(pool(), a->get_double() < b->get_double()); |
| Value *value=NEW VBool(pool(), | |
| a->get_double() < | |
| b->get_double()); | |
| PUSH(value); | PUSH(value); |
| break; | break; |
| } | } |
| case OP_NUM_GT: | case OP_NUM_GT: |
| { | { |
| Value *b=POP(); | Value *b=POP(); Value *a=POP(); |
| Value *a=POP(); | Value *value=NEW VBool(pool(), a->get_double() > b->get_double()); |
| Value *value=NEW VBool(pool(), | |
| a->get_double() > | |
| b->get_double()); | |
| PUSH(value); | PUSH(value); |
| break; | break; |
| } | } |
| case OP_NUM_LE: | case OP_NUM_LE: |
| { | { |
| Value *b=POP(); | Value *b=POP(); Value *a=POP(); |
| Value *a=POP(); | Value *value=NEW VBool(pool(), a->get_double() <= b->get_double()); |
| Value *value=NEW VBool(pool(), | |
| a->get_double() <= | |
| b->get_double()); | |
| PUSH(value); | PUSH(value); |
| break; | break; |
| } | } |
| case OP_NUM_GE: | case OP_NUM_GE: |
| { | { |
| Value *b=POP(); | Value *b=POP(); Value *a=POP(); |
| Value *a=POP(); | Value *value=NEW VBool(pool(), a->get_double() >= b->get_double()); |
| Value *value=NEW VBool(pool(), | |
| a->get_double() >= | |
| b->get_double()); | |
| PUSH(value); | PUSH(value); |
| break; | break; |
| } | } |
| case OP_NUM_EQ: | case OP_NUM_EQ: |
| { | { |
| Value *b=POP(); | Value *b=POP(); Value *a=POP(); |
| Value *a=POP(); | Value *value=NEW VBool(pool(), a->get_double() == b->get_double()); |
| Value *value=NEW VBool(pool(), | |
| a->get_double() == | |
| b->get_double()); | |
| PUSH(value); | PUSH(value); |
| break; | break; |
| } | } |
| case OP_NUM_NE: | case OP_NUM_NE: |
| { | { |
| Value *b=POP(); | Value *b=POP(); Value *a=POP(); |
| Value *a=POP(); | Value *value=NEW VBool(pool(), a->get_double() != b->get_double()); |
| Value *value=NEW VBool(pool(), | |
| a->get_double() != | |
| b->get_double()); | |
| PUSH(value); | PUSH(value); |
| break; | break; |
| } | } |
| case OP_STR_LT: | case OP_STR_LT: |
| { | { |
| Value *b=POP(); | Value *b=POP(); Value *a=POP(); |
| Value *a=POP(); | Value *value=NEW VBool(pool(), a->as_string() < b->as_string()); |
| Value *value=NEW VBool(pool(), | |
| a->as_string() < | |
| b->as_string()); | |
| PUSH(value); | PUSH(value); |
| break; | break; |
| } | } |
| case OP_STR_GT: | case OP_STR_GT: |
| { | { |
| Value *b=POP(); | Value *b=POP(); Value *a=POP(); |
| Value *a=POP(); | Value *value=NEW VBool(pool(), a->as_string() > b->as_string()); |
| Value *value=NEW VBool(pool(), | |
| a->as_string() > | |
| b->as_string()); | |
| PUSH(value); | PUSH(value); |
| break; | break; |
| } | } |
| case OP_STR_LE: | case OP_STR_LE: |
| { | { |
| Value *b=POP(); | Value *b=POP(); Value *a=POP(); |
| Value *a=POP(); | Value *value=NEW VBool(pool(), a->as_string() <= b->as_string()); |
| Value *value=NEW VBool(pool(), | |
| a->as_string() <= | |
| b->as_string()); | |
| PUSH(value); | PUSH(value); |
| break; | break; |
| } | } |
| case OP_STR_GE: | case OP_STR_GE: |
| { | { |
| Value *b=POP(); | Value *b=POP(); Value *a=POP(); |
| Value *a=POP(); | Value *value=NEW VBool(pool(), a->as_string() >= b->as_string()); |
| Value *value=NEW VBool(pool(), | |
| a->as_string() >= | |
| b->as_string()); | |
| PUSH(value); | PUSH(value); |
| break; | break; |
| } | } |
| case OP_STR_EQ: | case OP_STR_EQ: |
| { | { |
| Value *b=POP(); | Value *b=POP(); Value *a=POP(); |
| Value *a=POP(); | Value *value=NEW VBool(pool(), a->as_string() == b->as_string()); |
| Value *value=NEW VBool(pool(), | |
| a->as_string() == | |
| b->as_string()); | |
| PUSH(value); | PUSH(value); |
| break; | break; |
| } | } |
| case OP_STR_NE: | case OP_STR_NE: |
| { | { |
| Value *b=POP(); | Value *b=POP(); Value *a=POP(); |
| Value *a=POP(); | Value *value=NEW VBool(pool(), a->as_string() != b->as_string()); |
| Value *value=NEW VBool(pool(), | |
| a->as_string() != | |
| b->as_string()); | |
| PUSH(value); | PUSH(value); |
| break; | break; |
| } | } |
| Line 596 Value *Request::get_element() { | Line 557 Value *Request::get_element() { |
| rcontext=POP(); | rcontext=POP(); |
| root=POP(); | root=POP(); |
| self=static_cast<VAliased *>(POP()); | self=static_cast<VAliased *>(POP()); |
| fprintf(stderr, "<-ja returned"); | fprintf(stderr, "<-ja returned"); |
| } | } |
| } else { | } else |
| value=NEW VUnknown(pool()); | value=NEW VUnknown(pool()); |
| value->set_name(name); | |
| } | value->set_name(name); |
| return value; | return value; |
| } | } |