Resolve fields on expressions/non-objects also.

git-svn-id: http://voip.null.ro/svn/yate@5586 acf43c95-373e-0410-b603-e72c3f656dc1
This commit is contained in:
oana 2013-07-17 14:47:33 +00:00
parent 53834559a2
commit 1c5160f54d
1 changed files with 14 additions and 2 deletions

View File

@ -49,10 +49,10 @@ public:
virtual bool runField(ObjList& stack, const ExpOperation& oper, GenObject* context);
virtual bool runAssign(ObjList& stack, const ExpOperation& oper, GenObject* context);
GenObject* resolve(ObjList& stack, String& name, GenObject* context);
private:
GenObject* resolveTop(ObjList& stack, const String& name, GenObject* context);
bool runStringFunction(GenObject* obj, const String& name, ObjList& stack, const ExpOperation& oper, GenObject* context);
bool runStringField(GenObject* obj, const String& name, ObjList& stack, const ExpOperation& oper, GenObject* context);
private:
GenObject* resolveTop(ObjList& stack, const String& name, GenObject* context);
};
class JsNull : public JsObject
@ -2060,12 +2060,24 @@ bool JsCode::runOperation(ObjList& stack, const ExpOperation& oper, GenObject* c
return gotError("Expecting field names",oper.lineNumber());
}
if (op1->opcode() != OpcField) {
// try to obtain an object on which to run the field
ScriptContext* ctx = YOBJECT(ScriptContext,op1);
if (ctx && ctx->runField(stack,*op2,context)) {
TelEngine::destruct(op1);
TelEngine::destruct(op2);
break;
}
else {
// op1 is not an object, it's a string
JsContext* jsCtx = 0;
if (sr)
jsCtx = static_cast<JsContext*>(sr->context());
if (jsCtx && jsCtx->runStringField(op1,op2->name(),stack,*op2,context)) {
TelEngine::destruct(op1);
TelEngine::destruct(op2);
break;
}
}
TelEngine::destruct(op1);
TelEngine::destruct(op2);
return gotError("Expecting field names",oper.lineNumber());