From f304229d7f71f9e38134355414809ded77323dac Mon Sep 17 00:00:00 2001 From: "beard%netscape.com" Date: Fri, 23 Jun 2000 23:49:48 +0000 Subject: [PATCH] added NEW_CLASS instruction, to instantiate classes. --- js/js2/interpreter.cpp | 15 ++++++++++++++- js2/src/interpreter.cpp | 15 ++++++++++++++- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/js/js2/interpreter.cpp b/js/js2/interpreter.cpp index c9a9582b6aae..a4b8cc687171 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 c9a9582b6aae..a4b8cc687171 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: