| 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\(([kA-Z]\w+)') | 72 INVALID_ERROR_MESSAGE_PATTERN = re.compile( |
| 73 NEW_ERROR_PATTERN = re.compile(r'new \$\w*Error\((?!\))'); | 73 r'Make(?!Generic)\w*Error\(([kA-Z]\w+)') |
| 74 NEW_ERROR_PATTERN = re.compile(r'new \$\w*Error\((?!\))') |
| 74 | 75 |
| 75 def Validate(lines): | 76 def Validate(lines): |
| 76 # Because of simplified context setup, eval and with is not | 77 # Because of simplified context setup, eval and with is not |
| 77 # allowed in the natives files. | 78 # allowed in the natives files. |
| 78 if EVAL_PATTERN.search(lines): | 79 if EVAL_PATTERN.search(lines): |
| 79 raise Error("Eval disallowed in natives.") | 80 raise Error("Eval disallowed in natives.") |
| 80 if WITH_PATTERN.search(lines): | 81 if WITH_PATTERN.search(lines): |
| 81 raise Error("With statements disallowed in natives.") | 82 raise Error("With statements disallowed in natives.") |
| 82 invalid_error = INVALID_ERROR_MESSAGE_PATTERN.search(lines) | 83 invalid_error = INVALID_ERROR_MESSAGE_PATTERN.search(lines) |
| 83 if invalid_error: | 84 if invalid_error: |
| (...skipping 476 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 560 out.cc: C code to be generated. | 561 out.cc: C code to be generated. |
| 561 type: type parameter for NativesCollection template. | 562 type: type parameter for NativesCollection template. |
| 562 sources.js: JS internal sources or macros.py.""") | 563 sources.js: JS internal sources or macros.py.""") |
| 563 (options, args) = parser.parse_args() | 564 (options, args) = parser.parse_args() |
| 564 | 565 |
| 565 JS2C(args[2:], args[0], args[1], options.raw, options.startup_blob) | 566 JS2C(args[2:], args[0], args[1], options.raw, options.startup_blob) |
| 566 | 567 |
| 567 | 568 |
| 568 if __name__ == "__main__": | 569 if __name__ == "__main__": |
| 569 main() | 570 main() |
| OLD | NEW |