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

Last change on this file since 18837 was 17372, checked in by darin, 19 years ago

Reviewed by Geoff.

  • made changes so the code compiles with the highest warning level under MSVC (disabling some warnings, making some code fixes)
  • API/JSCallbackConstructor.cpp: (KJS::JSCallbackConstructor::construct):
  • API/JSCallbackFunction.cpp: (KJS::JSCallbackFunction::callAsFunction):
  • API/JSCallbackObject.cpp: (KJS::JSCallbackObject::init): (KJS::JSCallbackObject::construct): (KJS::JSCallbackObject::callAsFunction):
  • API/JSObjectRef.cpp: (JSPropertyNameArrayGetNameAtIndex):
  • API/JSStringRef.cpp: (JSStringCreateWithCharacters):
  • JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj:
  • bindings/c/c_utility.cpp: (KJS::Bindings::convertUTF8ToUTF16): (KJS::Bindings::coerceValueToNPVariantStringType): (KJS::Bindings::convertValueToNPVariant):
  • kjs/DateMath.h: (KJS::GregorianDateTime::GregorianDateTime):
  • kjs/ExecState.h: (KJS::ExecState::hadException):
  • kjs/JSImmediate.h: (KJS::JSImmediate::fromDouble): (KJS::JSImmediate::toDouble): (KJS::JSImmediate::NanAsBits): (KJS::JSImmediate::oneAsBits):
  • kjs/Parser.h:
  • kjs/PropertyNameArray.h: (KJS::PropertyNameArray::size):
  • kjs/array_object.cpp: (ArrayObjectImp::callAsFunction):
  • kjs/bool_object.cpp: (BooleanObjectImp::callAsFunction):
  • kjs/collector.cpp: (KJS::Collector::allocate): (KJS::Collector::markCurrentThreadConservatively): (KJS::Collector::collect):
  • kjs/completion.h: (KJS::Completion::isValueCompletion):
  • kjs/date_object.cpp: (KJS::findMonth):
  • kjs/debugger.cpp: (Debugger::sourceParsed): (Debugger::sourceUnused): (Debugger::exception): (Debugger::atStatement): (Debugger::callEvent): (Debugger::returnEvent):
  • kjs/dtoa.cpp:
  • kjs/error_object.cpp: (ErrorObjectImp::callAsFunction): (NativeErrorImp::callAsFunction):
  • kjs/function.cpp: (KJS::FunctionImp::processVarDecls): (KJS::GlobalFuncImp::callAsFunction):
  • kjs/function_object.cpp: (FunctionPrototype::callAsFunction):
  • kjs/grammar.y:
  • kjs/identifier.cpp: (KJS::CStringTranslator::translate): (KJS::Identifier::add):
  • kjs/internal.h:
  • kjs/lexer.cpp: (Lexer::lex): (Lexer::isIdentStart): (Lexer::isIdentPart): (isDecimalDigit): (Lexer::isHexDigit): (Lexer::isOctalDigit): (Lexer::matchPunctuator): (Lexer::singleEscape): (Lexer::convertOctal): (Lexer::convertHex): (Lexer::convertUnicode): (Lexer::record8):
  • kjs/lexer.h:
  • kjs/math_object.cpp: (MathFuncImp::callAsFunction):
  • kjs/number_object.cpp: (integer_part_noexp): (intPow10): (NumberProtoFunc::callAsFunction): (NumberObjectImp::callAsFunction):
  • kjs/object.cpp: (KJS::JSObject::deleteProperty): (KJS::JSObject::callAsFunction): (KJS::JSObject::toBoolean): (KJS::JSObject::toObject):
  • kjs/object.h: (KJS::JSObject::getPropertySlot):
  • kjs/property_map.cpp: (KJS::isValid): (KJS::PropertyMap::put): (KJS::PropertyMap::insert): (KJS::PropertyMap::containsGettersOrSetters):
  • kjs/property_map.h: (KJS::PropertyMap::hasGetterSetterProperties):
  • kjs/property_slot.h:
  • kjs/string_object.cpp: (StringInstance::getPropertyNames): (StringObjectImp::callAsFunction): (StringObjectFuncImp::callAsFunction):
  • kjs/ustring.cpp: (KJS::UString::Rep::computeHash): (KJS::UString::UString): (KJS::UString::from): (KJS::UString::append): (KJS::UString::ascii): (KJS::UString::operator=): (KJS::UString::find): (KJS::UString::rfind):
  • kjs/ustring.h: (KJS::UChar::high): (KJS::UChar::low): (KJS::UCharReference::low): (KJS::UCharReference::high):
  • kjs/value.cpp: (KJS::JSValue::toUInt16):
  • kjs/value.h:
  • pcre/pcre_compile.c: (get_othercase_range):
  • pcre/pcre_exec.c: (match):
  • pcre/pcre_internal.h:
  • wtf/HashFunctions.h: (WTF::intHash): (WTF::PtrHash::hash):
  • wtf/MathExtras.h: (isnan): (lround): (lroundf):
  • wtf/StringExtras.h: (strncasecmp):
  • wtf/unicode/icu/UnicodeIcu.h: (WTF::Unicode::isPrintableChar):
  • Property svn:eol-style set to native
