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 1946 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1957 // Compute the function template for the native function. | 1957 // Compute the function template for the native function. |
1958 v8::Handle<v8::FunctionTemplate> fun_template = | 1958 v8::Handle<v8::FunctionTemplate> fun_template = |
1959 extension_->GetNativeFunction(v8::Utils::ToLocal(name)); | 1959 extension_->GetNativeFunction(v8::Utils::ToLocal(name)); |
1960 ASSERT(!fun_template.IsEmpty()); | 1960 ASSERT(!fun_template.IsEmpty()); |
1961 | 1961 |
1962 // Instantiate the function and create a boilerplate function from it. | 1962 // Instantiate the function and create a boilerplate function from it. |
1963 Handle<JSFunction> fun = Utils::OpenHandle(*fun_template->GetFunction()); | 1963 Handle<JSFunction> fun = Utils::OpenHandle(*fun_template->GetFunction()); |
1964 const int literals = fun->NumberOfLiterals(); | 1964 const int literals = fun->NumberOfLiterals(); |
1965 Handle<Code> code = Handle<Code>(fun->shared()->code()); | 1965 Handle<Code> code = Handle<Code>(fun->shared()->code()); |
1966 Handle<Code> construct_stub = Handle<Code>(fun->shared()->construct_stub()); | 1966 Handle<Code> construct_stub = Handle<Code>(fun->shared()->construct_stub()); |
1967 Handle<JSFunction> boilerplate = | 1967 Handle<SharedFunctionInfo> shared = |
1968 Factory::NewFunctionBoilerplate(name, literals, code); | 1968 Factory::NewSharedFunctionInfo(name, literals, code); |
1969 boilerplate->shared()->set_construct_stub(*construct_stub); | 1969 shared->set_construct_stub(*construct_stub); |
1970 | 1970 |
1971 // Copy the function data to the boilerplate. | 1971 // Copy the function data to the boilerplate. |
1972 boilerplate->shared()->set_function_data(fun->shared()->function_data()); | 1972 shared->set_function_data(fun->shared()->function_data()); |
1973 int parameters = fun->shared()->formal_parameter_count(); | 1973 int parameters = fun->shared()->formal_parameter_count(); |
1974 boilerplate->shared()->set_formal_parameter_count(parameters); | 1974 shared->set_formal_parameter_count(parameters); |
1975 | 1975 |
1976 // TODO(1240846): It's weird that native function declarations are | 1976 // TODO(1240846): It's weird that native function declarations are |
1977 // introduced dynamically when we meet their declarations, whereas | 1977 // introduced dynamically when we meet their declarations, whereas |
1978 // other functions are setup when entering the surrounding scope. | 1978 // other functions are setup when entering the surrounding scope. |
1979 FunctionBoilerplateLiteral* lit = | 1979 SharedFunctionInfoLiteral* lit = NEW(SharedFunctionInfoLiteral(shared)); |
1980 NEW(FunctionBoilerplateLiteral(boilerplate)); | |
1981 VariableProxy* var = Declare(name, Variable::VAR, NULL, true, CHECK_OK); | 1980 VariableProxy* var = Declare(name, Variable::VAR, NULL, true, CHECK_OK); |
1982 return NEW(ExpressionStatement( | 1981 return NEW(ExpressionStatement( |
1983 new Assignment(Token::INIT_VAR, var, lit, RelocInfo::kNoPosition))); | 1982 new Assignment(Token::INIT_VAR, var, lit, RelocInfo::kNoPosition))); |
1984 } | 1983 } |
1985 | 1984 |
1986 | 1985 |
1987 Statement* Parser::ParseFunctionDeclaration(bool* ok) { | 1986 Statement* Parser::ParseFunctionDeclaration(bool* ok) { |
1988 // FunctionDeclaration :: | 1987 // FunctionDeclaration :: |
1989 // 'function' Identifier '(' FormalParameterListopt ')' '{' FunctionBody '}' | 1988 // 'function' Identifier '(' FormalParameterListopt ')' '{' FunctionBody '}' |
1990 Expect(Token::FUNCTION, CHECK_OK); | 1989 Expect(Token::FUNCTION, CHECK_OK); |
(...skipping 3183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5174 parser.ParseLazy(script_source, name, | 5173 parser.ParseLazy(script_source, name, |
5175 start_position, end_position, is_expression); | 5174 start_position, end_position, is_expression); |
5176 return result; | 5175 return result; |
5177 } | 5176 } |
5178 | 5177 |
5179 | 5178 |
5180 #undef NEW | 5179 #undef NEW |
5181 | 5180 |
5182 | 5181 |
5183 } } // namespace v8::internal | 5182 } } // namespace v8::internal |
OLD | NEW |