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

Unified Diff: runtime/vm/parser.cc

Issue 23020025: Implement ParameterMirror.{isFinal,hasDefaultValue,defaultValue}. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Addressed comments + rebase Created 7 years, 4 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
Index: runtime/vm/parser.cc
diff --git a/runtime/vm/parser.cc b/runtime/vm/parser.cc
index 6e65ac8ef8c25c4ff889007900cb9b88754cfb24..fcd3fd31d2b54ecb53cbb0030d1d2573640075a9 100644
--- a/runtime/vm/parser.cc
+++ b/runtime/vm/parser.cc
@@ -775,6 +775,48 @@ static bool IsInvisible(const Function& func) {
}
+RawObject* Parser::ParseFunctionParameters(const Function& func) {
+ ASSERT(!func.IsNull());
+ Isolate* isolate = Isolate::Current();
+ StackZone zone(isolate);
+ LongJump* base = isolate->long_jump_base();
+ LongJump jump;
+ isolate->set_long_jump_base(&jump);
+ if (setjmp(*jump.Set()) == 0) {
+ const Script& script = Script::Handle(isolate, func.script());
+ const Class& owner = Class::Handle(isolate, func.Owner());
+ ASSERT(!owner.IsNull());
+ const Library& lib = Library::Handle(isolate, owner.library());
+ Parser parser(script, lib, func.token_pos());
+ parser.set_current_class(owner);
+ parser.SkipFunctionPreamble();
+ ParamList params;
+ parser.ParseFormalParameterList(true, &params);
+ ParamDesc* param = params.parameters->data();
+ const int param_cnt = params.num_fixed_parameters +
+ params.num_optional_parameters;
+ Array& param_descriptor = Array::Handle(isolate, Array::New(param_cnt * 2));
+ for (int i = 0, j = 0; i < param_cnt; i++, j += 2) {
+ param_descriptor.SetAt(j, param[i].is_final ? Bool::True() :
+ Bool::False());
+ param_descriptor.SetAt(j + 1,
+ (param[i].default_value == NULL) ? Object::null_instance() :
+ *(param[i].default_value));
+ }
+ isolate->set_long_jump_base(base);
+ return param_descriptor.raw();
+ } else {
+ Error& error = Error::Handle();
+ error = isolate->object_store()->sticky_error();
+ isolate->object_store()->clear_sticky_error();
+ isolate->set_long_jump_base(base);
+ return error.raw();
+ }
+ UNREACHABLE();
+ return Object::null();
+}
+
+
void Parser::ParseFunction(ParsedFunction* parsed_function) {
TimerScope timer(FLAG_compiler_stats, &CompilerStats::parser_timer);
Isolate* isolate = Isolate::Current();
« runtime/lib/mirrors.cc ('K') | « runtime/vm/parser.h ('k') | sdk/lib/mirrors/mirrors.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698