OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # | 2 # |
3 # Copyright 2012 the V8 project authors. All rights reserved. | 3 # Copyright 2012 the V8 project authors. All rights reserved. |
4 # Redistribution and use in source and binary forms, with or without | 4 # Redistribution and use in source and binary forms, with or without |
5 # modification, are permitted provided that the following conditions are | 5 # modification, are permitted provided that the following conditions are |
6 # met: | 6 # met: |
7 # | 7 # |
8 # * Redistributions of source code must retain the above copyright | 8 # * Redistributions of source code must retain the above copyright |
9 # notice, this list of conditions and the following disclaimer. | 9 # notice, this list of conditions and the following disclaimer. |
10 # * Redistributions in binary form must reproduce the above | 10 # * Redistributions in binary form must reproduce the above |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 file = open(filename, "rt") | 62 file = open(filename, "rt") |
63 try: | 63 try: |
64 lines = file.read() | 64 lines = file.read() |
65 finally: | 65 finally: |
66 file.close() | 66 file.close() |
67 return lines | 67 return lines |
68 | 68 |
69 | 69 |
70 EVAL_PATTERN = re.compile(r'\beval\s*\(') | 70 EVAL_PATTERN = re.compile(r'\beval\s*\(') |
71 WITH_PATTERN = re.compile(r'\bwith\s*\(') | 71 WITH_PATTERN = re.compile(r'\bwith\s*\(') |
72 INVALID_ERROR_MESSAGE_PATTERN = re.compile(r'Make\w*Error\((k\w+),') | 72 INVALID_ERROR_MESSAGE_PATTERN = re.compile(r'Make\w*Error\(([kA-Z]\w+)') |
| 73 NEW_ERROR_PATTERN = re.compile(r'new \$\w*Error\((?!\))'); |
73 | 74 |
74 def Validate(lines): | 75 def Validate(lines): |
75 # Because of simplified context setup, eval and with is not | 76 # Because of simplified context setup, eval and with is not |
76 # allowed in the natives files. | 77 # allowed in the natives files. |
77 if EVAL_PATTERN.search(lines): | 78 if EVAL_PATTERN.search(lines): |
78 raise Error("Eval disallowed in natives.") | 79 raise Error("Eval disallowed in natives.") |
79 if WITH_PATTERN.search(lines): | 80 if WITH_PATTERN.search(lines): |
80 raise Error("With statements disallowed in natives.") | 81 raise Error("With statements disallowed in natives.") |
81 invalid_error = INVALID_ERROR_MESSAGE_PATTERN.search(lines) | 82 invalid_error = INVALID_ERROR_MESSAGE_PATTERN.search(lines) |
82 if invalid_error: | 83 if invalid_error: |
83 raise Error("Unknown error message template '%s'" % invalid_error.group(1)) | 84 raise Error("Unknown error message template '%s'" % invalid_error.group(1)) |
| 85 if NEW_ERROR_PATTERN.search(lines): |
| 86 raise Error("Error constructed without message template.") |
84 # Pass lines through unchanged. | 87 # Pass lines through unchanged. |
85 return lines | 88 return lines |
86 | 89 |
87 | 90 |
88 def ExpandConstants(lines, constants): | 91 def ExpandConstants(lines, constants): |
89 for key, value in constants: | 92 for key, value in constants: |
90 lines = key.sub(str(value), lines) | 93 lines = key.sub(str(value), lines) |
91 return lines | 94 return lines |
92 | 95 |
93 | 96 |
(...skipping 463 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
557 out.cc: C code to be generated. | 560 out.cc: C code to be generated. |
558 type: type parameter for NativesCollection template. | 561 type: type parameter for NativesCollection template. |
559 sources.js: JS internal sources or macros.py.""") | 562 sources.js: JS internal sources or macros.py.""") |
560 (options, args) = parser.parse_args() | 563 (options, args) = parser.parse_args() |
561 | 564 |
562 JS2C(args[2:], args[0], args[1], options.raw, options.startup_blob) | 565 JS2C(args[2:], args[0], args[1], options.raw, options.startup_blob) |
563 | 566 |
564 | 567 |
565 if __name__ == "__main__": | 568 if __name__ == "__main__": |
566 main() | 569 main() |
OLD | NEW |