Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 4604 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4615 // very first time not when reparsing because of lazy compilation. | 4615 // very first time not when reparsing because of lazy compilation. |
| 4616 top_scope_->DeclarationScope()->ForceEagerCompilation(); | 4616 top_scope_->DeclarationScope()->ForceEagerCompilation(); |
| 4617 } | 4617 } |
| 4618 | 4618 |
| 4619 const Runtime::Function* function = Runtime::FunctionForSymbol(name); | 4619 const Runtime::Function* function = Runtime::FunctionForSymbol(name); |
| 4620 | 4620 |
| 4621 // Check for built-in IS_VAR macro. | 4621 // Check for built-in IS_VAR macro. |
| 4622 if (function != NULL && | 4622 if (function != NULL && |
| 4623 function->intrinsic_type == Runtime::RUNTIME && | 4623 function->intrinsic_type == Runtime::RUNTIME && |
| 4624 function->function_id == Runtime::kIS_VAR) { | 4624 function->function_id == Runtime::kIS_VAR) { |
| 4625 // %IS_VAR(x) evaluates to x if x is a variable, | 4625 // %IS_VAR(x) evaluates to x if x is a variable, |
|
Michael Starzinger
2013/01/31 15:04:53
Comment about IS_VAR needs adaptation as well.
drcarney
2013/01/31 15:20:48
This gets handled by the automatic replace
| |
| 4626 // leads to a parse error otherwise. Could be implemented as an | 4626 // leads to a parse error otherwise. Could be implemented as an |
| 4627 // inline function %_IS_VAR(x) to eliminate this special case. | 4627 // inline function %_IS_VAR(x) to eliminate this special case. |
| 4628 if (args->length() == 1 && args->at(0)->AsVariableProxy() != NULL) { | 4628 if (args->length() == 1 && args->at(0)->AsVariableProxy() != NULL) { |
| 4629 return args->at(0); | 4629 return args->at(0); |
| 4630 } else { | 4630 } else { |
| 4631 ReportMessage("unable_to_parse", Vector<const char*>::empty()); | 4631 ReportMessage("unable_to_parse", Vector<const char*>::empty()); |
| 4632 *ok = false; | 4632 *ok = false; |
| 4633 return NULL; | 4633 return NULL; |
| 4634 } | 4634 } |
| 4635 } | 4635 } |
| 4636 | 4636 |
| 4637 // Check that the expected number of arguments are being passed. | 4637 // Check that the expected number of arguments are being passed. |
| 4638 if (function != NULL && | 4638 if (function != NULL && |
| 4639 function->nargs != -1 && | 4639 function->nargs != -1 && |
| 4640 function->nargs != args->length()) { | 4640 function->nargs != args->length()) { |
| 4641 ReportMessage("illegal_access", Vector<const char*>::empty()); | 4641 ReportMessage("illegal_access", Vector<const char*>::empty()); |
| 4642 *ok = false; | 4642 *ok = false; |
| 4643 return NULL; | 4643 return NULL; |
| 4644 } | 4644 } |
| 4645 | 4645 |
| 4646 // Check that the function is defined if it's an inline runtime call. | 4646 if (function == NULL && name->length() > 0 && name->Get(0) == '_') { |
| 4647 if (function == NULL && name->Get(0) == '_') { | 4647 // Check that the function is defined if it's an inline runtime call. |
| 4648 ReportMessage("not_defined", Vector<Handle<String> >(&name, 1)); | 4648 if (name->length() > 1 && name->Get(1) == '_') { |
| 4649 *ok = false; | 4649 ReportMessage("not_defined", Vector<Handle<String> >(&name, 1)); |
| 4650 return NULL; | 4650 *ok = false; |
| 4651 return NULL; | |
| 4652 } | |
| 4653 // Assume this is a runtime-js function called via %_name. | |
| 4654 name = isolate()->factory()->NewSubString(name, 1, name->length()); | |
|
Michael Starzinger
2013/01/31 15:04:53
This essentially merge the "%foo" and "%_foo" name
drcarney
2013/01/31 15:20:48
Yes, I was planning this for the patch that actual
| |
| 4655 name = isolate()->factory()->LookupSymbol(name); | |
| 4651 } | 4656 } |
| 4652 | 4657 |
| 4653 // We have a valid intrinsics call or a call to a builtin. | 4658 // We have a valid intrinsics call or a call to a builtin. |
| 4654 return factory()->NewCallRuntime(name, function, args); | 4659 return factory()->NewCallRuntime(name, function, args); |
| 4655 } | 4660 } |
| 4656 | 4661 |
| 4657 | 4662 |
| 4658 bool Parser::peek_any_identifier() { | 4663 bool Parser::peek_any_identifier() { |
| 4659 Token::Value next = peek(); | 4664 Token::Value next = peek(); |
| 4660 return next == Token::IDENTIFIER || | 4665 return next == Token::IDENTIFIER || |
| (...skipping 1268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5929 ASSERT(info->isolate()->has_pending_exception()); | 5934 ASSERT(info->isolate()->has_pending_exception()); |
| 5930 } else { | 5935 } else { |
| 5931 result = parser.ParseProgram(); | 5936 result = parser.ParseProgram(); |
| 5932 } | 5937 } |
| 5933 } | 5938 } |
| 5934 info->SetFunction(result); | 5939 info->SetFunction(result); |
| 5935 return (result != NULL); | 5940 return (result != NULL); |
| 5936 } | 5941 } |
| 5937 | 5942 |
| 5938 } } // namespace v8::internal | 5943 } } // namespace v8::internal |
| OLD | NEW |