| 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 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 #define EXPRESSION_NODE_LIST(V) \ | 95 #define EXPRESSION_NODE_LIST(V) \ |
| 96 V(FunctionLiteral) \ | 96 V(FunctionLiteral) \ |
| 97 V(SharedFunctionInfoLiteral) \ | 97 V(SharedFunctionInfoLiteral) \ |
| 98 V(Conditional) \ | 98 V(Conditional) \ |
| 99 V(VariableProxy) \ | 99 V(VariableProxy) \ |
| 100 V(Literal) \ | 100 V(Literal) \ |
| 101 V(RegExpLiteral) \ | 101 V(RegExpLiteral) \ |
| 102 V(ObjectLiteral) \ | 102 V(ObjectLiteral) \ |
| 103 V(ArrayLiteral) \ | 103 V(ArrayLiteral) \ |
| 104 V(Assignment) \ | 104 V(Assignment) \ |
| 105 V(Yield) \ |
| 105 V(Throw) \ | 106 V(Throw) \ |
| 106 V(Property) \ | 107 V(Property) \ |
| 107 V(Call) \ | 108 V(Call) \ |
| 108 V(CallNew) \ | 109 V(CallNew) \ |
| 109 V(CallRuntime) \ | 110 V(CallRuntime) \ |
| 110 V(UnaryOperation) \ | 111 V(UnaryOperation) \ |
| 111 V(CountOperation) \ | 112 V(CountOperation) \ |
| 112 V(BinaryOperation) \ | 113 V(BinaryOperation) \ |
| 113 V(CompareOperation) \ | 114 V(CompareOperation) \ |
| 114 V(ThisFunction) | 115 V(ThisFunction) |
| (...skipping 1801 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1916 Expression* value_; | 1917 Expression* value_; |
| 1917 int pos_; | 1918 int pos_; |
| 1918 BinaryOperation* binary_operation_; | 1919 BinaryOperation* binary_operation_; |
| 1919 const BailoutId assignment_id_; | 1920 const BailoutId assignment_id_; |
| 1920 | 1921 |
| 1921 bool is_monomorphic_; | 1922 bool is_monomorphic_; |
| 1922 SmallMapList receiver_types_; | 1923 SmallMapList receiver_types_; |
| 1923 }; | 1924 }; |
| 1924 | 1925 |
| 1925 | 1926 |
| 1927 class Yield: public Expression { |
| 1928 public: |
| 1929 DECLARE_NODE_TYPE(Yield) |
| 1930 |
| 1931 Expression* expression() const { return expression_; } |
| 1932 bool is_delegating_yield() const { return is_delegating_yield_; } |
| 1933 virtual int position() const { return pos_; } |
| 1934 |
| 1935 protected: |
| 1936 Yield(Isolate* isolate, |
| 1937 Expression* expression, |
| 1938 bool is_delegating_yield, |
| 1939 int pos) |
| 1940 : Expression(isolate), |
| 1941 expression_(expression), |
| 1942 is_delegating_yield_(is_delegating_yield), |
| 1943 pos_(pos) { } |
| 1944 |
| 1945 private: |
| 1946 Expression* expression_; |
| 1947 bool is_delegating_yield_; |
| 1948 int pos_; |
| 1949 }; |
| 1950 |
| 1951 |
| 1926 class Throw: public Expression { | 1952 class Throw: public Expression { |
| 1927 public: | 1953 public: |
| 1928 DECLARE_NODE_TYPE(Throw) | 1954 DECLARE_NODE_TYPE(Throw) |
| 1929 | 1955 |
| 1930 Expression* exception() const { return exception_; } | 1956 Expression* exception() const { return exception_; } |
| 1931 virtual int position() const { return pos_; } | 1957 virtual int position() const { return pos_; } |
| 1932 | 1958 |
| 1933 protected: | 1959 protected: |
| 1934 Throw(Isolate* isolate, Expression* exception, int pos) | 1960 Throw(Isolate* isolate, Expression* exception, int pos) |
| 1935 : Expression(isolate), exception_(exception), pos_(pos) {} | 1961 : Expression(isolate), exception_(exception), pos_(pos) {} |
| (...skipping 20 matching lines...) Expand all Loading... |
| 1956 enum IsFunctionFlag { | 1982 enum IsFunctionFlag { |
| 1957 kGlobalOrEval, | 1983 kGlobalOrEval, |
| 1958 kIsFunction | 1984 kIsFunction |
| 1959 }; | 1985 }; |
| 1960 | 1986 |
| 1961 enum IsParenthesizedFlag { | 1987 enum IsParenthesizedFlag { |
| 1962 kIsParenthesized, | 1988 kIsParenthesized, |
| 1963 kNotParenthesized | 1989 kNotParenthesized |
| 1964 }; | 1990 }; |
| 1965 | 1991 |
| 1992 enum IsGeneratorFlag { |
| 1993 kIsGenerator, |
| 1994 kNotGenerator |
| 1995 }; |
| 1996 |
| 1966 DECLARE_NODE_TYPE(FunctionLiteral) | 1997 DECLARE_NODE_TYPE(FunctionLiteral) |
| 1967 | 1998 |
| 1968 Handle<String> name() const { return name_; } | 1999 Handle<String> name() const { return name_; } |
| 1969 Scope* scope() const { return scope_; } | 2000 Scope* scope() const { return scope_; } |
| 1970 ZoneList<Statement*>* body() const { return body_; } | 2001 ZoneList<Statement*>* body() const { return body_; } |
| 1971 void set_function_token_position(int pos) { function_token_position_ = pos; } | 2002 void set_function_token_position(int pos) { function_token_position_ = pos; } |
| 1972 int function_token_position() const { return function_token_position_; } | 2003 int function_token_position() const { return function_token_position_; } |
| 1973 int start_position() const; | 2004 int start_position() const; |
| 1974 int end_position() const; | 2005 int end_position() const; |
| 1975 int SourceSize() const { return end_position() - start_position(); } | 2006 int SourceSize() const { return end_position() - start_position(); } |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2016 // function will be called immediately: | 2047 // function will be called immediately: |
| 2017 // - (function() { ... })(); | 2048 // - (function() { ... })(); |
| 2018 // - var x = function() { ... }(); | 2049 // - var x = function() { ... }(); |
| 2019 bool is_parenthesized() { | 2050 bool is_parenthesized() { |
| 2020 return IsParenthesized::decode(bitfield_) == kIsParenthesized; | 2051 return IsParenthesized::decode(bitfield_) == kIsParenthesized; |
| 2021 } | 2052 } |
| 2022 void set_parenthesized() { | 2053 void set_parenthesized() { |
| 2023 bitfield_ = IsParenthesized::update(bitfield_, kIsParenthesized); | 2054 bitfield_ = IsParenthesized::update(bitfield_, kIsParenthesized); |
| 2024 } | 2055 } |
| 2025 | 2056 |
| 2057 bool is_generator() { |
| 2058 return IsGenerator::decode(bitfield_) == kIsGenerator; |
| 2059 } |
| 2060 |
| 2026 int ast_node_count() { return ast_properties_.node_count(); } | 2061 int ast_node_count() { return ast_properties_.node_count(); } |
| 2027 AstProperties::Flags* flags() { return ast_properties_.flags(); } | 2062 AstProperties::Flags* flags() { return ast_properties_.flags(); } |
| 2028 void set_ast_properties(AstProperties* ast_properties) { | 2063 void set_ast_properties(AstProperties* ast_properties) { |
| 2029 ast_properties_ = *ast_properties; | 2064 ast_properties_ = *ast_properties; |
| 2030 } | 2065 } |
| 2031 | 2066 |
| 2032 protected: | 2067 protected: |
| 2033 FunctionLiteral(Isolate* isolate, | 2068 FunctionLiteral(Isolate* isolate, |
| 2034 Handle<String> name, | 2069 Handle<String> name, |
| 2035 Scope* scope, | 2070 Scope* scope, |
| 2036 ZoneList<Statement*>* body, | 2071 ZoneList<Statement*>* body, |
| 2037 int materialized_literal_count, | 2072 int materialized_literal_count, |
| 2038 int expected_property_count, | 2073 int expected_property_count, |
| 2039 int handler_count, | 2074 int handler_count, |
| 2040 bool has_only_simple_this_property_assignments, | 2075 bool has_only_simple_this_property_assignments, |
| 2041 Handle<FixedArray> this_property_assignments, | 2076 Handle<FixedArray> this_property_assignments, |
| 2042 int parameter_count, | 2077 int parameter_count, |
| 2043 Type type, | 2078 Type type, |
| 2044 ParameterFlag has_duplicate_parameters, | 2079 ParameterFlag has_duplicate_parameters, |
| 2045 IsFunctionFlag is_function, | 2080 IsFunctionFlag is_function, |
| 2046 IsParenthesizedFlag is_parenthesized) | 2081 IsParenthesizedFlag is_parenthesized, |
| 2082 IsGeneratorFlag is_generator) |
| 2047 : Expression(isolate), | 2083 : Expression(isolate), |
| 2048 name_(name), | 2084 name_(name), |
| 2049 scope_(scope), | 2085 scope_(scope), |
| 2050 body_(body), | 2086 body_(body), |
| 2051 this_property_assignments_(this_property_assignments), | 2087 this_property_assignments_(this_property_assignments), |
| 2052 inferred_name_(isolate->factory()->empty_string()), | 2088 inferred_name_(isolate->factory()->empty_string()), |
| 2053 materialized_literal_count_(materialized_literal_count), | 2089 materialized_literal_count_(materialized_literal_count), |
| 2054 expected_property_count_(expected_property_count), | 2090 expected_property_count_(expected_property_count), |
| 2055 handler_count_(handler_count), | 2091 handler_count_(handler_count), |
| 2056 parameter_count_(parameter_count), | 2092 parameter_count_(parameter_count), |
| 2057 function_token_position_(RelocInfo::kNoPosition) { | 2093 function_token_position_(RelocInfo::kNoPosition) { |
| 2058 bitfield_ = | 2094 bitfield_ = |
| 2059 HasOnlySimpleThisPropertyAssignments::encode( | 2095 HasOnlySimpleThisPropertyAssignments::encode( |
| 2060 has_only_simple_this_property_assignments) | | 2096 has_only_simple_this_property_assignments) | |
| 2061 IsExpression::encode(type != DECLARATION) | | 2097 IsExpression::encode(type != DECLARATION) | |
| 2062 IsAnonymous::encode(type == ANONYMOUS_EXPRESSION) | | 2098 IsAnonymous::encode(type == ANONYMOUS_EXPRESSION) | |
| 2063 Pretenure::encode(false) | | 2099 Pretenure::encode(false) | |
| 2064 HasDuplicateParameters::encode(has_duplicate_parameters) | | 2100 HasDuplicateParameters::encode(has_duplicate_parameters) | |
| 2065 IsFunction::encode(is_function) | | 2101 IsFunction::encode(is_function) | |
| 2066 IsParenthesized::encode(is_parenthesized); | 2102 IsParenthesized::encode(is_parenthesized) | |
| 2103 IsGenerator::encode(is_generator); |
| 2067 } | 2104 } |
| 2068 | 2105 |
| 2069 private: | 2106 private: |
| 2070 Handle<String> name_; | 2107 Handle<String> name_; |
| 2071 Scope* scope_; | 2108 Scope* scope_; |
| 2072 ZoneList<Statement*>* body_; | 2109 ZoneList<Statement*>* body_; |
| 2073 Handle<FixedArray> this_property_assignments_; | 2110 Handle<FixedArray> this_property_assignments_; |
| 2074 Handle<String> inferred_name_; | 2111 Handle<String> inferred_name_; |
| 2075 AstProperties ast_properties_; | 2112 AstProperties ast_properties_; |
| 2076 | 2113 |
| 2077 int materialized_literal_count_; | 2114 int materialized_literal_count_; |
| 2078 int expected_property_count_; | 2115 int expected_property_count_; |
| 2079 int handler_count_; | 2116 int handler_count_; |
| 2080 int parameter_count_; | 2117 int parameter_count_; |
| 2081 int function_token_position_; | 2118 int function_token_position_; |
| 2082 | 2119 |
| 2083 unsigned bitfield_; | 2120 unsigned bitfield_; |
| 2084 class HasOnlySimpleThisPropertyAssignments: public BitField<bool, 0, 1> {}; | 2121 class HasOnlySimpleThisPropertyAssignments: public BitField<bool, 0, 1> {}; |
| 2085 class IsExpression: public BitField<bool, 1, 1> {}; | 2122 class IsExpression: public BitField<bool, 1, 1> {}; |
| 2086 class IsAnonymous: public BitField<bool, 2, 1> {}; | 2123 class IsAnonymous: public BitField<bool, 2, 1> {}; |
| 2087 class Pretenure: public BitField<bool, 3, 1> {}; | 2124 class Pretenure: public BitField<bool, 3, 1> {}; |
| 2088 class HasDuplicateParameters: public BitField<ParameterFlag, 4, 1> {}; | 2125 class HasDuplicateParameters: public BitField<ParameterFlag, 4, 1> {}; |
| 2089 class IsFunction: public BitField<IsFunctionFlag, 5, 1> {}; | 2126 class IsFunction: public BitField<IsFunctionFlag, 5, 1> {}; |
| 2090 class IsParenthesized: public BitField<IsParenthesizedFlag, 6, 1> {}; | 2127 class IsParenthesized: public BitField<IsParenthesizedFlag, 6, 1> {}; |
| 2128 class IsGenerator: public BitField<IsGeneratorFlag, 7, 1> {}; |
| 2091 }; | 2129 }; |
| 2092 | 2130 |
| 2093 | 2131 |
| 2094 class SharedFunctionInfoLiteral: public Expression { | 2132 class SharedFunctionInfoLiteral: public Expression { |
| 2095 public: | 2133 public: |
| 2096 DECLARE_NODE_TYPE(SharedFunctionInfoLiteral) | 2134 DECLARE_NODE_TYPE(SharedFunctionInfoLiteral) |
| 2097 | 2135 |
| 2098 Handle<SharedFunctionInfo> shared_function_info() const { | 2136 Handle<SharedFunctionInfo> shared_function_info() const { |
| 2099 return shared_function_info_; | 2137 return shared_function_info_; |
| 2100 } | 2138 } |
| (...skipping 778 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2879 Assignment* NewAssignment(Token::Value op, | 2917 Assignment* NewAssignment(Token::Value op, |
| 2880 Expression* target, | 2918 Expression* target, |
| 2881 Expression* value, | 2919 Expression* value, |
| 2882 int pos) { | 2920 int pos) { |
| 2883 Assignment* assign = | 2921 Assignment* assign = |
| 2884 new(zone_) Assignment(isolate_, op, target, value, pos); | 2922 new(zone_) Assignment(isolate_, op, target, value, pos); |
| 2885 assign->Init(isolate_, this); | 2923 assign->Init(isolate_, this); |
| 2886 VISIT_AND_RETURN(Assignment, assign) | 2924 VISIT_AND_RETURN(Assignment, assign) |
| 2887 } | 2925 } |
| 2888 | 2926 |
| 2927 Yield* NewYield(Expression* expression, bool is_delegating_yield, int pos) { |
| 2928 Yield* yield = |
| 2929 new(zone_) Yield(isolate_, expression, is_delegating_yield, pos); |
| 2930 VISIT_AND_RETURN(Yield, yield) |
| 2931 } |
| 2932 |
| 2889 Throw* NewThrow(Expression* exception, int pos) { | 2933 Throw* NewThrow(Expression* exception, int pos) { |
| 2890 Throw* t = new(zone_) Throw(isolate_, exception, pos); | 2934 Throw* t = new(zone_) Throw(isolate_, exception, pos); |
| 2891 VISIT_AND_RETURN(Throw, t) | 2935 VISIT_AND_RETURN(Throw, t) |
| 2892 } | 2936 } |
| 2893 | 2937 |
| 2894 FunctionLiteral* NewFunctionLiteral( | 2938 FunctionLiteral* NewFunctionLiteral( |
| 2895 Handle<String> name, | 2939 Handle<String> name, |
| 2896 Scope* scope, | 2940 Scope* scope, |
| 2897 ZoneList<Statement*>* body, | 2941 ZoneList<Statement*>* body, |
| 2898 int materialized_literal_count, | 2942 int materialized_literal_count, |
| 2899 int expected_property_count, | 2943 int expected_property_count, |
| 2900 int handler_count, | 2944 int handler_count, |
| 2901 bool has_only_simple_this_property_assignments, | 2945 bool has_only_simple_this_property_assignments, |
| 2902 Handle<FixedArray> this_property_assignments, | 2946 Handle<FixedArray> this_property_assignments, |
| 2903 int parameter_count, | 2947 int parameter_count, |
| 2904 FunctionLiteral::ParameterFlag has_duplicate_parameters, | 2948 FunctionLiteral::ParameterFlag has_duplicate_parameters, |
| 2905 FunctionLiteral::Type type, | 2949 FunctionLiteral::Type type, |
| 2906 FunctionLiteral::IsFunctionFlag is_function, | 2950 FunctionLiteral::IsFunctionFlag is_function, |
| 2907 FunctionLiteral::IsParenthesizedFlag is_parenthesized) { | 2951 FunctionLiteral::IsParenthesizedFlag is_parenthesized, |
| 2952 FunctionLiteral::IsGeneratorFlag is_generator) { |
| 2908 FunctionLiteral* lit = new(zone_) FunctionLiteral( | 2953 FunctionLiteral* lit = new(zone_) FunctionLiteral( |
| 2909 isolate_, name, scope, body, | 2954 isolate_, name, scope, body, |
| 2910 materialized_literal_count, expected_property_count, handler_count, | 2955 materialized_literal_count, expected_property_count, handler_count, |
| 2911 has_only_simple_this_property_assignments, this_property_assignments, | 2956 has_only_simple_this_property_assignments, this_property_assignments, |
| 2912 parameter_count, type, has_duplicate_parameters, is_function, | 2957 parameter_count, type, has_duplicate_parameters, is_function, |
| 2913 is_parenthesized); | 2958 is_parenthesized, is_generator); |
| 2914 // Top-level literal doesn't count for the AST's properties. | 2959 // Top-level literal doesn't count for the AST's properties. |
| 2915 if (is_function == FunctionLiteral::kIsFunction) { | 2960 if (is_function == FunctionLiteral::kIsFunction) { |
| 2916 visitor_.VisitFunctionLiteral(lit); | 2961 visitor_.VisitFunctionLiteral(lit); |
| 2917 } | 2962 } |
| 2918 return lit; | 2963 return lit; |
| 2919 } | 2964 } |
| 2920 | 2965 |
| 2921 SharedFunctionInfoLiteral* NewSharedFunctionInfoLiteral( | 2966 SharedFunctionInfoLiteral* NewSharedFunctionInfoLiteral( |
| 2922 Handle<SharedFunctionInfo> shared_function_info) { | 2967 Handle<SharedFunctionInfo> shared_function_info) { |
| 2923 SharedFunctionInfoLiteral* lit = | 2968 SharedFunctionInfoLiteral* lit = |
| (...skipping 11 matching lines...) Expand all Loading... |
| 2935 private: | 2980 private: |
| 2936 Isolate* isolate_; | 2981 Isolate* isolate_; |
| 2937 Zone* zone_; | 2982 Zone* zone_; |
| 2938 Visitor visitor_; | 2983 Visitor visitor_; |
| 2939 }; | 2984 }; |
| 2940 | 2985 |
| 2941 | 2986 |
| 2942 } } // namespace v8::internal | 2987 } } // namespace v8::internal |
| 2943 | 2988 |
| 2944 #endif // V8_AST_H_ | 2989 #endif // V8_AST_H_ |
| OLD | NEW |