Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 1886 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1897 const Function& super_operator = Function::ZoneHandle( | 1897 const Function& super_operator = Function::ZoneHandle( |
| 1898 GetSuperFunction(operator_pos, | 1898 GetSuperFunction(operator_pos, |
| 1899 operator_function_name, | 1899 operator_function_name, |
| 1900 op_arguments, | 1900 op_arguments, |
| 1901 kResolveGetter, | 1901 kResolveGetter, |
| 1902 &is_no_such_method)); | 1902 &is_no_such_method)); |
| 1903 if (is_no_such_method) { | 1903 if (is_no_such_method) { |
| 1904 op_arguments = BuildNoSuchMethodArguments( | 1904 op_arguments = BuildNoSuchMethodArguments( |
| 1905 operator_pos, operator_function_name, *op_arguments); | 1905 operator_pos, operator_function_name, *op_arguments); |
| 1906 } | 1906 } |
| 1907 super_op = new StaticCallNode(operator_pos, super_operator, op_arguments); | 1907 if (super_operator.name() == Symbols::EqualOperator().raw()) { |
| 1908 // Expand super.== call to match correct == semantics into: | |
|
Kevin Millikin (Google)
2013/09/06 12:41:09
Is it better to expand this as:
let t1 = left, t2
Florian Schneider
2013/09/06 13:56:26
I'll leave it as is for now.
| |
| 1909 // Let t1 = left, t2 = right { | |
| 1910 // (t1 === null || t2 === null) ? t1 === t2 | |
| 1911 // : static_call(super.==, t1, t2) | |
| 1912 // } | |
| 1913 // Normal == calls are not expanded at the AST level to produce | |
| 1914 // more compact code and enable more optimization opportunities. | |
| 1915 ASSERT(!is_no_such_method); // == is always found. | |
| 1916 EnsureExpressionTemp(); // Needed for ConditionalExprNode. | |
| 1917 LetNode* result = new LetNode(operator_pos); | |
| 1918 AstNode* left = | |
| 1919 new LoadLocalNode(operator_pos, | |
| 1920 result->AddInitializer(op_arguments->NodeAt(0))); | |
| 1921 AstNode* right = | |
| 1922 new LoadLocalNode(operator_pos, | |
| 1923 result->AddInitializer(op_arguments->NodeAt(1))); | |
| 1924 LiteralNode* null_operand = | |
| 1925 new LiteralNode(operator_pos, Instance::ZoneHandle()); | |
| 1926 ComparisonNode* is_left_null = new ComparisonNode(operator_pos, | |
| 1927 Token::kEQ_STRICT, | |
| 1928 left, | |
| 1929 null_operand); | |
| 1930 ComparisonNode* is_right_null = new ComparisonNode(operator_pos, | |
| 1931 Token::kEQ_STRICT, | |
| 1932 right, | |
| 1933 null_operand); | |
| 1934 BinaryOpNode* null_check = new BinaryOpNode(operator_pos, | |
| 1935 Token::kOR, | |
| 1936 is_left_null, | |
| 1937 is_right_null); | |
| 1938 ArgumentListNode* new_arguments = new ArgumentListNode(operator_pos); | |
| 1939 new_arguments->Add(left); | |
| 1940 new_arguments->Add(right); | |
| 1941 StaticCallNode* call = new StaticCallNode(operator_pos, | |
| 1942 super_operator, | |
| 1943 new_arguments); | |
| 1944 ComparisonNode* strict_eq = new ComparisonNode(operator_pos, | |
| 1945 Token::kEQ_STRICT, | |
| 1946 left, | |
| 1947 right); | |
| 1948 result->AddNode(new ConditionalExprNode(operator_pos, | |
| 1949 null_check, | |
| 1950 strict_eq, | |
| 1951 call)); | |
| 1952 super_op = result; | |
| 1953 } else { | |
| 1954 super_op = new StaticCallNode(operator_pos, super_operator, op_arguments); | |
| 1955 } | |
| 1908 if (negate_result) { | 1956 if (negate_result) { |
| 1909 super_op = new UnaryOpNode(operator_pos, Token::kNOT, super_op); | 1957 super_op = new UnaryOpNode(operator_pos, Token::kNOT, super_op); |
| 1910 } | 1958 } |
| 1911 } | 1959 } |
| 1912 return super_op; | 1960 return super_op; |
| 1913 } | 1961 } |
| 1914 | 1962 |
| 1915 | 1963 |
| 1916 AstNode* Parser::CreateImplicitClosureNode(const Function& func, | 1964 AstNode* Parser::CreateImplicitClosureNode(const Function& func, |
| 1917 intptr_t token_pos, | 1965 intptr_t token_pos, |
| (...skipping 8585 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 10503 void Parser::SkipQualIdent() { | 10551 void Parser::SkipQualIdent() { |
| 10504 ASSERT(IsIdentifier()); | 10552 ASSERT(IsIdentifier()); |
| 10505 ConsumeToken(); | 10553 ConsumeToken(); |
| 10506 if (CurrentToken() == Token::kPERIOD) { | 10554 if (CurrentToken() == Token::kPERIOD) { |
| 10507 ConsumeToken(); // Consume the kPERIOD token. | 10555 ConsumeToken(); // Consume the kPERIOD token. |
| 10508 ExpectIdentifier("identifier expected after '.'"); | 10556 ExpectIdentifier("identifier expected after '.'"); |
| 10509 } | 10557 } |
| 10510 } | 10558 } |
| 10511 | 10559 |
| 10512 } // namespace dart | 10560 } // namespace dart |
| OLD | NEW |