--- parser3/src/main/execute.C 2001/03/16 09:26:43 1.108 +++ parser3/src/main/execute.C 2001/03/16 11:10:20 1.111 @@ -3,7 +3,7 @@ Copyright (c) 2001 ArtLebedev Group (http://www.artlebedev.com) Author: Alexander Petrosyan (http://design.ru/paf) - $Id: execute.C,v 1.108 2001/03/16 09:26:43 paf Exp $ + $Id: execute.C,v 1.111 2001/03/16 11:10:20 paf Exp $ */ #include "pa_array.h" @@ -20,6 +20,7 @@ #include "pa_vtable.h" #include +#include #define PUSH(value) stack.push(value) #define POP() static_cast(stack.pop()) @@ -28,7 +29,7 @@ char *opcode_name[]={ // literals - "VALUE", "CODE__STORE_PARAM", + "VALUE", "CURLY_CODE__STORE_PARAM", "EXPR_CODE__STORE_PARAM", // actions "WITH_SELF", "WITH_ROOT", "WITH_READ", "WITH_WRITE", @@ -90,7 +91,7 @@ void dump(int level, const Array& ops) { } log_printf("\n"); - if(op.code==OP_CODE__STORE_PARAM) { + if(op.code==OP_CURLY_CODE__STORE_PARAM || op.code==OP_EXPR_CODE__STORE_PARAM) { const Array *local_ops=reinterpret_cast(ops.quick_get(++i)); dump(level+1, *local_ops); } @@ -120,7 +121,8 @@ void Request::execute(const Array& ops) PUSH(value); break; } - case OP_CODE__STORE_PARAM: + case OP_CURLY_CODE__STORE_PARAM: + case OP_EXPR_CODE__STORE_PARAM: { VMethodFrame *frame=static_cast(stack.top_value()); // code @@ -128,9 +130,16 @@ void Request::execute(const Array& ops) log_printf(" (%d)\n", local_ops->size()); dump(1, *local_ops); + // when they evaluate expression parameter, + // the object expression result + // does not need to be written into calling frame + // it must go into any expressions using that parameter + // hence, zeroing junction.wcontext being created + // later, in .process would test that field + // in decision "which wwrapper to use" Junction& j=*NEW Junction(pool(), *self, 0, 0, - root, frame, frame, local_ops); + root, frame, op.code==OP_EXPR_CODE__STORE_PARAM?0:frame, local_ops); Value *value=NEW VJunction(j); @@ -291,12 +300,14 @@ void Request::execute(const Array& ops) case OP_GET_METHOD_FRAME: { Value *value=POP(); - // info: this one's always method-junction, not a code-junction + // info: + // code compiled so that this one's always method-junction, + // not a code-junction Junction *junction=value->get_junction(); if(!junction) THROW(0,0, &value->name(), - "(%s) uncallable, must be method or junction", + "(%s) not a method or junction, can not call it", value->type()); VMethodFrame *frame=NEW VMethodFrame(pool(), *junction); @@ -404,7 +415,8 @@ void Request::execute(const Array& ops) case OP_IN: { Value *operand=POP(); - Value *value=NEW VBool(pool(), true/*TODO*/); + const char *path=operand->as_string().cstr(); + Value *value=NEW VBool(pool(), strcmp(path, info.request_uri)<=0); PUSH(value); break; } @@ -639,7 +651,11 @@ Value& Request::process(Value& value, co PUSH(wcontext); WContext *frame; - if(intercept_string) { + // for expression method params + // wcontext is set 0 + // using the fact in decision "which wwrapper to use" + bool using_code_frame=intercept_string && junction->wcontext; + if(using_code_frame) { // almost plain wwrapper about junction wcontext, // BUT intercepts string writes frame=NEW VCodeFrame(pool(), *junction->wcontext); @@ -653,7 +669,7 @@ Value& Request::process(Value& value, co root=junction->root; rcontext=junction->rcontext; execute(*junction->code); - if(intercept_string) { + if(using_code_frame) { // CodeFrame soul: // string writes were intercepted // returning them as the result of getting code-junction