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

Side by Side Diff: runtime/vm/parser.cc

Issue 23019013: Mark private methods of core libraries as invisible in the VM. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: 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 unified diff | Download patch | Annotate | Revision Log
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/parser.h" 5 #include "vm/parser.h"
6 6
7 #include "lib/invocation_mirror.h" 7 #include "lib/invocation_mirror.h"
8 #include "vm/bigint_operations.h" 8 #include "vm/bigint_operations.h"
9 #include "vm/bootstrap.h" 9 #include "vm/bootstrap.h"
10 #include "vm/class_finalizer.h" 10 #include "vm/class_finalizer.h"
(...skipping 744 matching lines...) Expand 10 before | Expand all | Expand 10 after
755 Isolate* isolate = Isolate::Current(); 755 Isolate* isolate = Isolate::Current();
756 ASSERT(isolate->long_jump_base()->IsSafeToJump()); 756 ASSERT(isolate->long_jump_base()->IsSafeToJump());
757 const Script& script = Script::Handle(isolate, cls.script()); 757 const Script& script = Script::Handle(isolate, cls.script());
758 const Library& lib = Library::Handle(isolate, cls.library()); 758 const Library& lib = Library::Handle(isolate, cls.library());
759 Parser parser(script, lib, cls.token_pos()); 759 Parser parser(script, lib, cls.token_pos());
760 parser.ParseClassDefinition(cls); 760 parser.ParseClassDefinition(cls);
761 } 761 }
762 } 762 }
763 763
764 764
765 static bool IsInvisible(const Function& func) {
766 if (!Library::IsPrivate(String::Handle(func.name()))) return false;
767 // Check for private function in the core libraries.
768 const Class& cls = Class::Handle(func.Owner());
769 const Library& library = Library::Handle(cls.library());
770 if (library.raw() == Library::CoreLibrary()) return true;
771 if (library.raw() == Library::CollectionLibrary()) return true;
772 if (library.raw() == Library::TypedDataLibrary()) return true;
773 if (library.raw() == Library::MathLibrary()) return true;
774 return false;
775 }
776
777
765 void Parser::ParseFunction(ParsedFunction* parsed_function) { 778 void Parser::ParseFunction(ParsedFunction* parsed_function) {
766 TimerScope timer(FLAG_compiler_stats, &CompilerStats::parser_timer); 779 TimerScope timer(FLAG_compiler_stats, &CompilerStats::parser_timer);
767 Isolate* isolate = Isolate::Current(); 780 Isolate* isolate = Isolate::Current();
768 ASSERT(isolate->long_jump_base()->IsSafeToJump()); 781 ASSERT(isolate->long_jump_base()->IsSafeToJump());
769 ASSERT(parsed_function != NULL); 782 ASSERT(parsed_function != NULL);
770 const Function& func = parsed_function->function(); 783 const Function& func = parsed_function->function();
784 // Mark private core library functions as invisible by default.
785 if (IsInvisible(func)) func.set_is_visible(false);
771 const Script& script = Script::Handle(isolate, func.script()); 786 const Script& script = Script::Handle(isolate, func.script());
772 Parser parser(script, parsed_function, func.token_pos()); 787 Parser parser(script, parsed_function, func.token_pos());
773 SequenceNode* node_sequence = NULL; 788 SequenceNode* node_sequence = NULL;
774 Array& default_parameter_values = Array::ZoneHandle(isolate, Array::null()); 789 Array& default_parameter_values = Array::ZoneHandle(isolate, Array::null());
775 switch (func.kind()) { 790 switch (func.kind()) {
776 case RawFunction::kRegularFunction: 791 case RawFunction::kRegularFunction:
777 case RawFunction::kClosureFunction: 792 case RawFunction::kClosureFunction:
778 case RawFunction::kGetterFunction: 793 case RawFunction::kGetterFunction:
779 case RawFunction::kSetterFunction: 794 case RawFunction::kSetterFunction:
780 case RawFunction::kConstructor: 795 case RawFunction::kConstructor:
(...skipping 9589 matching lines...) Expand 10 before | Expand all | Expand 10 after
10370 void Parser::SkipQualIdent() { 10385 void Parser::SkipQualIdent() {
10371 ASSERT(IsIdentifier()); 10386 ASSERT(IsIdentifier());
10372 ConsumeToken(); 10387 ConsumeToken();
10373 if (CurrentToken() == Token::kPERIOD) { 10388 if (CurrentToken() == Token::kPERIOD) {
10374 ConsumeToken(); // Consume the kPERIOD token. 10389 ConsumeToken(); // Consume the kPERIOD token.
10375 ExpectIdentifier("identifier expected after '.'"); 10390 ExpectIdentifier("identifier expected after '.'");
10376 } 10391 }
10377 } 10392 }
10378 10393
10379 } // namespace dart 10394 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698