зеркало из https://github.com/mozilla/pjs.git
added NEW_CLASS instruction, to instantiate classes.
This commit is contained in:
Родитель
24a81ca7ca
Коммит
69d8a01263
|
@ -32,6 +32,7 @@
|
|||
*/
|
||||
|
||||
#include "interpreter.h"
|
||||
#include "jsclasses.h"
|
||||
#include "world.h"
|
||||
|
||||
#include <assert.h>
|
||||
|
@ -623,7 +624,19 @@ JSValue Context::interpret(ICodeModule* iCode, const JSValues& args)
|
|||
case NEW_OBJECT:
|
||||
{
|
||||
NewObject* no = static_cast<NewObject*>(instruction);
|
||||
(*registers)[dst(no).first] = JSValue(new JSObject());
|
||||
(*registers)[dst(no).first] = new JSObject();
|
||||
}
|
||||
break;
|
||||
case NEW_CLASS:
|
||||
{
|
||||
NewClass* nc = static_cast<NewClass*>(instruction);
|
||||
JSValue value = mGlobal->getVariable(*src1(nc));
|
||||
if (value.isType()) {
|
||||
using JSClasses::JSClass;
|
||||
using JSClasses::JSInstance;
|
||||
JSClass* thisClass = static_cast<JSClass*>(value.type);
|
||||
(*registers)[dst(nc).first] = new(thisClass) JSInstance(thisClass);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case NEW_FUNCTION:
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
*/
|
||||
|
||||
#include "interpreter.h"
|
||||
#include "jsclasses.h"
|
||||
#include "world.h"
|
||||
|
||||
#include <assert.h>
|
||||
|
@ -623,7 +624,19 @@ JSValue Context::interpret(ICodeModule* iCode, const JSValues& args)
|
|||
case NEW_OBJECT:
|
||||
{
|
||||
NewObject* no = static_cast<NewObject*>(instruction);
|
||||
(*registers)[dst(no).first] = JSValue(new JSObject());
|
||||
(*registers)[dst(no).first] = new JSObject();
|
||||
}
|
||||
break;
|
||||
case NEW_CLASS:
|
||||
{
|
||||
NewClass* nc = static_cast<NewClass*>(instruction);
|
||||
JSValue value = mGlobal->getVariable(*src1(nc));
|
||||
if (value.isType()) {
|
||||
using JSClasses::JSClass;
|
||||
using JSClasses::JSInstance;
|
||||
JSClass* thisClass = static_cast<JSClass*>(value.type);
|
||||
(*registers)[dst(nc).first] = new(thisClass) JSInstance(thisClass);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case NEW_FUNCTION:
|
||||
|
|
Загрузка…
Ссылка в новой задаче