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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/lib/collection_sources.gypi ('k') | runtime/lib/linked_hash_map.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/lib/linked_hash_map.cc
===================================================================
--- runtime/lib/linked_hash_map.cc (revision 0)
+++ runtime/lib/linked_hash_map.cc (revision 0)
@@ -0,0 +1,96 @@
+// Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+#include "platform/assert.h"
+
+#include "vm/assembler.h"
+#include "vm/bootstrap_natives.h"
+#include "vm/exceptions.h"
+#include "vm/flags.h"
+#include "vm/native_entry.h"
+#include "vm/object.h"
+
+namespace dart {
+
+DEFINE_FLAG(bool, use_internal_hash_map, false, "Use internal hash map.");
+
+DEFINE_NATIVE_ENTRY(LinkedHashMap_allocate, 1) {
+ const TypeArguments& type_arguments =
+ TypeArguments::CheckedHandle(arguments->NativeArgAt(0));
+ const LinkedHashMap& map =
+ LinkedHashMap::Handle(LinkedHashMap::New());
+ map.SetTypeArguments(type_arguments);
+ return map.raw();
+}
+
+
+DEFINE_NATIVE_ENTRY(LinkedHashMap_getLength, 1) {
+ const LinkedHashMap& map =
+ LinkedHashMap::CheckedHandle(arguments->NativeArgAt(0));
+ return Smi::New(map.Length());
+}
+
+
+DEFINE_NATIVE_ENTRY(LinkedHashMap_lookUp, 2) {
+ const LinkedHashMap& map =
+ LinkedHashMap::CheckedHandle(arguments->NativeArgAt(0));
+ GET_NON_NULL_NATIVE_ARGUMENT(Instance, key, arguments->NativeArgAt(1));
+ return map.LookUp(key);
+}
+
+
+DEFINE_NATIVE_ENTRY(LinkedHashMap_containsKey, 2) {
+ const LinkedHashMap& map =
+ LinkedHashMap::CheckedHandle(arguments->NativeArgAt(0));
+ GET_NON_NULL_NATIVE_ARGUMENT(Instance, key, arguments->NativeArgAt(1));
+ return Bool::Get(map.Contains(key)).raw();
+}
+
+
+DEFINE_NATIVE_ENTRY(LinkedHashMap_insertOrUpdate, 3) {
+ LinkedHashMap& map =
+ LinkedHashMap::CheckedHandle(arguments->NativeArgAt(0));
+ GET_NON_NULL_NATIVE_ARGUMENT(Instance, key, arguments->NativeArgAt(1));
+ GET_NON_NULL_NATIVE_ARGUMENT(Instance, value, arguments->NativeArgAt(2));
+ map.InsertOrUpdate(key, value);
+ return Object::null();
+}
+
+
+DEFINE_NATIVE_ENTRY(LinkedHashMap_remove, 2) {
+ const LinkedHashMap& map =
+ LinkedHashMap::CheckedHandle(arguments->NativeArgAt(0));
+ GET_NON_NULL_NATIVE_ARGUMENT(Instance, key, arguments->NativeArgAt(1));
+ return map.Remove(key);
+}
+
+
+DEFINE_NATIVE_ENTRY(LinkedHashMap_clear, 1) {
+ const LinkedHashMap& map =
+ LinkedHashMap::CheckedHandle(arguments->NativeArgAt(0));
+ map.Clear();
+ return Object::null();
+}
+
+
+DEFINE_NATIVE_ENTRY(LinkedHashMap_toArray, 1) {
+ const LinkedHashMap& map =
+ LinkedHashMap::CheckedHandle(arguments->NativeArgAt(0));
+ return map.ToArray();
+}
+
+
+DEFINE_NATIVE_ENTRY(LinkedHashMap_getModMark, 2) {
+ const LinkedHashMap& map =
+ LinkedHashMap::CheckedHandle(arguments->NativeArgAt(0));
+ GET_NON_NULL_NATIVE_ARGUMENT(Bool, create, arguments->NativeArgAt(1));
+ return map.GetModificationMark(create.value());
+}
+
+
+DEFINE_NATIVE_ENTRY(LinkedHashMap_useInternal, 0) {
+ return Bool::Get(FLAG_use_internal_hash_map).raw();
+}
+
+} // namespace dart
« 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