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 1090 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1101 for (int i = 0; source_data[i].outer_prefix; i++) { | 1101 for (int i = 0; source_data[i].outer_prefix; i++) { |
1102 int kPrefixLen = Utf8LengthHelper(source_data[i].outer_prefix); | 1102 int kPrefixLen = Utf8LengthHelper(source_data[i].outer_prefix); |
1103 int kInnerLen = Utf8LengthHelper(source_data[i].inner_source); | 1103 int kInnerLen = Utf8LengthHelper(source_data[i].inner_source); |
1104 int kSuffixLen = Utf8LengthHelper(source_data[i].outer_suffix); | 1104 int kSuffixLen = Utf8LengthHelper(source_data[i].outer_suffix); |
1105 int kPrefixByteLen = i::StrLength(source_data[i].outer_prefix); | 1105 int kPrefixByteLen = i::StrLength(source_data[i].outer_prefix); |
1106 int kInnerByteLen = i::StrLength(source_data[i].inner_source); | 1106 int kInnerByteLen = i::StrLength(source_data[i].inner_source); |
1107 int kSuffixByteLen = i::StrLength(source_data[i].outer_suffix); | 1107 int kSuffixByteLen = i::StrLength(source_data[i].outer_suffix); |
1108 int kProgramSize = kPrefixLen + kInnerLen + kSuffixLen; | 1108 int kProgramSize = kPrefixLen + kInnerLen + kSuffixLen; |
1109 int kProgramByteSize = kPrefixByteLen + kInnerByteLen + kSuffixByteLen; | 1109 int kProgramByteSize = kPrefixByteLen + kInnerByteLen + kSuffixByteLen; |
1110 i::ScopedVector<char> program(kProgramByteSize + 1); | 1110 i::ScopedVector<char> program(kProgramByteSize + 1); |
1111 i::OS::SNPrintF(program, "%s%s%s", | 1111 i::SNPrintF(program, "%s%s%s", |
1112 source_data[i].outer_prefix, | 1112 source_data[i].outer_prefix, |
1113 source_data[i].inner_source, | 1113 source_data[i].inner_source, |
1114 source_data[i].outer_suffix); | 1114 source_data[i].outer_suffix); |
1115 | 1115 |
1116 // Parse program source. | 1116 // Parse program source. |
1117 i::Handle<i::String> source = factory->NewStringFromUtf8( | 1117 i::Handle<i::String> source = factory->NewStringFromUtf8( |
1118 i::CStrVector(program.start())).ToHandleChecked(); | 1118 i::CStrVector(program.start())).ToHandleChecked(); |
1119 CHECK_EQ(source->length(), kProgramSize); | 1119 CHECK_EQ(source->length(), kProgramSize); |
1120 i::Handle<i::Script> script = factory->NewScript(source); | 1120 i::Handle<i::Script> script = factory->NewScript(source); |
1121 i::CompilationInfoWithZone info(script); | 1121 i::CompilationInfoWithZone info(script); |
1122 i::Parser parser(&info); | 1122 i::Parser parser(&info); |
1123 parser.set_allow_lazy(true); | 1123 parser.set_allow_lazy(true); |
1124 parser.set_allow_harmony_scoping(true); | 1124 parser.set_allow_harmony_scoping(true); |
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1403 for (int k = 0; termination_data[k] != NULL; ++k) { | 1403 for (int k = 0; termination_data[k] != NULL; ++k) { |
1404 int kPrefixLen = i::StrLength(context_data[i][0]); | 1404 int kPrefixLen = i::StrLength(context_data[i][0]); |
1405 int kStatementLen = i::StrLength(statement_data[j]); | 1405 int kStatementLen = i::StrLength(statement_data[j]); |
1406 int kTerminationLen = i::StrLength(termination_data[k]); | 1406 int kTerminationLen = i::StrLength(termination_data[k]); |
1407 int kSuffixLen = i::StrLength(context_data[i][1]); | 1407 int kSuffixLen = i::StrLength(context_data[i][1]); |
1408 int kProgramSize = kPrefixLen + kStatementLen + kTerminationLen | 1408 int kProgramSize = kPrefixLen + kStatementLen + kTerminationLen |
1409 + kSuffixLen + i::StrLength("label: for (;;) { }"); | 1409 + kSuffixLen + i::StrLength("label: for (;;) { }"); |
1410 | 1410 |
1411 // Plug the source code pieces together. | 1411 // Plug the source code pieces together. |
1412 i::ScopedVector<char> program(kProgramSize + 1); | 1412 i::ScopedVector<char> program(kProgramSize + 1); |
1413 int length = i::OS::SNPrintF(program, | 1413 int length = i::SNPrintF(program, |
1414 "label: for (;;) { %s%s%s%s }", | 1414 "label: for (;;) { %s%s%s%s }", |
1415 context_data[i][0], | 1415 context_data[i][0], |
1416 statement_data[j], | 1416 statement_data[j], |
1417 termination_data[k], | 1417 termination_data[k], |
1418 context_data[i][1]); | 1418 context_data[i][1]); |
1419 CHECK(length == kProgramSize); | 1419 CHECK(length == kProgramSize); |
1420 TestParserSync(program.start(), flags1, ARRAY_SIZE(flags1)); | 1420 TestParserSync(program.start(), flags1, ARRAY_SIZE(flags1)); |
1421 } | 1421 } |
1422 } | 1422 } |
1423 } | 1423 } |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1480 } | 1480 } |
1481 for (int i = 0; context_data[i][0] != NULL; ++i) { | 1481 for (int i = 0; context_data[i][0] != NULL; ++i) { |
1482 for (int j = 0; statement_data[j] != NULL; ++j) { | 1482 for (int j = 0; statement_data[j] != NULL; ++j) { |
1483 int kPrefixLen = i::StrLength(context_data[i][0]); | 1483 int kPrefixLen = i::StrLength(context_data[i][0]); |
1484 int kStatementLen = i::StrLength(statement_data[j]); | 1484 int kStatementLen = i::StrLength(statement_data[j]); |
1485 int kSuffixLen = i::StrLength(context_data[i][1]); | 1485 int kSuffixLen = i::StrLength(context_data[i][1]); |
1486 int kProgramSize = kPrefixLen + kStatementLen + kSuffixLen; | 1486 int kProgramSize = kPrefixLen + kStatementLen + kSuffixLen; |
1487 | 1487 |
1488 // Plug the source code pieces together. | 1488 // Plug the source code pieces together. |
1489 i::ScopedVector<char> program(kProgramSize + 1); | 1489 i::ScopedVector<char> program(kProgramSize + 1); |
1490 int length = i::OS::SNPrintF(program, | 1490 int length = i::SNPrintF(program, |
1491 "%s%s%s", | 1491 "%s%s%s", |
1492 context_data[i][0], | 1492 context_data[i][0], |
1493 statement_data[j], | 1493 statement_data[j], |
1494 context_data[i][1]); | 1494 context_data[i][1]); |
1495 CHECK(length == kProgramSize); | 1495 CHECK(length == kProgramSize); |
1496 TestParserSync(program.start(), | 1496 TestParserSync(program.start(), |
1497 flags, | 1497 flags, |
1498 flags_len, | 1498 flags_len, |
1499 result); | 1499 result); |
1500 } | 1500 } |
1501 } | 1501 } |
1502 } | 1502 } |
1503 | 1503 |
1504 | 1504 |
(...skipping 1038 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2543 v8::Local<v8::String> source = | 2543 v8::Local<v8::String> source = |
2544 v8::String::NewFromTwoByte(isolate, two_byte_source); | 2544 v8::String::NewFromTwoByte(isolate, two_byte_source); |
2545 v8::Local<v8::Value> result = CompileRun(source); | 2545 v8::Local<v8::Value> result = CompileRun(source); |
2546 CHECK(result->IsString()); | 2546 CHECK(result->IsString()); |
2547 v8::Local<v8::String> expected_name = | 2547 v8::Local<v8::String> expected_name = |
2548 v8::String::NewFromTwoByte(isolate, two_byte_name); | 2548 v8::String::NewFromTwoByte(isolate, two_byte_name); |
2549 CHECK(result->Equals(expected_name)); | 2549 CHECK(result->Equals(expected_name)); |
2550 i::DeleteArray(two_byte_source); | 2550 i::DeleteArray(two_byte_source); |
2551 i::DeleteArray(two_byte_name); | 2551 i::DeleteArray(two_byte_name); |
2552 } | 2552 } |
OLD | NEW |