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) 2009
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 Stringp
Multiname::getName() const
45 AvmAssert(!isAnyName() && !isRtname());
49 REALLY_INLINE
void Multiname::setName(Stringp _name
)
51 AvmAssert(_name
&& _name
->isInterned());
52 this->flags
&= ~RTNAME
;
56 REALLY_INLINE
void Multiname::setName(const Multiname
* other
)
58 // copy name settings from other
60 flags
|= other
->flags
& RTNAME
;
61 this->name
= other
->name
;
64 REALLY_INLINE
int32_t Multiname::namespaceCount() const
66 return (nsset
&& (flags
& NSSET
)) ? nsset
->count() : 1;
69 REALLY_INLINE Namespacep
Multiname::getNamespace() const
71 return getNamespace(0);
74 REALLY_INLINE
void Multiname::setNamespace(Namespacep _ns
)
76 flags
&= ~(NSSET
|RTNS
);
77 AvmAssert(_ns
!= NULL
);
81 REALLY_INLINE
void Multiname::setNamespace(const Multiname
* other
)
83 // copy namespace settings from other
84 flags
&= ~(NSSET
|RTNS
);
85 flags
|= other
->flags
& (NSSET
|RTNS
);
89 REALLY_INLINE NamespaceSetp
Multiname::getNsset() const
91 AvmAssert(!isRtns() && (flags
&NSSET
));
95 REALLY_INLINE
void Multiname::setNsset(NamespaceSetp _nsset
)
99 AvmAssert(_nsset
!= NULL
);
100 this->nsset
= _nsset
;
103 REALLY_INLINE
uint32_t Multiname::getTypeParameter() const
105 AvmAssert(isParameterizedType());
109 REALLY_INLINE
void Multiname::setTypeParameter(uint32_t index
)
112 this->next_index
= index
;
115 REALLY_INLINE
Multiname::Multiname()
120 this->next_index
= 0;
123 REALLY_INLINE
Multiname::Multiname(NamespaceSetp nsset
)
128 this->next_index
= 0;
131 REALLY_INLINE
Multiname::Multiname(const Multiname
&other
)
136 REALLY_INLINE
Multiname::Multiname(Namespacep ns
, Stringp name
)
138 AvmAssert(name
&& name
->isInterned());
142 this->next_index
= 0;
145 REALLY_INLINE
Multiname::Multiname(Namespacep ns
, Stringp name
, bool qualified
)
147 AvmAssert(name
&& name
->isInterned());
151 this->next_index
= 0;
156 REALLY_INLINE
Multiname::~Multiname()
164 REALLY_INLINE
void Multiname::gcTrace(MMgc::GC
* gc
)
166 gc
->TraceLocation((const void**)&name
);
167 gc
->TraceLocation((const void**)&ns
); // or nsset
170 REALLY_INLINE
bool Multiname::containsAnyPublicNamespace() const
173 return false; // note, also handles this->ns == null
177 return this->nsset
->containsAnyPublicNamespace();
181 return this->ns
->isPublic();
187 * return the flags we want to keep when copying a compile-time
188 * multiname into a runtime temporary multiname
190 REALLY_INLINE
int32_t Multiname::ctFlags() const
192 return flags
& ~(RTNS
|RTNAME
);
196 * returns true if this multiname could resolve to a binding. Attributes,
197 * wildcards, and runtime parts mean it can't match any binding.
199 REALLY_INLINE
int32_t Multiname::isBinding() const
201 return !(flags
& (ATTR
|RTNS
|RTNAME
)) && name
&& ns
;
204 REALLY_INLINE
int32_t Multiname::isRuntime() const
206 return flags
& (RTNS
|RTNAME
);
209 REALLY_INLINE
int32_t Multiname::isRtns() const
214 REALLY_INLINE
int32_t Multiname::isRtname() const
216 return flags
& RTNAME
;
219 REALLY_INLINE
int32_t Multiname::isQName() const
221 return flags
& QNAME
;
224 REALLY_INLINE
bool Multiname::isAttr() const
226 return (bool) (flags
& ATTR
);
229 REALLY_INLINE
bool Multiname::isAnyName() const
231 return !isRtname() && !name
;
234 REALLY_INLINE
bool Multiname::isAnyNamespace() const
236 return !isRtns() && !(flags
&NSSET
) && ns
== NULL
;
239 REALLY_INLINE
int32_t Multiname::isNsset() const
241 return flags
& NSSET
;
244 REALLY_INLINE
bool Multiname::isValidDynamicName() const
246 // return !isAnyName() && !isAttr() && containsAnyPublicNamespace();
247 // consolidate the above to insure against compiler stupidity
248 return ((flags
& (ATTR
|RTNAME
)) == 0) && name
!= NULL
&& containsAnyPublicNamespace();
251 REALLY_INLINE
int32_t Multiname::isParameterizedType() const
253 return flags
&TYPEPARAM
;
256 REALLY_INLINE
void Multiname::setAttr(bool b
)
264 REALLY_INLINE
void Multiname::setQName()
266 AvmAssert(namespaceCount()==1 && !(flags
&NSSET
));
270 REALLY_INLINE
void Multiname::setRtns()
277 REALLY_INLINE
void Multiname::setRtname()
283 REALLY_INLINE
void Multiname::setAnyName()
289 REALLY_INLINE
void Multiname::setAnyNamespace()
291 flags
&= ~(NSSET
|RTNS
);
295 REALLY_INLINE
void Multiname::IncrementRef()
298 name
->IncrementRef();
299 if (ns
!= NULL
&& (flags
& NSSET
) == 0)
303 REALLY_INLINE
void Multiname::DecrementRef()
306 name
->DecrementRef();
307 if (ns
!= NULL
&& (flags
& NSSET
) == 0)
311 REALLY_INLINE
HeapMultiname::HeapMultiname()
312 { /* our embedded Multiname inits itself to all zero */ }
314 REALLY_INLINE
HeapMultiname::HeapMultiname(const Multiname
& other
)
319 REALLY_INLINE
HeapMultiname::operator const Multiname
* () const
324 REALLY_INLINE
HeapMultiname::operator const Multiname
& () const
329 REALLY_INLINE
const HeapMultiname
& HeapMultiname::operator=(const HeapMultiname
& that
)
333 setMultiname(that
.name
);
338 REALLY_INLINE
const HeapMultiname
& HeapMultiname::operator=(const Multiname
& that
)
344 REALLY_INLINE
void HeapMultiname::gcTrace(MMgc::GC
* gc
)
349 REALLY_INLINE Stringp
HeapMultiname::getName() const
351 return name
.getName();
354 REALLY_INLINE
int32_t HeapMultiname::namespaceCount() const
356 return name
.namespaceCount();
359 REALLY_INLINE Namespacep
HeapMultiname::getNamespace(int32_t i
) const
361 return name
.getNamespace(i
);
364 REALLY_INLINE Namespacep
HeapMultiname::getNamespace() const
366 return name
.getNamespace();
369 REALLY_INLINE NamespaceSetp
HeapMultiname::getNsset() const
371 return name
.getNsset();
374 REALLY_INLINE
bool HeapMultiname::contains(Namespacep ns
) const
376 return name
.contains(ns
);
379 REALLY_INLINE
int32_t HeapMultiname::ctFlags() const
381 return name
.ctFlags();
384 REALLY_INLINE
int32_t HeapMultiname::isBinding() const
386 return name
.isBinding();
389 REALLY_INLINE
int32_t HeapMultiname::isRuntime() const
391 return name
.isRuntime();
394 REALLY_INLINE
int32_t HeapMultiname::isRtns() const
396 return name
.isRtns();
399 REALLY_INLINE
int32_t HeapMultiname::isRtname() const
401 return name
.isRtname();
404 REALLY_INLINE
int32_t HeapMultiname::isQName() const
406 return name
.isQName();
409 REALLY_INLINE
bool HeapMultiname::isAttr() const
411 return name
.isAttr();
414 REALLY_INLINE
bool HeapMultiname::isAnyName() const
416 return name
.isAnyName();
419 REALLY_INLINE
bool HeapMultiname::isAnyNamespace() const
421 return name
.isAnyNamespace();
424 REALLY_INLINE
int32_t HeapMultiname::isNsset() const
426 return name
.isNsset();
429 REALLY_INLINE
bool HeapMultiname::matches(const Multiname
*mn
) const
431 return name
.matches(mn
);
434 REALLY_INLINE
MMgc::GC
* HeapMultiname::gc() const
436 return MMgc::GC::GetGC(this);
439 } // namespace avmplus