source: webkit/trunk/JavaScriptCore/kjs/internal.h@ 28777

Last change on this file since 28777 was 28468, checked in by [email protected], 17 years ago

JavaScriptCore:

Reviewed by Darin Adler.

Third step in refactoring JSGlobalObject: Moved data members and
functions accessing data members from Interpreter to JSGlobalObject.
Changed Interpreter member functions to static functions.


This resolves a bug in global object bootstrapping, where the global
ExecState could be used when uninitialized.


This is a big change, but it's mostly code motion and renaming.


Layout and JS tests, and testjsglue and testapi, pass. SunSpider reports
a .7% regression, but Shark sees no difference related to this patch,
and SunSpider reported a .7% speedup from an earlier step in this
refactoring, so I think it's fair to call that a wash.

JavaScriptGlue:

Reviewed by Darin Adler.

Third step in refactoring JSGlobalObject: Moved data members and data
member access from Interpreter to JSGlobalObject. Replaced JSInterpreter
subclass with JSGlobalObject subclass.


  • JSRun.cpp: (JSRun::JSRun): (JSRun::Evaluate): (JSRun::CheckSyntax):
  • JSRun.h: (JSGlueGlobalObject::JSGlueGlobalObject):
  • JSUtils.cpp: (KJSValueToCFTypeInternal):
  • JSValueWrapper.cpp: (getThreadGlobalExecState):

WebCore:

Reviewed by Darin Adler.

Third step in refactoring JSGlobalObject: Moved data members and data
member access from Interpreter to JSGlobalObject. Changed Interpreter
member functions to static functions. Same for the subclass,
ScriptInterpreter.


This is a big change, but it's mostly code motion and renaming.

WebKit/mac:

Reviewed by Darin Adler.

Third step in refactoring JSGlobalObject: Moved data members and data
member access from Interpreter to JSGlobalObject.


  • WebView/WebFrame.mm: (-[WebFrame _attachScriptDebugger]):

WebKit/win:

Reviewed by Darin Adler.

Third step in refactoring JSGlobalObject: Moved data members and data
member access from Interpreter to JSGlobalObject.


  • WebFrame.cpp: (WebFrame::globalContext): (WebFrame::attachScriptDebugger): (WebFrame::windowObjectCleared):
  • WebScriptDebugger.cpp: (WebScriptDebugger::WebScriptDebugger):
  • Property svn:eol-style set to native
File size: 3.7 KB
Line 
1// -*- c-basic-offset: 2 -*-
2/*
3 * Copyright (C) 1999-2001 Harri Porten ([email protected])
4 * Copyright (C) 2001 Peter Kelly ([email protected])
5 * Copyright (C) 2003, 2004, 2005, 2006, 2007 Apple Inc. All rights reserved.
6 *
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version.
11 *
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Library General Public License for more details.
16 *
17 * You should have received a copy of the GNU Library General Public License
18 * along with this library; see the file COPYING.LIB. If not, write to
19 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20 * Boston, MA 02110-1301, USA.
21 *
22 */
23
24#ifndef INTERNAL_H
25#define INTERNAL_H
26
27#include "JSType.h"
28#include "object.h"
29#include "protect.h"
30#include "scope_chain.h"
31#include "types.h"
32#include "ustring.h"
33
34#include <wtf/Noncopyable.h>
35
36#define I18N_NOOP(s) s
37
38namespace KJS {
39
40 class FunctionPrototype;
41
42 // ---------------------------------------------------------------------------
43 // Primitive impls
44 // ---------------------------------------------------------------------------
45
46 class StringImp : public JSCell {
47 public:
48 StringImp(const UString& v) : val(v) { Collector::reportExtraMemoryCost(v.cost()); }
49 enum HasOtherOwnerType { HasOtherOwner };
50 StringImp(const UString& value, HasOtherOwnerType) : val(value) { }
51 const UString& value() const { return val; }
52
53 private:
54 virtual JSType type() const { return StringType; }
55
56 virtual JSValue* toPrimitive(ExecState*, JSType preferred = UnspecifiedType) const;
57 virtual bool getPrimitiveNumber(ExecState*, double& number, JSValue*& value);
58 virtual bool toBoolean(ExecState *exec) const;
59 virtual double toNumber(ExecState *exec) const;
60 virtual JSObject *toObject(ExecState *exec) const;
61 virtual UString toString(ExecState*) const;
62
63 UString val;
64 };
65
66 class NumberImp : public JSCell {
67 friend class ConstantValues;
68 friend JSValue *jsNumberCell(double);
69 public:
70 double value() const { return val; }
71
72 virtual JSType type() const { return NumberType; }
73
74 virtual JSValue* toPrimitive(ExecState*, JSType preferred = UnspecifiedType) const;
75 virtual bool getPrimitiveNumber(ExecState*, double& number, JSValue*& value);
76 virtual bool toBoolean(ExecState *exec) const;
77 virtual double toNumber(ExecState *exec) const;
78 virtual UString toString(ExecState *exec) const;
79 virtual JSObject *toObject(ExecState *exec) const;
80
81 void* operator new(size_t size)
82 {
83 return Collector::allocateNumber(size);
84 }
85 private:
86 NumberImp(double v) : val(v) { }
87
88 virtual bool getUInt32(uint32_t&) const;
89 virtual bool getTruncatedInt32(int32_t&) const;
90 virtual bool getTruncatedUInt32(uint32_t&) const;
91
92 double val;
93 };
94
95
96 // ---------------------------------------------------------------------------
97 // Evaluation
98 // ---------------------------------------------------------------------------
99
100 struct AttachedGlobalObject;
101 class DebuggerImp {
102 public:
103
104 DebuggerImp() {
105 globalObjects = 0;
106 isAborted = false;
107 }
108
109 void abort() { isAborted = true; }
110 bool aborted() const { return isAborted; }
111
112 AttachedGlobalObject* globalObjects;
113 bool isAborted;
114 };
115
116#ifndef NDEBUG
117 void printInfo(ExecState *exec, const char *s, JSValue *, int lineno = -1);
118#endif
119
120} // namespace
121
122#endif // INTERNAL_H
Note: See TracBrowser for help on using the repository browser.