Commit 6f821c8d authored by mjs's avatar mjs

Merged changes from LABYRINTH_KDE_3_MERGE branch.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@798 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent f54a76f3
...@@ -4,6 +4,8 @@ noinst_LIBRARIES = libkjs.o ...@@ -4,6 +4,8 @@ noinst_LIBRARIES = libkjs.o
libkjs_o_LDFLAGS = -Wl,-r -nostdlib libkjs_o_LDFLAGS = -Wl,-r -nostdlib
libkjs_o_AR = $(OBJCXXLD) $(AM_OBJCXXFLAGS) $(OBJCXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) $(libkjs_o_LDFLAGS) -o libkjs_o_AR = $(OBJCXXLD) $(AM_OBJCXXFLAGS) $(OBJCXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) $(libkjs_o_LDFLAGS) -o
INCLUDES = $(KWQ_INCLUDES)
libkjs_o_SOURCES = \ libkjs_o_SOURCES = \
array_object.cpp \ array_object.cpp \
array_object.h \ array_object.h \
...@@ -21,13 +23,12 @@ libkjs_o_SOURCES = \ ...@@ -21,13 +23,12 @@ libkjs_o_SOURCES = \
function.h \ function.h \
function_object.cpp \ function_object.cpp \
function_object.h \ function_object.h \
global_object.cpp \
grammar.cpp \ grammar.cpp \
grammar.h \ grammar.h \
internal.cpp \ internal.cpp \
internal.h \ internal.h \
kjs.cpp \ interpreter.cpp \
kjs.h \ interpreter.h \
lexer.cpp \ lexer.cpp \
lexer.h \ lexer.h \
lexer.lut.h \ lexer.lut.h \
...@@ -46,6 +47,8 @@ libkjs_o_SOURCES = \ ...@@ -46,6 +47,8 @@ libkjs_o_SOURCES = \
object_object.h \ object_object.h \
operations.cpp \ operations.cpp \
operations.h \ operations.h \
property_map.cpp \
property_map.h \
regexp.cpp \ regexp.cpp \
regexp.h \ regexp.h \
regexp_object.cpp \ regexp_object.cpp \
...@@ -56,6 +59,8 @@ libkjs_o_SOURCES = \ ...@@ -56,6 +59,8 @@ libkjs_o_SOURCES = \
types.h \ types.h \
ustring.cpp \ ustring.cpp \
ustring.h \ ustring.h \
value.cpp \
value.h \
$(NULL) $(NULL)
noinst_PROGRAMS = testkjs noinst_PROGRAMS = testkjs
...@@ -75,7 +80,29 @@ grammar-stamp: grammar.y ...@@ -75,7 +80,29 @@ grammar-stamp: grammar.y
ln -sf grammar.cpp.h grammar.h ln -sf grammar.cpp.h grammar.h
touch ./grammar-stamp touch ./grammar-stamp
BUILT_SOURCES = $(GRAMMAR_FILES) grammar-stamp LUT_FILES = math_object.lut.h lexer.lut.h array_object.lut.h date_object.lut.h string_object.lut.h number_object.lut.h
lexer.lut.h: keywords.table
./create_hash_table keywords.table -i > lexer.lut.h;
array_object.lut.h: array_object.cpp
./create_hash_table array_object.cpp -i > array_object.lut.h
math_object.lut.h: math_object.cpp
./create_hash_table math_object.cpp -i > math_object.lut.h
date_object.lut.h: date_object.cpp
./create_hash_table date_object.cpp -i > date_object.lut.h
number_object.lut.h: number_object.cpp
./create_hash_table number_object.cpp -i > number_object.lut.h
string_object.lut.h: string_object.cpp
./create_hash_table string_object.cpp -i > string_object.lut.h
BUILT_SOURCES = $(GRAMMAR_FILES) $(LUT_FILES) grammar-stamp
CLEANFILES = $(BUILT_SOURCES) CLEANFILES = $(BUILT_SOURCES)
This diff is collapsed.
// -*- c-basic-offset: 2 -*-
/* /*
* This file is part of the KDE libraries * This file is part of the KDE libraries
* Copyright (C) 1999-2000 Harri Porten (porten@kde.org) * Copyright (C) 1999-2000 Harri Porten (porten@kde.org)
...@@ -15,39 +16,64 @@ ...@@ -15,39 +16,64 @@
* You should have received a copy of the GNU Lesser General Public * You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software * License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* $Id$
*/ */
#ifndef _ARRAY_OBJECT_H_ #ifndef _ARRAY_OBJECT_H_
#define _ARRAY_OBJECT_H_ #define _ARRAY_OBJECT_H_
#include "object.h" #include "internal.h"
#include "function.h" #include "function_object.h"
namespace KJS { namespace KJS {
class ArrayObject : public ConstructorImp { class ArrayInstanceImp : public ObjectImp {
public: public:
ArrayObject(const Object &funcProto, const Object &arrayProto); ArrayInstanceImp(const Object &proto);
Completion execute(const List &);
Object construct(const List &); virtual void put(ExecState *exec, const UString &propertyName, const Value &value, int attr = None);
virtual void putDirect(ExecState *exec, const UString &propertyName, const Value &value, int attr = None);
virtual const ClassInfo *classInfo() const { return &info; }
static const ClassInfo info;
}; };
class ArrayPrototype : public ObjectImp { class ArrayPrototypeImp : public ArrayInstanceImp {
public: public:
ArrayPrototype(const Object& proto); ArrayPrototypeImp(ExecState *exec,
virtual KJSO get(const UString &p) const; ObjectPrototypeImp *objProto);
Value get(ExecState *exec, const UString &p) const;
virtual const ClassInfo *classInfo() const { return &info; }
static const ClassInfo info;
}; };
class ArrayProtoFunc : public InternalFunctionImp { class ArrayProtoFuncImp : public InternalFunctionImp {
public: public:
ArrayProtoFunc(int i) : id(i) { } ArrayProtoFuncImp(ExecState *exec, int i, int len);
Completion execute(const List &);
virtual bool implementsCall() const;
virtual Value call(ExecState *exec, Object &thisObj, const List &args);
enum { ToString, ToLocaleString, Concat, Join, Pop, Push, enum { ToString, ToLocaleString, Concat, Join, Pop, Push,
Reverse, Shift, Slice, Sort, Splice, UnShift }; Reverse, Shift, Slice, Sort, Splice, UnShift };
private: private:
int id; int id;
}; };
class ArrayObjectImp : public InternalFunctionImp {
public:
ArrayObjectImp(ExecState *exec,
FunctionPrototypeImp *funcProto,
ArrayPrototypeImp *arrayProto);
virtual bool implementsConstruct() const;
virtual Object construct(ExecState *exec, const List &args);
virtual bool implementsCall() const;
virtual Value call(ExecState *exec, Object &thisObj, const List &args);
};
}; // namespace }; // namespace
#endif #endif
// -*- c-basic-offset: 2 -*-
/* /*
* This file is part of the KDE libraries * This file is part of the KDE libraries
* Copyright (C) 1999-2000 Harri Porten (porten@kde.org) * Copyright (C) 1999-2000 Harri Porten (porten@kde.org)
...@@ -15,89 +16,134 @@ ...@@ -15,89 +16,134 @@
* You should have received a copy of the GNU Lesser General Public * You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software * License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/ */
#include "kjs.h" #include "value.h"
#include "operations.h" #include "object.h"
#include "types.h" #include "types.h"
#include "interpreter.h"
#include "operations.h"
#include "bool_object.h" #include "bool_object.h"
#include "error_object.h" #include "error_object.h"
#include <assert.h>
using namespace KJS; using namespace KJS;
BooleanObject::BooleanObject(const KJSO& funcProto, const KJSO &booleanProto) // ------------------------------ BooleanInstanceImp ---------------------------
: ConstructorImp(funcProto, 1)
const ClassInfo BooleanInstanceImp::info = {"Boolean", 0, 0, 0};
BooleanInstanceImp::BooleanInstanceImp(const Object &proto)
: ObjectImp(proto)
{ {
// Boolean.prototype
setPrototypeProperty(booleanProto);
} }
// ECMA 15.6.1 // ------------------------------ BooleanPrototypeImp --------------------------
Completion BooleanObject::execute(const List &args)
{
Boolean b;
if (args.isEmpty()) // ECMA 15.6.4
b = Boolean(false);
else BooleanPrototypeImp::BooleanPrototypeImp(ExecState *exec,
b = args[0].toBoolean(); ObjectPrototypeImp *objectProto,
FunctionPrototypeImp *funcProto)
: BooleanInstanceImp(Object(objectProto))
{
Value protect(this);
// The constructor will be added later by InterpreterImp::InterpreterImp()
return Completion(ReturnValue, b); put(exec,"toString", Object(new BooleanProtoFuncImp(exec,funcProto,BooleanProtoFuncImp::ToString,0)), DontEnum);
put(exec,"valueOf", Object(new BooleanProtoFuncImp(exec,funcProto,BooleanProtoFuncImp::ValueOf,0)), DontEnum);
setInternalValue(Boolean(false));
} }
// ECMA 15.6.2
Object BooleanObject::construct(const List &args)
{
Boolean b;
if (args.size() > 0)
b = args.begin()->toBoolean();
else