diff --git a/js/js2/interpreter.cpp b/js/js2/interpreter.cpp index c9a9582b6aa..a4b8cc68717 100644 --- a/js/js2/interpreter.cpp +++ b/js/js2/interpreter.cpp @@ -32,6 +32,7 @@ */ #include "interpreter.h" +#include "jsclasses.h" #include "world.h" #include @@ -623,7 +624,19 @@ JSValue Context::interpret(ICodeModule* iCode, const JSValues& args) case NEW_OBJECT: { NewObject* no = static_cast(instruction); - (*registers)[dst(no).first] = JSValue(new JSObject()); + (*registers)[dst(no).first] = new JSObject(); + } + break; + case NEW_CLASS: + { + NewClass* nc = static_cast(instruction); + JSValue value = mGlobal->getVariable(*src1(nc)); + if (value.isType()) { + using JSClasses::JSClass; + using JSClasses::JSInstance; + JSClass* thisClass = static_cast(value.type); + (*registers)[dst(nc).first] = new(thisClass) JSInstance(thisClass); + } } break; case NEW_FUNCTION: diff --git a/js2/src/interpreter.cpp b/js2/src/interpreter.cpp index c9a9582b6aa..a4b8cc68717 100644 --- a/js2/src/interpreter.cpp +++ b/js2/src/interpreter.cpp @@ -32,6 +32,7 @@ */ #include "interpreter.h" +#include "jsclasses.h" #include "world.h" #include @@ -623,7 +624,19 @@ JSValue Context::interpret(ICodeModule* iCode, const JSValues& args) case NEW_OBJECT: { NewObject* no = static_cast(instruction); - (*registers)[dst(no).first] = JSValue(new JSObject()); + (*registers)[dst(no).first] = new JSObject(); + } + break; + case NEW_CLASS: + { + NewClass* nc = static_cast(instruction); + JSValue value = mGlobal->getVariable(*src1(nc)); + if (value.isType()) { + using JSClasses::JSClass; + using JSClasses::JSInstance; + JSClass* thisClass = static_cast(value.type); + (*registers)[dst(nc).first] = new(thisClass) JSInstance(thisClass); + } } break; case NEW_FUNCTION: