1 /* -*- Mode: C++; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 4 -*- */
2 /* vi: set ts=4 sw=4 expandtab: (add to ~/.vimrc: set modeline modelines=5) */
3 /* ***** BEGIN LICENSE BLOCK *****
4 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
6 * The contents of this file are subject to the Mozilla Public License Version
7 * 1.1 (the "License"); you may not use this file except in compliance with
8 * the License. You may obtain a copy of the License at
9 * http://www.mozilla.org/MPL/
11 * Software distributed under the License is distributed on an "AS IS" basis,
12 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13 * for the specific language governing rights and limitations under the
16 * The Original Code is [Open Source Virtual Machine.].
18 * The Initial Developer of the Original Code is
19 * Adobe System Incorporated.
20 * Portions created by the Initial Developer are Copyright (C) 2004-2006
21 * the Initial Developer. All Rights Reserved.
26 * Alternatively, the contents of this file may be used under the terms of
27 * either the GNU General Public License Version 2 or later (the "GPL"), or
28 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
29 * in which case the provisions of the GPL or the LGPL are applicable instead
30 * of those above. If you wish to allow use of your version of this file only
31 * under the terms of either the GPL or the LGPL, and not to allow others to
32 * use your version of this file under the terms of the MPL, indicate your
33 * decision by deleting the provisions above and replace them with the notice
34 * and other provisions required by the GPL or the LGPL. If you do not delete
35 * the provisions above, a recipient may use your version of this file under
36 * the terms of any one of the MPL, the GPL or the LGPL.
38 * ***** END LICENSE BLOCK ***** */
43 REALLY_INLINE Toplevel
* Toplevel::create(MMgc::GC
* gc
, AbcEnv
* abcEnv
)
45 return new (gc
, MMgc::kExact
) Toplevel(abcEnv
);
48 REALLY_INLINE GCRef
<builtinClassManifest
> Toplevel::builtinClasses() const
50 AvmAssert(_builtinClasses
!= NULL
);
51 return GCRef
<builtinClassManifest
>(_builtinClasses
);
54 REALLY_INLINE GCRef
<ArgumentErrorClass
> Toplevel::argumentErrorClass() const { return builtinClasses()->get_ArgumentErrorClass(); }
55 REALLY_INLINE GCRef
<ArrayClass
> Toplevel::arrayClass() const { return builtinClasses()->get_ArrayClass(); }
56 REALLY_INLINE GCRef
<BooleanClass
> Toplevel::booleanClass() const { return builtinClasses()->get_BooleanClass(); }
57 REALLY_INLINE GCRef
<ByteArrayClass
> Toplevel::byteArrayClass() const { return builtinClasses()->get_ByteArrayClass(); }
58 REALLY_INLINE GCRef
<ClassClass
> Toplevel::classClass() const { return builtinClasses()->get_ClassClass(); }
59 REALLY_INLINE GCRef
<EOFErrorClass
> Toplevel::eofErrorClass() const { return builtinClasses()->get_EOFErrorClass(); }
60 REALLY_INLINE GCRef
<IOErrorClass
> Toplevel::ioErrorClass() const { return builtinClasses()->get_IOErrorClass(); }
61 REALLY_INLINE GCRef
<MemoryErrorClass
> Toplevel::memoryErrorClass() const { return builtinClasses()->get_MemoryErrorClass(); }
62 REALLY_INLINE GCRef
<DateClass
> Toplevel::dateClass() const { return builtinClasses()->get_DateClass(); }
63 REALLY_INLINE GCRef
<DoubleVectorClass
> Toplevel::doubleVectorClass() const { return builtinClasses()->get_Vector_doubleClass(); }
64 REALLY_INLINE GCRef
<ErrorClass
> Toplevel::errorClass() const { return builtinClasses()->get_ErrorClass(); }
65 REALLY_INLINE GCRef
<EvalErrorClass
> Toplevel::evalErrorClass() const { return builtinClasses()->get_EvalErrorClass(); }
66 REALLY_INLINE GCRef
<FunctionClass
> Toplevel::functionClass() const { return builtinClasses()->get_FunctionClass(); }
67 REALLY_INLINE GCRef
<IntClass
> Toplevel::intClass() const { return builtinClasses()->get_intClass(); }
68 REALLY_INLINE GCRef
<IntVectorClass
> Toplevel::intVectorClass() const { return builtinClasses()->get_Vector_intClass(); }
69 REALLY_INLINE GCRef
<MethodClosureClass
> Toplevel::methodClosureClass() const { return builtinClasses()->get_MethodClosureClass(); }
70 REALLY_INLINE GCRef
<NamespaceClass
> Toplevel::namespaceClass() const { return builtinClasses()->get_NamespaceClass(); }
71 REALLY_INLINE GCRef
<NumberClass
> Toplevel::numberClass() const { return builtinClasses()->get_NumberClass(); }
72 REALLY_INLINE GCRef
<ObjectVectorClass
> Toplevel::objectVectorClass() const { return builtinClasses()->get_Vector_objectClass(); }
73 REALLY_INLINE GCRef
<QNameClass
> Toplevel::qnameClass() const { return builtinClasses()->get_QNameClass(); }
74 REALLY_INLINE GCRef
<RangeErrorClass
> Toplevel::rangeErrorClass() const { return builtinClasses()->get_RangeErrorClass(); }
75 REALLY_INLINE GCRef
<ReferenceErrorClass
> Toplevel::referenceErrorClass() const { return builtinClasses()->get_ReferenceErrorClass(); }
76 REALLY_INLINE GCRef
<RegExpClass
> Toplevel::regexpClass() const { return builtinClasses()->get_RegExpClass(); }
77 REALLY_INLINE GCRef
<SecurityErrorClass
> Toplevel::securityErrorClass() const { return builtinClasses()->get_SecurityErrorClass(); }
78 REALLY_INLINE GCRef
<StringClass
> Toplevel::stringClass() const { return builtinClasses()->get_StringClass(); }
79 REALLY_INLINE GCRef
<SyntaxErrorClass
> Toplevel::syntaxErrorClass() const { return builtinClasses()->get_SyntaxErrorClass(); }
80 REALLY_INLINE GCRef
<TypeErrorClass
> Toplevel::typeErrorClass() const { return builtinClasses()->get_TypeErrorClass(); }
81 REALLY_INLINE GCRef
<UIntClass
> Toplevel::uintClass() const { return builtinClasses()->get_uintClass(); }
82 REALLY_INLINE GCRef
<UIntVectorClass
> Toplevel::uintVectorClass() const { return builtinClasses()->get_Vector_uintClass(); }
83 REALLY_INLINE GCRef
<URIErrorClass
> Toplevel::uriErrorClass() const { return builtinClasses()->get_URIErrorClass(); }
84 REALLY_INLINE GCRef
<VectorClass
> Toplevel::vectorClass() const { return builtinClasses()->get_VectorClass(); }
85 REALLY_INLINE GCRef
<VerifyErrorClass
> Toplevel::verifyErrorClass() const { return builtinClasses()->get_VerifyErrorClass(); }
86 REALLY_INLINE GCRef
<XMLClass
> Toplevel::xmlClass() const { return builtinClasses()->get_XMLClass(); }
87 REALLY_INLINE GCRef
<XMLListClass
> Toplevel::xmlListClass() const { return builtinClasses()->get_XMLListClass(); }
89 REALLY_INLINE Atom
Toplevel::callproperty(Atom base
, const Multiname
* name
, int argc
, Atom
* atomv
, VTable
* vtable
)
92 Binding b
= avmplus::getBinding(this, vtable
, name
);
93 return avmplus::callprop_b(this, base
, name
, argc
, atomv
, vtable
, b
);
96 REALLY_INLINE VTable
* Toplevel::toVTable(Atom atom
)
98 return avmplus::toVTable(this, atom
);
101 REALLY_INLINE Atom
Toplevel::op_call(Atom method
, int argc
, Atom
* atomv
)
103 return avmplus::op_call(this, method
, argc
, atomv
);
106 REALLY_INLINE Atom
Toplevel::op_construct(Atom ctor
, int argc
, Atom
* atomv
)
108 return avmplus::op_construct(this, ctor
, argc
, atomv
);
111 REALLY_INLINE Binding
Toplevel::getBinding(Traits
* traits
, const Multiname
* ref
) const
113 return avmplus::getBinding(this, traits
, ref
);
116 REALLY_INLINE Atom
Toplevel::constructprop(const Multiname
*name
, int argc
, Atom
* atomv
, VTable
* vtable
)
118 return avmplus::constructprop(this, name
, argc
, atomv
, vtable
);
121 REALLY_INLINE Atom
Toplevel::op_applytype(Atom obj
, int argc
, Atom
* atomv
)
123 return avmplus::op_applytype(this, obj
, argc
, atomv
);
126 REALLY_INLINE QNameObject
* Toplevel::ToAttributeName(const Stringp arg
)
128 return ToAttributeName(arg
->atom());
131 REALLY_INLINE Atom
Toplevel::coerce(Atom atom
, Traits
* expected
) const
133 return avmplus::coerce(this, atom
, expected
);
137 REALLY_INLINE
bool Toplevel::contains(const uint32_t *uriSet
, uint32_t ch
)
139 return (ch
<0x80) && (uriSet
[ch
>>5]&(1<<(ch
&0x1f))) != 0;
142 REALLY_INLINE
void Toplevel::throwReferenceError(int id
, const Multiname
& multiname
, const Traits
* traits
) const
144 throwReferenceError(id
, &multiname
, traits
);
147 REALLY_INLINE
void Toplevel::throwReferenceError(int id
, const Multiname
& multiname
) const
149 throwReferenceError(id
, &multiname
);
153 REALLY_INLINE
void Toplevel::throwVerifyError(int id
, Stringp
) const
155 throwVerifyError(id
);
158 REALLY_INLINE
void Toplevel::throwVerifyError(int id
, Stringp
, Stringp
) const
160 throwVerifyError(id
);
164 REALLY_INLINE AbcEnv
* Toplevel::abcEnv() const
169 REALLY_INLINE DomainEnv
* Toplevel::domainEnv() const
171 return _abcEnv
->domainEnv();
174 REALLY_INLINE AvmCore
* Toplevel::core() const
176 return _abcEnv
->pool()->core
;
179 REALLY_INLINE
MMgc::GC
* Toplevel::gc() const
181 return core()->GetGC();
184 REALLY_INLINE ScriptObject
* Toplevel::global() const
186 AvmAssert(_mainEntryPoint
!= NULL
);
187 AvmAssert(_mainEntryPoint
->global
!= NULL
);
188 return _mainEntryPoint
->global
;
191 REALLY_INLINE Atom
Toplevel::atom() const
193 AvmAssert(_mainEntryPoint
!= NULL
);
194 AvmAssert(_mainEntryPoint
->global
!= NULL
);
195 return _mainEntryPoint
->global
->atom();
198 REALLY_INLINE Atom
Toplevel::add2(Atom val1
, Atom val2
)
200 return avmplus::op_add(this->core(), val1
, val2
);
203 REALLY_INLINE
void Toplevel::init_mainEntryPoint(ScriptEnv
* main
, builtinClassManifest
* builtins
)
205 AvmAssert(_mainEntryPoint
== NULL
);
206 _mainEntryPoint
= main
;
207 _builtinClasses
= builtins
;
210 REALLY_INLINE ScopeChain
* Toplevel::toplevel_scope()
212 AvmAssert(_mainEntryPoint
!= NULL
);
213 return _mainEntryPoint
->scope();
216 } // namespace avmplus