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 ***** */
41 #ifndef __avmplus_VectorClass_inlines__
42 #define __avmplus_VectorClass_inlines__
46 // For some hand-written tracers that are used by generated tracers.
48 #define avmplus_TypedVectorClassXDoubleVectorObjectX_isExactInterlock 1
49 #define avmplus_TypedVectorClassXIntVectorObjectX_isExactInterlock 1
50 #define avmplus_TypedVectorClassXUIntVectorObjectX_isExactInterlock 1
51 #define avmplus_TypedVectorClassXObjectVectorObjectX_isExactInterlock 1
52 #define avmplus_TypedVectorObjectXDataListXdoubleXX_isExactInterlock 1
53 #define avmplus_TypedVectorObjectXDataListXint32_tXX_isExactInterlock 1
54 #define avmplus_TypedVectorObjectXDataListXuint32_tXX_isExactInterlock 1
55 #define avmplus_TypedVectorObjectXAtomListX_isExactInterlock 1
57 // ----------------------------
59 REALLY_INLINE
TypedVectorClassBase::TypedVectorClassBase(VTable
* vtable
)
60 : ClassClosure(vtable
)
64 REALLY_INLINE Traits
* TypedVectorClassBase::getTypeTraits() const
69 // ----------------------------
72 REALLY_INLINE OpaqueAtom TypedVectorConstants
<OpaqueAtom
>::nullValue()
74 return (OpaqueAtom
)nullObjectAtom
;
77 REALLY_INLINE OpaqueAtom TypedVectorConstants
<OpaqueAtom
>::undefinedValue()
79 return (OpaqueAtom
)undefinedAtom
;
83 REALLY_INLINE T TypedVectorConstants
<T
>::nullValue()
88 REALLY_INLINE T TypedVectorConstants
<T
>::undefinedValue()
93 // ----------------------------
95 REALLY_INLINE
bool VectorBaseObject::get_fixed() const
100 REALLY_INLINE
void VectorBaseObject::set_fixed(bool f
)
105 REALLY_INLINE
void VectorBaseObject::checkFixed() const
111 REALLY_INLINE Traits
* VectorBaseObject::getTypeTraits() const
113 return m_vecClass
->getTypeTraits();
116 REALLY_INLINE
void VectorBaseObject::atomToValue(Atom atom
, int32_t& value
)
118 value
= AvmCore::integer(atom
);
121 REALLY_INLINE Atom
VectorBaseObject::valueToAtom(const int32_t& value
) const
123 return core()->intToAtom(value
);
126 REALLY_INLINE
void VectorBaseObject::atomToValue(Atom atom
, uint32_t& value
)
128 value
= AvmCore::toUInt32(atom
);
131 REALLY_INLINE Atom
VectorBaseObject::valueToAtom(const uint32_t& value
) const
133 return core()->uintToAtom(value
);
136 REALLY_INLINE
void VectorBaseObject::atomToValue(Atom atom
, double& value
)
138 value
= AvmCore::number(atom
);
141 REALLY_INLINE Atom
VectorBaseObject::valueToAtom(const double& value
) const
143 return core()->doubleToAtom(value
);
146 REALLY_INLINE
void VectorBaseObject::atomToValue(Atom atom
, OpaqueAtom
& value
)
148 AvmAssert(m_vecClass
!= NULL
);
149 atom
= avmplus::coerce(toplevel(), atom
, m_vecClass
->getTypeTraits());
150 value
= (OpaqueAtom
)atom
;
153 REALLY_INLINE Atom
VectorBaseObject::valueToAtom(const OpaqueAtom
& value
) const
158 // ----------------------------
160 template<class TLIST
>
161 REALLY_INLINE typename
TLIST::TYPE TypedVectorObject
<TLIST
>::getUintPropertyFast(uint32_t index
) const
163 return m_list
.get(index
);
166 template<class TLIST
>
167 REALLY_INLINE
void TypedVectorObject
<TLIST
>::setUintPropertyFast(uint32_t index
, typename
TLIST::TYPE value
)
169 m_list
.set(index
, value
);
172 template<class TLIST
>
173 REALLY_INLINE
uint32_t TypedVectorObject
<TLIST
>::get_length() const
175 return m_list
.length();
178 template<class TLIST
>
179 REALLY_INLINE
void TypedVectorObject
<TLIST
>::_reverse()
184 template<class TLIST
>
185 REALLY_INLINE
bool TypedVectorObject
<TLIST
>::hasUintProperty(uint32_t index
) const
187 return _hasUintProperty(index
);
190 template<class TLIST
>
191 REALLY_INLINE Atom TypedVectorObject
<TLIST
>::getUintProperty(uint32_t index
) const
193 return _getUintProperty(index
);
196 template<class TLIST
>
197 REALLY_INLINE
void TypedVectorObject
<TLIST
>::setUintProperty(uint32_t index
, Atom value
)
199 _setUintProperty(index
, value
);
203 template<class TLIST
>
204 REALLY_INLINE
uint64_t TypedVectorObject
<TLIST
>::bytesUsed() const
206 return ScriptObject::bytesUsed() + m_list
.bytesUsed();
210 template<class TLIST
>
211 REALLY_INLINE
uint32_t TypedVectorObject
<TLIST
>::checkReadIndex_u(uint32_t index
) const
213 uint32_t const limit
= m_list
.length();
215 throwRangeError(index
);
219 template<class TLIST
>
220 REALLY_INLINE
uint32_t TypedVectorObject
<TLIST
>::checkWriteIndex_u(uint32_t index
) const
222 // If we are 'fixed', we can't write past the end.
223 // If we are not 'fixed', legal to write exactly 1 past the end, growing as needed.
224 uint32_t const limit
= m_list
.length() + 1 - uint32_t(m_fixed
);
226 throwRangeError(index
);
230 // ----------------------------
232 template<class TLIST
>
233 REALLY_INLINE VectorAccessor
<TLIST
>::VectorAccessor(TypedVectorObject
<TLIST
>* v
) : m_vector(v
)
237 template<class TLIST
>
238 REALLY_INLINE typename
TLIST::TYPE
* VectorAccessor
<TLIST
>::addr()
240 return (m_vector
!= NULL
) ? m_vector
->m_list
.m_data
->entries
: (typename
TLIST::TYPE
*)NULL
;
243 template<class TLIST
>
244 REALLY_INLINE
uint32_t VectorAccessor
<TLIST
>::length()
246 return (m_vector
!= NULL
) ? m_vector
->m_list
.length() : 0;
250 #endif /* __avmplus_VectorClass__ */