| OLD | NEW |
| 1 // Copyright 2006-2009 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2009 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 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 149 NULL | 149 NULL |
| 150 }; | 150 }; |
| 151 | 151 |
| 152 // Parser/Scanner needs a stack limit. | 152 // Parser/Scanner needs a stack limit. |
| 153 int marker; | 153 int marker; |
| 154 i::StackGuard::SetStackLimit( | 154 i::StackGuard::SetStackLimit( |
| 155 reinterpret_cast<uintptr_t>(&marker) - 128 * 1024); | 155 reinterpret_cast<uintptr_t>(&marker) - 128 * 1024); |
| 156 | 156 |
| 157 for (int i = 0; tests[i]; i++) { | 157 for (int i = 0; tests[i]; i++) { |
| 158 v8::ScriptData* data = | 158 v8::ScriptData* data = |
| 159 v8::ScriptData::PreCompile(tests[i], strlen(tests[i])); | 159 v8::ScriptData::PreCompile(tests[i], i::StrLength(tests[i])); |
| 160 CHECK(data != NULL && !data->HasError()); | 160 CHECK(data != NULL && !data->HasError()); |
| 161 delete data; | 161 delete data; |
| 162 } | 162 } |
| 163 } | 163 } |
| 164 | 164 |
| 165 | 165 |
| 166 class ScriptResource : public v8::String::ExternalAsciiStringResource { | 166 class ScriptResource : public v8::String::ExternalAsciiStringResource { |
| 167 public: | 167 public: |
| 168 ScriptResource(const char* data, size_t length) | 168 ScriptResource(const char* data, size_t length) |
| 169 : data_(data), length_(length) { } | 169 : data_(data), length_(length) { } |
| (...skipping 21 matching lines...) Expand all Loading... |
| 191 "var x = 42;" | 191 "var x = 42;" |
| 192 "function foo(a) { return function nolazy(b) { return a + b; } }" | 192 "function foo(a) { return function nolazy(b) { return a + b; } }" |
| 193 "function bar(a) { if (a) return function lazy(b) { return b; } }" | 193 "function bar(a) { if (a) return function lazy(b) { return b; } }" |
| 194 "var z = {'string': 'string literal', bareword: 'propertyName', " | 194 "var z = {'string': 'string literal', bareword: 'propertyName', " |
| 195 " 42: 'number literal', for: 'keyword as propertyName', " | 195 " 42: 'number literal', for: 'keyword as propertyName', " |
| 196 " f\\u006fr: 'keyword propertyname with escape'};" | 196 " f\\u006fr: 'keyword propertyname with escape'};" |
| 197 "var v = /RegExp Literal/;" | 197 "var v = /RegExp Literal/;" |
| 198 "var w = /RegExp Literal\\u0020With Escape/gin;" | 198 "var w = /RegExp Literal\\u0020With Escape/gin;" |
| 199 "var y = { get getter() { return 42; }, " | 199 "var y = { get getter() { return 42; }, " |
| 200 " set setter(v) { this.value = v; }};"; | 200 " set setter(v) { this.value = v; }};"; |
| 201 int source_length = strlen(source); | 201 int source_length = i::StrLength(source); |
| 202 const char* error_source = "var x = y z;"; | 202 const char* error_source = "var x = y z;"; |
| 203 int error_source_length = strlen(error_source); | 203 int error_source_length = i::StrLength(error_source); |
| 204 | 204 |
| 205 v8::ScriptData* preparse = | 205 v8::ScriptData* preparse = |
| 206 v8::ScriptData::PreCompile(source, source_length); | 206 v8::ScriptData::PreCompile(source, source_length); |
| 207 CHECK(!preparse->HasError()); | 207 CHECK(!preparse->HasError()); |
| 208 bool lazy_flag = i::FLAG_lazy; | 208 bool lazy_flag = i::FLAG_lazy; |
| 209 { | 209 { |
| 210 i::FLAG_lazy = true; | 210 i::FLAG_lazy = true; |
| 211 ScriptResource* resource = new ScriptResource(source, source_length); | 211 ScriptResource* resource = new ScriptResource(source, source_length); |
| 212 v8::Local<v8::String> script_source = v8::String::NewExternal(resource); | 212 v8::Local<v8::String> script_source = v8::String::NewExternal(resource); |
| 213 v8::Script::Compile(script_source, NULL, preparse); | 213 v8::Script::Compile(script_source, NULL, preparse); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 232 i::Scanner::Location error_location = | 232 i::Scanner::Location error_location = |
| 233 pre_impl->MessageLocation(); | 233 pre_impl->MessageLocation(); |
| 234 // Error is at "z" in source, location 10..11. | 234 // Error is at "z" in source, location 10..11. |
| 235 CHECK_EQ(10, error_location.beg_pos); | 235 CHECK_EQ(10, error_location.beg_pos); |
| 236 CHECK_EQ(11, error_location.end_pos); | 236 CHECK_EQ(11, error_location.end_pos); |
| 237 // Should not crash. | 237 // Should not crash. |
| 238 const char* message = pre_impl->BuildMessage(); | 238 const char* message = pre_impl->BuildMessage(); |
| 239 i::Vector<const char*> args = pre_impl->BuildArgs(); | 239 i::Vector<const char*> args = pre_impl->BuildArgs(); |
| 240 CHECK_GT(strlen(message), 0); | 240 CHECK_GT(strlen(message), 0); |
| 241 } | 241 } |
| OLD | NEW |