OLD | NEW |
---|---|
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 #ifndef VM_DART_API_IMPL_H_ | 5 #ifndef VM_DART_API_IMPL_H_ |
6 #define VM_DART_API_IMPL_H_ | 6 #define VM_DART_API_IMPL_H_ |
7 | 7 |
8 #include "vm/allocation.h" | 8 #include "vm/allocation.h" |
9 #include "vm/object.h" | 9 #include "vm/object.h" |
10 | 10 |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
104 static FinalizablePersistentHandle* UnwrapAsPrologueWeakPersistentHandle( | 104 static FinalizablePersistentHandle* UnwrapAsPrologueWeakPersistentHandle( |
105 const ApiState& state, | 105 const ApiState& state, |
106 Dart_Handle object); | 106 Dart_Handle object); |
107 | 107 |
108 // Casts the internal Isolate* type to the external Dart_Isolate type. | 108 // Casts the internal Isolate* type to the external Dart_Isolate type. |
109 static Dart_Isolate CastIsolate(Isolate* isolate); | 109 static Dart_Isolate CastIsolate(Isolate* isolate); |
110 | 110 |
111 // Gets the handle used to designate successful return. | 111 // Gets the handle used to designate successful return. |
112 static Dart_Handle Success(Isolate* isolate); | 112 static Dart_Handle Success(Isolate* isolate); |
113 | 113 |
114 // Returns true if the handle holds a Smi. | |
115 static bool IsSmi(Dart_Handle handle) { | |
cshapiro
2012/04/11 23:29:09
Why not call the existing predicate after casing t
turnidge
2012/04/16 20:07:24
Done.
| |
116 uword value = *(reinterpret_cast<uword*>(handle)); | |
117 return (value & kSmiTagMask) == kSmiTag; | |
118 } | |
119 | |
120 // Returns the value of a Smi. | |
121 static intptr_t SmiValue(Dart_Handle handle) { | |
122 intptr_t value = *(reinterpret_cast<intptr_t*>(handle)); | |
cshapiro
2012/04/11 23:29:09
This may be another opportunity to reuse existing
turnidge
2012/04/16 20:07:24
Done. Had to add friend permission though...
| |
123 ASSERT((value & kSmiTagMask) == kSmiTag); | |
124 return (value >> kSmiTagShift); | |
125 } | |
126 | |
114 // Generates a handle used to designate an error return. | 127 // Generates a handle used to designate an error return. |
115 static Dart_Handle NewError(const char* format, ...); | 128 static Dart_Handle NewError(const char* format, ...); |
116 | 129 |
117 // Gets a handle to Null. | 130 // Gets a handle to Null. |
118 static Dart_Handle Null(Isolate* isolate); | 131 static Dart_Handle Null(Isolate* isolate); |
119 | 132 |
120 // Gets a handle to True. | 133 // Gets a handle to True. |
121 static Dart_Handle True(Isolate* isolate); | 134 static Dart_Handle True(Isolate* isolate); |
122 | 135 |
123 // Gets a handle to False | 136 // Gets a handle to False |
(...skipping 29 matching lines...) Expand all Loading... | |
153 } | 166 } |
154 private: | 167 private: |
155 Isolate* saved_isolate_; | 168 Isolate* saved_isolate_; |
156 | 169 |
157 DISALLOW_COPY_AND_ASSIGN(IsolateSaver); | 170 DISALLOW_COPY_AND_ASSIGN(IsolateSaver); |
158 }; | 171 }; |
159 | 172 |
160 } // namespace dart. | 173 } // namespace dart. |
161 | 174 |
162 #endif // VM_DART_API_IMPL_H_ | 175 #endif // VM_DART_API_IMPL_H_ |
OLD | NEW |