OLD | NEW |
1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 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 1941 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1952 // isn't lazily compiled. The extension structures are only | 1952 // isn't lazily compiled. The extension structures are only |
1953 // accessible while parsing the first time not when reparsing | 1953 // accessible while parsing the first time not when reparsing |
1954 // because of lazy compilation. | 1954 // because of lazy compilation. |
1955 top_scope_->ForceEagerCompilation(); | 1955 top_scope_->ForceEagerCompilation(); |
1956 | 1956 |
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 shared function info 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<SharedFunctionInfo> shared = | 1967 Handle<SharedFunctionInfo> shared = |
1968 Factory::NewSharedFunctionInfo(name, literals, code); | 1968 Factory::NewSharedFunctionInfo(name, literals, code); |
1969 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 shared function info. |
1972 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 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 SharedFunctionInfoLiteral* lit = NEW(SharedFunctionInfoLiteral(shared)); | 1979 SharedFunctionInfoLiteral* lit = NEW(SharedFunctionInfoLiteral(shared)); |
1980 VariableProxy* var = Declare(name, Variable::VAR, NULL, true, CHECK_OK); | 1980 VariableProxy* var = Declare(name, Variable::VAR, NULL, true, CHECK_OK); |
1981 return NEW(ExpressionStatement( | 1981 return NEW(ExpressionStatement( |
(...skipping 3191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5173 parser.ParseLazy(script_source, name, | 5173 parser.ParseLazy(script_source, name, |
5174 start_position, end_position, is_expression); | 5174 start_position, end_position, is_expression); |
5175 return result; | 5175 return result; |
5176 } | 5176 } |
5177 | 5177 |
5178 | 5178 |
5179 #undef NEW | 5179 #undef NEW |
5180 | 5180 |
5181 | 5181 |
5182 } } // namespace v8::internal | 5182 } } // namespace v8::internal |
OLD | NEW |