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

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

Issue 888463004: Add support for sync* and yield (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 5 years, 10 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/core_patch.dart ('k') | runtime/lib/function.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 #include "vm/bootstrap_natives.h" 5 #include "vm/bootstrap_natives.h"
6 6
7 #include "vm/compiler.h" 7 #include "vm/compiler.h"
8 #include "vm/dart_entry.h" 8 #include "vm/dart_entry.h"
9 #include "vm/exceptions.h" 9 #include "vm/exceptions.h"
10 #include "vm/native_entry.h" 10 #include "vm/native_entry.h"
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 result += result << 3; 67 result += result << 3;
68 result ^= result >> 11; 68 result ^= result >> 11;
69 result += result << 15; 69 result += result << 15;
70 result &= ((static_cast<intptr_t>(1) << String::kHashBits) - 1); 70 result &= ((static_cast<intptr_t>(1) << String::kHashBits) - 1);
71 return Smi::New(result); 71 return Smi::New(result);
72 } 72 }
73 UNREACHABLE(); 73 UNREACHABLE();
74 return Object::null(); 74 return Object::null();
75 } 75 }
76 76
77
78 DEFINE_NATIVE_ENTRY(FunctionImpl_clone, 1) {
79 const Instance& receiver = Instance::CheckedHandle(
80 isolate, arguments->NativeArgAt(0));
81 ASSERT(receiver.IsClosure());
82 if (receiver.IsClosure()) {
83 const Function& func =
84 Function::Handle(isolate, Closure::function(receiver));
85 const Context& ctx =
86 Context::Handle(isolate, Closure::context(receiver));
87 Context& cloned_ctx =
88 Context::Handle(isolate, Context::New(ctx.num_variables()));
89 cloned_ctx.set_parent(Context::Handle(isolate, ctx.parent()));
90 Object& inst = Object::Handle(isolate);
91 for (int i = 0; i < ctx.num_variables(); i++) {
92 inst = ctx.At(i);
93 cloned_ctx.SetAt(i, inst);
94 }
95 return Closure::New(func, cloned_ctx);
96 }
97 return Object::null();
98 }
99
100
77 } // namespace dart 101 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/lib/core_patch.dart ('k') | runtime/lib/function.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698