Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(251)

Side by Side Diff: runtime/lib/linked_hash_map.cc

Issue 380333002: Add VM class for Map/LinkedHashMap. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « runtime/lib/collection_sources.gypi ('k') | runtime/lib/linked_hash_map.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
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.
4
5 #include "platform/assert.h"
6
7 #include "vm/assembler.h"
8 #include "vm/bootstrap_natives.h"
9 #include "vm/exceptions.h"
10 #include "vm/flags.h"
11 #include "vm/native_entry.h"
12 #include "vm/object.h"
13
14 namespace dart {
15
16 DEFINE_FLAG(bool, use_internal_hash_map, false, "Use internal hash map.");
17
18 DEFINE_NATIVE_ENTRY(LinkedHashMap_allocate, 1) {
19 const TypeArguments& type_arguments =
20 TypeArguments::CheckedHandle(arguments->NativeArgAt(0));
21 const LinkedHashMap& map =
22 LinkedHashMap::Handle(LinkedHashMap::New());
23 map.SetTypeArguments(type_arguments);
24 return map.raw();
25 }
26
27
28 DEFINE_NATIVE_ENTRY(LinkedHashMap_getLength, 1) {
29 const LinkedHashMap& map =
30 LinkedHashMap::CheckedHandle(arguments->NativeArgAt(0));
31 return Smi::New(map.Length());
32 }
33
34
35 DEFINE_NATIVE_ENTRY(LinkedHashMap_lookUp, 2) {
36 const LinkedHashMap& map =
37 LinkedHashMap::CheckedHandle(arguments->NativeArgAt(0));
38 GET_NON_NULL_NATIVE_ARGUMENT(Instance, key, arguments->NativeArgAt(1));
39 return map.LookUp(key);
40 }
41
42
43 DEFINE_NATIVE_ENTRY(LinkedHashMap_containsKey, 2) {
44 const LinkedHashMap& map =
45 LinkedHashMap::CheckedHandle(arguments->NativeArgAt(0));
46 GET_NON_NULL_NATIVE_ARGUMENT(Instance, key, arguments->NativeArgAt(1));
47 return Bool::Get(map.Contains(key)).raw();
48 }
49
50
51 DEFINE_NATIVE_ENTRY(LinkedHashMap_insertOrUpdate, 3) {
52 LinkedHashMap& map =
53 LinkedHashMap::CheckedHandle(arguments->NativeArgAt(0));
54 GET_NON_NULL_NATIVE_ARGUMENT(Instance, key, arguments->NativeArgAt(1));
55 GET_NON_NULL_NATIVE_ARGUMENT(Instance, value, arguments->NativeArgAt(2));
56 map.InsertOrUpdate(key, value);
57 return Object::null();
58 }
59
60
61 DEFINE_NATIVE_ENTRY(LinkedHashMap_remove, 2) {
62 const LinkedHashMap& map =
63 LinkedHashMap::CheckedHandle(arguments->NativeArgAt(0));
64 GET_NON_NULL_NATIVE_ARGUMENT(Instance, key, arguments->NativeArgAt(1));
65 return map.Remove(key);
66 }
67
68
69 DEFINE_NATIVE_ENTRY(LinkedHashMap_clear, 1) {
70 const LinkedHashMap& map =
71 LinkedHashMap::CheckedHandle(arguments->NativeArgAt(0));
72 map.Clear();
73 return Object::null();
74 }
75
76
77 DEFINE_NATIVE_ENTRY(LinkedHashMap_toArray, 1) {
78 const LinkedHashMap& map =
79 LinkedHashMap::CheckedHandle(arguments->NativeArgAt(0));
80 return map.ToArray();
81 }
82
83
84 DEFINE_NATIVE_ENTRY(LinkedHashMap_getModMark, 2) {
85 const LinkedHashMap& map =
86 LinkedHashMap::CheckedHandle(arguments->NativeArgAt(0));
87 GET_NON_NULL_NATIVE_ARGUMENT(Bool, create, arguments->NativeArgAt(1));
88 return map.GetModificationMark(create.value());
89 }
90
91
92 DEFINE_NATIVE_ENTRY(LinkedHashMap_useInternal, 0) {
93 return Bool::Get(FLAG_use_internal_hash_map).raw();
94 }
95
96 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/lib/collection_sources.gypi ('k') | runtime/lib/linked_hash_map.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698