File size: 4.9 KB
Line 
1// -*- c-basic-offset: 2 -*-
2/*
3 * This file is part of the KDE libraries
4 * Copyright (C) 1999-2001 Harri Porten ([email protected])
5 * Copyright (C) 2001 Peter Kelly ([email protected])
6 * Copyright (C) 2003, 2004, 2005, 2006 Apple Computer, Inc.
7 *
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either
11 * version 2 of the License, or (at your option) any later version.
12 *
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Library General Public License for more details.
17 *
18 * You should have received a copy of the GNU Library General Public License
19 * along with this library; see the file COPYING.LIB. If not, write to
20 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
21 * Boston, MA 02110-1301, USA.
22 *
23 */
24
25#ifndef INTERNAL_H
26#define INTERNAL_H
27
28#include "JSType.h"
29#include "interpreter.h"
30#include "object.h"
31#include "protect.h"
32#include "scope_chain.h"
33#include "types.h"
34#include "ustring.h"
35
36#include <wtf/Noncopyable.h>
37
38#define I18N_NOOP(s) s
39
40namespace KJS {
41
42 class FunctionPrototype;
43
44 // ---------------------------------------------------------------------------
45 // Primitive impls
46 // ---------------------------------------------------------------------------
47
48 class StringImp : public JSCell {
49 public:
50 StringImp(const UString& v) : val(v) { }
51 UString value() const { return val; }
52
53 JSType type() const { return StringType; }
54
55 JSValue *toPrimitive(ExecState *exec, JSType preferred = UnspecifiedType) const;
56 bool toBoolean(ExecState *exec) const;
57 double toNumber(ExecState *exec) const;
58 UString toString(ExecState *exec) const;
59 JSObject *toObject(ExecState *exec) const;
60
61 private:
62 UString val;
63 };
64
65 class NumberImp : public JSCell {
66 friend class ConstantValues;
67 friend JSValue *jsNumberCell(double);
68 public:
69 double value() const { return val; }
70
71 JSType type() const { return NumberType; }
72
73 JSValue *toPrimitive(ExecState *exec, JSType preferred = UnspecifiedType) const;
74 bool toBoolean(ExecState *exec) const;
75 double toNumber(ExecState *exec) const;
76 UString toString(ExecState *exec) const;
77 JSObject *toObject(ExecState *exec) const;
78
79 private:
80 NumberImp(double v) : val(v) { }
81
82 virtual bool getUInt32(uint32_t&) const;
83
84 double val;
85 };
86
87
88 /**
89 * @short The "label set" in Ecma-262 spec
90 */
91 class LabelStack : Noncopyable {
92 public:
93 LabelStack()
94 : tos(0)
95 {
96 }
97 ~LabelStack();
98
99 /**
100 * If id is not empty and is not in the stack already, puts it on top of
101 * the stack and returns true, otherwise returns false
102 */
103 bool push(const Identifier &id);
104 /**
105 * Is the id in the stack?
106 */
107 bool contains(const Identifier &id) const;
108 /**
109 * Removes from the stack the last pushed id (what else?)
110 */
111 void pop();
112
113 private:
114 struct StackElem {
115 Identifier id;
116 StackElem *prev;
117 };
118
119 StackElem *tos;
120 };
121
122
123 // ---------------------------------------------------------------------------
124 // Evaluation
125 // ---------------------------------------------------------------------------
126
127 enum CodeType { GlobalCode,
128 EvalCode,
129 FunctionCode,
130 AnonymousCode };
131
132 struct AttachedInterpreter;
133 class DebuggerImp {
134 public:
135
136 DebuggerImp() {
137 interps = 0;
138 isAborted = false;
139 }
140
141 void abort() { isAborted = true; }
142 bool aborted() const { return isAborted; }
143
144 AttachedInterpreter *interps;
145 bool isAborted;
146 };
147
148 class InternalFunctionImp : public JSObject {
149 public:
150 InternalFunctionImp();
151 InternalFunctionImp(FunctionPrototype*);
152 InternalFunctionImp(FunctionPrototype*, const Identifier&);
153
154 virtual bool implementsCall() const;
155 virtual JSValue* callAsFunction(ExecState*, JSObject* thisObjec, const List& args) = 0;
156 virtual bool implementsHasInstance() const;
157
158 virtual const ClassInfo* classInfo() const { return &info; }
159 static const ClassInfo info;
160 const Identifier& functionName() const { return m_name; }
161
162 private:
163 Identifier m_name;
164 };
165
166 // helper function for toInteger, toInt32, toUInt32 and toUInt16
167 double roundValue(ExecState *, JSValue *);
168
169#ifndef NDEBUG
170 void printInfo(ExecState *exec, const char *s, JSValue *, int lineno = -1);
171#endif
172
173inline LabelStack::~LabelStack()
174{
175 StackElem *prev;
176 for (StackElem *e = tos; e; e = prev) {
177 prev = e->prev;
178 delete e;
179 }
180}
181
182inline void LabelStack::pop()
183{
184 if (StackElem *e = tos) {
185 tos = e->prev;
186 delete e;
187 }
188}
189
190} // namespace
191
192#endif // INTERNAL_H
Note: See TracBrowser for help on using the repository browser.