Reviewers: Mads Ager,

Description:
Refactor SetFunctionInfo to reduce long argument list.

Please review this at http://codereview.chromium.org/165527

SVN Base: http://v8.googlecode.com/svn/branches/bleeding_edge/

Affected files:
   M     src/codegen.cc
   M     src/compiler.cc
   M     src/ia32/codegen-ia32.h


Index: src/ia32/codegen-ia32.h
===================================================================
--- src/ia32/codegen-ia32.h     (revision 2686)
+++ src/ia32/codegen-ia32.h     (working copy)
@@ -299,14 +299,9 @@
  #endif

    static void SetFunctionInfo(Handle<JSFunction> fun,
-                              int length,
-                              int function_token_position,
-                              int start_position,
-                              int end_position,
-                              bool is_expression,
+                              FunctionLiteral* lit,
                                bool is_toplevel,
-                              Handle<Script> script,
-                              Handle<String> inferred_name);
+                              Handle<Script> script);

    // Accessors
    MacroAssembler* masm() { return masm_; }
Index: src/compiler.cc
===================================================================
--- src/compiler.cc     (revision 2686)
+++ src/compiler.cc     (working copy)
@@ -219,11 +219,8 @@
                                        lit->contains_array_literal(),
                                        code);

-  CodeGenerator::SetFunctionInfo(fun, lit->scope()->num_parameters(),
-                                 RelocInfo::kNoPosition,
-                                 lit->start_position(),  
lit->end_position(),
-                                 lit->is_expression(), true, script,
-                                 lit->inferred_name());
+  ASSERT_EQ(RelocInfo::kNoPosition, lit->function_token_position());
+  CodeGenerator::SetFunctionInfo(fun, lit, true, script);

    // Hint to the runtime system used when allocating space for initial
    // property space by setting the expected number of properties for
Index: src/codegen.cc
===================================================================
--- src/codegen.cc      (revision 2686)
+++ src/codegen.cc      (working copy)
@@ -243,23 +243,18 @@
  // in the full script source. When counting characters in the script  
source the
  // the first character is number 0 (not 1).
  void CodeGenerator::SetFunctionInfo(Handle<JSFunction> fun,
-                                    int length,
-                                    int function_token_position,
-                                    int start_position,
-                                    int end_position,
-                                    bool is_expression,
+                                    FunctionLiteral* lit,
                                      bool is_toplevel,
-                                    Handle<Script> script,
-                                    Handle<String> inferred_name) {
-  fun->shared()->set_length(length);
-  fun->shared()->set_formal_parameter_count(length);
+                                    Handle<Script> script) {
+  fun->shared()->set_length(lit->num_parameters());
+  fun->shared()->set_formal_parameter_count(lit->num_parameters());
    fun->shared()->set_script(*script);
-  fun->shared()->set_function_token_position(function_token_position);
-  fun->shared()->set_start_position(start_position);
-  fun->shared()->set_end_position(end_position);
-  fun->shared()->set_is_expression(is_expression);
+   
fun->shared()->set_function_token_position(lit->function_token_position());
+  fun->shared()->set_start_position(lit->start_position());
+  fun->shared()->set_end_position(lit->end_position());
+  fun->shared()->set_is_expression(lit->is_expression());
    fun->shared()->set_is_toplevel(is_toplevel);
-  fun->shared()->set_inferred_name(*inferred_name);
+  fun->shared()->set_inferred_name(*lit->inferred_name());
  }


@@ -317,11 +312,7 @@
                                        node->materialized_literal_count(),
                                        node->contains_array_literal(),
                                        code);
-  CodeGenerator::SetFunctionInfo(function, node->num_parameters(),
-                                 node->function_token_position(),
-                                 node->start_position(),  
node->end_position(),
-                                 node->is_expression(), false, script_,
-                                 node->inferred_name());
+  CodeGenerator::SetFunctionInfo(function, node, false, script_);

  #ifdef ENABLE_DEBUGGER_SUPPORT
    // Notify debugger that a new function has been added.



--~--~---------~--~----~------------~-------~--~----~
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
-~----------~----~----~----~------~----~------~--~---

Reply via email to