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

Side by Side Diff: vm/parser.cc

Issue 9203004: - Remove support for ">>>" operator. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
Patch Set: '' Created 8 years, 11 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 | « vm/opt_code_generator_ia32.cc ('k') | vm/scanner.cc » ('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) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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 "vm/bigint_operations.h" 7 #include "vm/bigint_operations.h"
8 #include "vm/class_finalizer.h" 8 #include "vm/class_finalizer.h"
9 #include "vm/compiler.h" 9 #include "vm/compiler.h"
10 #include "vm/compiler_stats.h" 10 #include "vm/compiler_stats.h"
(...skipping 2852 matching lines...) Expand 10 before | Expand all | Expand 10 after
2863 } 2863 }
2864 2864
2865 2865
2866 // Consumes exactly one right angle bracket. If the current token is a single 2866 // Consumes exactly one right angle bracket. If the current token is a single
2867 // bracket token, it is consumed normally. However, if it is a double or triple 2867 // bracket token, it is consumed normally. However, if it is a double or triple
2868 // bracket, it is replaced by a single or double bracket token without 2868 // bracket, it is replaced by a single or double bracket token without
2869 // incrementing the token index. 2869 // incrementing the token index.
2870 void Parser::ConsumeRightAngleBracket() { 2870 void Parser::ConsumeRightAngleBracket() {
2871 if (token_kind_ == Token::kGT) { 2871 if (token_kind_ == Token::kGT) {
2872 ConsumeToken(); 2872 ConsumeToken();
2873 } else if (token_kind_ == Token::kSAR) { 2873 } else if (token_kind_ == Token::kSHR) {
2874 token_kind_ = Token::kGT; 2874 token_kind_ = Token::kGT;
2875 } else if (token_kind_ == Token::kSHR) {
2876 token_kind_ = Token::kSAR;
2877 } else { 2875 } else {
2878 UNREACHABLE(); 2876 UNREACHABLE();
2879 } 2877 }
2880 } 2878 }
2881 2879
2882 2880
2883 void Parser::SkipTypeArguments() { 2881 void Parser::SkipTypeArguments() {
2884 if (CurrentToken() == Token::kLT) { 2882 if (CurrentToken() == Token::kLT) {
2885 do { 2883 do {
2886 ConsumeToken(); 2884 ConsumeToken();
2887 SkipType(false); 2885 SkipType(false);
2888 } while (CurrentToken() == Token::kCOMMA); 2886 } while (CurrentToken() == Token::kCOMMA);
2889 Token::Kind token = CurrentToken(); 2887 Token::Kind token = CurrentToken();
2890 if ((token == Token::kGT) || 2888 if ((token == Token::kGT) || (token == Token::kSHR)) {
2891 (token == Token::kSAR) ||
2892 (token == Token::kSHR)) {
2893 ConsumeRightAngleBracket(); 2889 ConsumeRightAngleBracket();
2894 } else { 2890 } else {
2895 ErrorMsg("right angle bracket expected"); 2891 ErrorMsg("right angle bracket expected");
2896 } 2892 }
2897 } 2893 }
2898 } 2894 }
2899 2895
2900 2896
2901 void Parser::SkipType(bool allow_void) { 2897 void Parser::SkipType(bool allow_void) {
2902 if (CurrentToken() == Token::kVOID) { 2898 if (CurrentToken() == Token::kVOID) {
(...skipping 26 matching lines...) Expand all
2929 ConsumeToken(); 2925 ConsumeToken();
2930 AbstractType& type_extends = Type::ZoneHandle(Type::DynamicType()); 2926 AbstractType& type_extends = Type::ZoneHandle(Type::DynamicType());
2931 if (CurrentToken() == Token::kEXTENDS) { 2927 if (CurrentToken() == Token::kEXTENDS) {
2932 ConsumeToken(); 2928 ConsumeToken();
2933 type_extends = ParseType(kCanResolve); 2929 type_extends = ParseType(kCanResolve);
2934 } 2930 }
2935 type_parameters.Add(&type_parameter_name); 2931 type_parameters.Add(&type_parameter_name);
2936 type_parameter_extends.Add(&type_extends); 2932 type_parameter_extends.Add(&type_extends);
2937 } while (CurrentToken() == Token::kCOMMA); 2933 } while (CurrentToken() == Token::kCOMMA);
2938 Token::Kind token = CurrentToken(); 2934 Token::Kind token = CurrentToken();
2939 if ((token == Token::kGT) || 2935 if ((token == Token::kGT) || (token == Token::kSHR)) {
2940 (token == Token::kSAR) ||
2941 (token == Token::kSHR)) {
2942 ConsumeRightAngleBracket(); 2936 ConsumeRightAngleBracket();
2943 } else { 2937 } else {
2944 ErrorMsg("right angle bracket expected"); 2938 ErrorMsg("right angle bracket expected");
2945 } 2939 }
2946 cls.set_type_parameters(Array::Handle(NewArray<String>(type_parameters))); 2940 cls.set_type_parameters(Array::Handle(NewArray<String>(type_parameters)));
2947 const TypeArguments& extends_array = 2941 const TypeArguments& extends_array =
2948 TypeArguments::Handle(NewTypeArguments(type_parameter_extends)); 2942 TypeArguments::Handle(NewTypeArguments(type_parameter_extends));
2949 cls.set_type_parameter_extends(extends_array); 2943 cls.set_type_parameter_extends(extends_array);
2950 // Try to resolve the upper bounds, which will at least resolve the 2944 // Try to resolve the upper bounds, which will at least resolve the
2951 // referenced type parameters. 2945 // referenced type parameters.
(...skipping 11 matching lines...) Expand all
2963 RawAbstractTypeArguments* Parser::ParseTypeArguments( 2957 RawAbstractTypeArguments* Parser::ParseTypeArguments(
2964 TypeResolution type_resolution) { 2958 TypeResolution type_resolution) {
2965 if (CurrentToken() == Token::kLT) { 2959 if (CurrentToken() == Token::kLT) {
2966 GrowableArray<AbstractType*> types; 2960 GrowableArray<AbstractType*> types;
2967 do { 2961 do {
2968 ConsumeToken(); 2962 ConsumeToken();
2969 AbstractType& type = AbstractType::ZoneHandle(ParseType(type_resolution)); 2963 AbstractType& type = AbstractType::ZoneHandle(ParseType(type_resolution));
2970 types.Add(&type); 2964 types.Add(&type);
2971 } while (CurrentToken() == Token::kCOMMA); 2965 } while (CurrentToken() == Token::kCOMMA);
2972 Token::Kind token = CurrentToken(); 2966 Token::Kind token = CurrentToken();
2973 if ((token == Token::kGT) || 2967 if ((token == Token::kGT) || (token == Token::kSHR)) {
2974 (token == Token::kSAR) ||
2975 (token == Token::kSHR)) {
2976 ConsumeRightAngleBracket(); 2968 ConsumeRightAngleBracket();
2977 } else { 2969 } else {
2978 ErrorMsg("right angle bracket expected"); 2970 ErrorMsg("right angle bracket expected");
2979 } 2971 }
2980 return NewTypeArguments(types); 2972 return NewTypeArguments(types);
2981 } 2973 }
2982 return TypeArguments::null(); 2974 return TypeArguments::null();
2983 } 2975 }
2984 2976
2985 2977
(...skipping 918 matching lines...) Expand 10 before | Expand all | Expand 10 after
3904 // parameters. Current token position is not saved and restored. 3896 // parameters. Current token position is not saved and restored.
3905 bool Parser::IsTypeParameter() { 3897 bool Parser::IsTypeParameter() {
3906 if (CurrentToken() == Token::kLT) { 3898 if (CurrentToken() == Token::kLT) {
3907 // We are possibly looking at type parameters. Find closing ">". 3899 // We are possibly looking at type parameters. Find closing ">".
3908 int nesting_level = 0; 3900 int nesting_level = 0;
3909 do { 3901 do {
3910 if (CurrentToken() == Token::kLT) { 3902 if (CurrentToken() == Token::kLT) {
3911 nesting_level++; 3903 nesting_level++;
3912 } else if (CurrentToken() == Token::kGT) { 3904 } else if (CurrentToken() == Token::kGT) {
3913 nesting_level--; 3905 nesting_level--;
3914 } else if (CurrentToken() == Token::kSAR) { 3906 } else if (CurrentToken() == Token::kSHR) {
3915 nesting_level -= 2; 3907 nesting_level -= 2;
3916 } else if (CurrentToken() == Token::kSHR) {
3917 nesting_level -= 3;
3918 } else if (CurrentToken() == Token::kIDENT) { 3908 } else if (CurrentToken() == Token::kIDENT) {
3919 // Check to see if it is a qualified identifier. 3909 // Check to see if it is a qualified identifier.
3920 if (LookaheadToken(1) == Token::kPERIOD) { 3910 if (LookaheadToken(1) == Token::kPERIOD) {
3921 // Consume the identifier, the period will be consumed below. 3911 // Consume the identifier, the period will be consumed below.
3922 ConsumeToken(); 3912 ConsumeToken();
3923 } 3913 }
3924 } else if (CurrentToken() != Token::kCOMMA && 3914 } else if (CurrentToken() != Token::kCOMMA &&
3925 CurrentToken() != Token::kEXTENDS) { 3915 CurrentToken() != Token::kEXTENDS) {
3926 // We are looking at something other than type parameters. 3916 // We are looking at something other than type parameters.
3927 return false; 3917 return false;
(...skipping 1642 matching lines...) Expand 10 before | Expand all | Expand 10 after
5570 case Token::kASSIGN_SUB: 5560 case Token::kASSIGN_SUB:
5571 return new BinaryOpNode(op_pos, Token::kSUB, lhs, rhs); 5561 return new BinaryOpNode(op_pos, Token::kSUB, lhs, rhs);
5572 case Token::kASSIGN_MUL: 5562 case Token::kASSIGN_MUL:
5573 return new BinaryOpNode(op_pos, Token::kMUL, lhs, rhs); 5563 return new BinaryOpNode(op_pos, Token::kMUL, lhs, rhs);
5574 case Token::kASSIGN_TRUNCDIV: 5564 case Token::kASSIGN_TRUNCDIV:
5575 return new BinaryOpNode(op_pos, Token::kTRUNCDIV, lhs, rhs); 5565 return new BinaryOpNode(op_pos, Token::kTRUNCDIV, lhs, rhs);
5576 case Token::kASSIGN_DIV: 5566 case Token::kASSIGN_DIV:
5577 return new BinaryOpNode(op_pos, Token::kDIV, lhs, rhs); 5567 return new BinaryOpNode(op_pos, Token::kDIV, lhs, rhs);
5578 case Token::kASSIGN_MOD: 5568 case Token::kASSIGN_MOD:
5579 return new BinaryOpNode(op_pos, Token::kMOD, lhs, rhs); 5569 return new BinaryOpNode(op_pos, Token::kMOD, lhs, rhs);
5580 case Token::kASSIGN_SAR: 5570 case Token::kASSIGN_SHR:
5581 return new BinaryOpNode(op_pos, Token::kSAR, lhs, rhs); 5571 return new BinaryOpNode(op_pos, Token::kSHR, lhs, rhs);
5582 case Token::kASSIGN_SHL: 5572 case Token::kASSIGN_SHL:
5583 return new BinaryOpNode(op_pos, Token::kSHL, lhs, rhs); 5573 return new BinaryOpNode(op_pos, Token::kSHL, lhs, rhs);
5584 case Token::kASSIGN_SHR:
5585 return new BinaryOpNode(op_pos, Token::kSHR, lhs, rhs);
5586 case Token::kASSIGN_OR: 5574 case Token::kASSIGN_OR:
5587 return new BinaryOpNode(op_pos, Token::kBIT_OR, lhs, rhs); 5575 return new BinaryOpNode(op_pos, Token::kBIT_OR, lhs, rhs);
5588 case Token::kASSIGN_AND: 5576 case Token::kASSIGN_AND:
5589 return new BinaryOpNode(op_pos, Token::kBIT_AND, lhs, rhs); 5577 return new BinaryOpNode(op_pos, Token::kBIT_AND, lhs, rhs);
5590 case Token::kASSIGN_XOR: 5578 case Token::kASSIGN_XOR:
5591 return new BinaryOpNode(op_pos, Token::kBIT_XOR, lhs, rhs); 5579 return new BinaryOpNode(op_pos, Token::kBIT_XOR, lhs, rhs);
5592 default: 5580 default:
5593 ErrorMsg(op_pos, "internal error: ExpandAssignableOp '%s' unimplemented", 5581 ErrorMsg(op_pos, "internal error: ExpandAssignableOp '%s' unimplemented",
5594 Token::Name(assignment_op)); 5582 Token::Name(assignment_op));
5595 UNIMPLEMENTED(); 5583 UNIMPLEMENTED();
(...skipping 2130 matching lines...) Expand 10 before | Expand all | Expand 10 after
7726 } 7714 }
7727 7715
7728 7716
7729 void Parser::SkipNestedExpr() { 7717 void Parser::SkipNestedExpr() {
7730 const bool saved_mode = SetAllowFunctionLiterals(true); 7718 const bool saved_mode = SetAllowFunctionLiterals(true);
7731 SkipExpr(); 7719 SkipExpr();
7732 SetAllowFunctionLiterals(saved_mode); 7720 SetAllowFunctionLiterals(saved_mode);
7733 } 7721 }
7734 7722
7735 } // namespace dart 7723 } // namespace dart
OLDNEW
« no previous file with comments | « vm/opt_code_generator_ia32.cc ('k') | vm/scanner.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698