| OLD | NEW |
| 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 Statement* ParseNativeDeclaration(bool* ok); | 113 Statement* ParseNativeDeclaration(bool* ok); |
| 114 Block* ParseBlock(ZoneStringList* labels, bool* ok); | 114 Block* ParseBlock(ZoneStringList* labels, bool* ok); |
| 115 Block* ParseVariableStatement(bool* ok); | 115 Block* ParseVariableStatement(bool* ok); |
| 116 Block* ParseVariableDeclarations(bool accept_IN, Expression** var, bool* ok); | 116 Block* ParseVariableDeclarations(bool accept_IN, Expression** var, bool* ok); |
| 117 Statement* ParseExpressionOrLabelledStatement(ZoneStringList* labels, | 117 Statement* ParseExpressionOrLabelledStatement(ZoneStringList* labels, |
| 118 bool* ok); | 118 bool* ok); |
| 119 IfStatement* ParseIfStatement(ZoneStringList* labels, bool* ok); | 119 IfStatement* ParseIfStatement(ZoneStringList* labels, bool* ok); |
| 120 Statement* ParseContinueStatement(bool* ok); | 120 Statement* ParseContinueStatement(bool* ok); |
| 121 Statement* ParseBreakStatement(ZoneStringList* labels, bool* ok); | 121 Statement* ParseBreakStatement(ZoneStringList* labels, bool* ok); |
| 122 Statement* ParseReturnStatement(bool* ok); | 122 Statement* ParseReturnStatement(bool* ok); |
| 123 Block* WithHelper(Expression* obj, ZoneStringList* labels, bool* ok); | 123 Block* WithHelper(Expression* obj, |
| 124 ZoneStringList* labels, |
| 125 bool is_catch_block, |
| 126 bool* ok); |
| 124 Statement* ParseWithStatement(ZoneStringList* labels, bool* ok); | 127 Statement* ParseWithStatement(ZoneStringList* labels, bool* ok); |
| 125 CaseClause* ParseCaseClause(bool* default_seen_ptr, bool* ok); | 128 CaseClause* ParseCaseClause(bool* default_seen_ptr, bool* ok); |
| 126 SwitchStatement* ParseSwitchStatement(ZoneStringList* labels, bool* ok); | 129 SwitchStatement* ParseSwitchStatement(ZoneStringList* labels, bool* ok); |
| 127 LoopStatement* ParseDoStatement(ZoneStringList* labels, bool* ok); | 130 LoopStatement* ParseDoStatement(ZoneStringList* labels, bool* ok); |
| 128 LoopStatement* ParseWhileStatement(ZoneStringList* labels, bool* ok); | 131 LoopStatement* ParseWhileStatement(ZoneStringList* labels, bool* ok); |
| 129 Statement* ParseForStatement(ZoneStringList* labels, bool* ok); | 132 Statement* ParseForStatement(ZoneStringList* labels, bool* ok); |
| 130 Statement* ParseThrowStatement(bool* ok); | 133 Statement* ParseThrowStatement(bool* ok); |
| 131 Expression* MakeCatchContext(Handle<String> id, VariableProxy* value); | 134 Expression* MakeCatchContext(Handle<String> id, VariableProxy* value); |
| 132 TryStatement* ParseTryStatement(bool* ok); | 135 TryStatement* ParseTryStatement(bool* ok); |
| 133 DebuggerStatement* ParseDebuggerStatement(bool* ok); | 136 DebuggerStatement* ParseDebuggerStatement(bool* ok); |
| (...skipping 1780 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1914 ExpectSemicolon(CHECK_OK); | 1917 ExpectSemicolon(CHECK_OK); |
| 1915 return NEW(ReturnStatement(GetLiteralUndefined())); | 1918 return NEW(ReturnStatement(GetLiteralUndefined())); |
| 1916 } | 1919 } |
| 1917 | 1920 |
| 1918 Expression* expr = ParseExpression(true, CHECK_OK); | 1921 Expression* expr = ParseExpression(true, CHECK_OK); |
| 1919 ExpectSemicolon(CHECK_OK); | 1922 ExpectSemicolon(CHECK_OK); |
| 1920 return NEW(ReturnStatement(expr)); | 1923 return NEW(ReturnStatement(expr)); |
| 1921 } | 1924 } |
| 1922 | 1925 |
| 1923 | 1926 |
| 1924 Block* Parser::WithHelper(Expression* obj, ZoneStringList* labels, bool* ok) { | 1927 Block* Parser::WithHelper(Expression* obj, |
| 1928 ZoneStringList* labels, |
| 1929 bool is_catch_block, |
| 1930 bool* ok) { |
| 1925 // Parse the statement and collect escaping labels. | 1931 // Parse the statement and collect escaping labels. |
| 1926 ZoneList<Label*>* label_list = NEW(ZoneList<Label*>(0)); | 1932 ZoneList<Label*>* label_list = NEW(ZoneList<Label*>(0)); |
| 1927 LabelCollector collector(label_list); | 1933 LabelCollector collector(label_list); |
| 1928 Statement* stat; | 1934 Statement* stat; |
| 1929 { Target target(this, &collector); | 1935 { Target target(this, &collector); |
| 1930 with_nesting_level_++; | 1936 with_nesting_level_++; |
| 1931 top_scope_->RecordWithStatement(); | 1937 top_scope_->RecordWithStatement(); |
| 1932 stat = ParseStatement(labels, CHECK_OK); | 1938 stat = ParseStatement(labels, CHECK_OK); |
| 1933 with_nesting_level_--; | 1939 with_nesting_level_--; |
| 1934 } | 1940 } |
| 1935 // Create resulting block with two statements. | 1941 // Create resulting block with two statements. |
| 1936 // 1: Evaluate the with expression. | 1942 // 1: Evaluate the with expression. |
| 1937 // 2: The try-finally block evaluating the body. | 1943 // 2: The try-finally block evaluating the body. |
| 1938 Block* result = NEW(Block(NULL, 2, false)); | 1944 Block* result = NEW(Block(NULL, 2, false)); |
| 1939 | 1945 |
| 1940 if (result) { | 1946 if (result) { |
| 1941 result->AddStatement(NEW(WithEnterStatement(obj))); | 1947 result->AddStatement(NEW(WithEnterStatement(obj, is_catch_block))); |
| 1942 | 1948 |
| 1943 // Create body block. | 1949 // Create body block. |
| 1944 Block* body = NEW(Block(NULL, 1, false)); | 1950 Block* body = NEW(Block(NULL, 1, false)); |
| 1945 body->AddStatement(stat); | 1951 body->AddStatement(stat); |
| 1946 | 1952 |
| 1947 // Create exit block. | 1953 // Create exit block. |
| 1948 Block* exit = NEW(Block(NULL, 1, false)); | 1954 Block* exit = NEW(Block(NULL, 1, false)); |
| 1949 exit->AddStatement(NEW(WithExitStatement())); | 1955 exit->AddStatement(NEW(WithExitStatement())); |
| 1950 | 1956 |
| 1951 // Return a try-finally statement. | 1957 // Return a try-finally statement. |
| (...skipping 15 matching lines...) Expand all Loading... |
| 1967 // code. If 'with' statements were allowed, the simplified setup of | 1973 // code. If 'with' statements were allowed, the simplified setup of |
| 1968 // the runtime context chain would allow access to properties in the | 1974 // the runtime context chain would allow access to properties in the |
| 1969 // global object from within a 'with' statement. | 1975 // global object from within a 'with' statement. |
| 1970 ASSERT(!Bootstrapper::IsActive()); | 1976 ASSERT(!Bootstrapper::IsActive()); |
| 1971 | 1977 |
| 1972 Expect(Token::WITH, CHECK_OK); | 1978 Expect(Token::WITH, CHECK_OK); |
| 1973 Expect(Token::LPAREN, CHECK_OK); | 1979 Expect(Token::LPAREN, CHECK_OK); |
| 1974 Expression* expr = ParseExpression(true, CHECK_OK); | 1980 Expression* expr = ParseExpression(true, CHECK_OK); |
| 1975 Expect(Token::RPAREN, CHECK_OK); | 1981 Expect(Token::RPAREN, CHECK_OK); |
| 1976 | 1982 |
| 1977 return WithHelper(expr, labels, CHECK_OK); | 1983 return WithHelper(expr, labels, false, CHECK_OK); |
| 1978 } | 1984 } |
| 1979 | 1985 |
| 1980 | 1986 |
| 1981 CaseClause* Parser::ParseCaseClause(bool* default_seen_ptr, bool* ok) { | 1987 CaseClause* Parser::ParseCaseClause(bool* default_seen_ptr, bool* ok) { |
| 1982 // CaseClause :: | 1988 // CaseClause :: |
| 1983 // 'case' Expression ':' Statement* | 1989 // 'case' Expression ':' Statement* |
| 1984 // 'default' ':' Statement* | 1990 // 'default' ':' Statement* |
| 1985 | 1991 |
| 1986 Expression* label = NULL; // NULL expression indicates default case | 1992 Expression* label = NULL; // NULL expression indicates default case |
| 1987 if (peek() == Token::CASE) { | 1993 if (peek() == Token::CASE) { |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2128 Expect(Token::LPAREN, CHECK_OK); | 2134 Expect(Token::LPAREN, CHECK_OK); |
| 2129 Handle<String> name = ParseIdentifier(CHECK_OK); | 2135 Handle<String> name = ParseIdentifier(CHECK_OK); |
| 2130 Expect(Token::RPAREN, CHECK_OK); | 2136 Expect(Token::RPAREN, CHECK_OK); |
| 2131 | 2137 |
| 2132 if (peek() == Token::LBRACE) { | 2138 if (peek() == Token::LBRACE) { |
| 2133 // Allocate a temporary for holding the finally state while | 2139 // Allocate a temporary for holding the finally state while |
| 2134 // executing the finally block. | 2140 // executing the finally block. |
| 2135 catch_var = top_scope_->NewTemporary(Factory::catch_var_symbol()); | 2141 catch_var = top_scope_->NewTemporary(Factory::catch_var_symbol()); |
| 2136 Expression* obj = MakeCatchContext(name, catch_var); | 2142 Expression* obj = MakeCatchContext(name, catch_var); |
| 2137 { Target target(this, &catch_collector); | 2143 { Target target(this, &catch_collector); |
| 2138 catch_block = WithHelper(obj, NULL, CHECK_OK); | 2144 catch_block = WithHelper(obj, NULL, true, CHECK_OK); |
| 2139 } | 2145 } |
| 2140 } else { | 2146 } else { |
| 2141 Expect(Token::LBRACE, CHECK_OK); | 2147 Expect(Token::LBRACE, CHECK_OK); |
| 2142 } | 2148 } |
| 2143 | 2149 |
| 2144 tok = peek(); | 2150 tok = peek(); |
| 2145 } | 2151 } |
| 2146 | 2152 |
| 2147 if (tok == Token::FINALLY || !has_catch) { | 2153 if (tok == Token::FINALLY || !has_catch) { |
| 2148 Consume(Token::FINALLY); | 2154 Consume(Token::FINALLY); |
| (...skipping 2219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4368 start_position, | 4374 start_position, |
| 4369 is_expression); | 4375 is_expression); |
| 4370 return result; | 4376 return result; |
| 4371 } | 4377 } |
| 4372 | 4378 |
| 4373 | 4379 |
| 4374 #undef NEW | 4380 #undef NEW |
| 4375 | 4381 |
| 4376 | 4382 |
| 4377 } } // namespace v8::internal | 4383 } } // namespace v8::internal |
| OLD | NEW |