Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(11)

Side by Side Diff: tools/js2c.py

Issue 1425333002: Use inline constants instead of typed array for math constants. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/third_party/fdlibm/fdlibm.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 macro = TextMacro(args, body) 235 macro = TextMacro(args, body)
236 236
237 # advance position to where the macro defintion was 237 # advance position to where the macro defintion was
238 pos = macro_match.start() 238 pos = macro_match.start()
239 239
240 def non_expander(s): 240 def non_expander(s):
241 return s 241 return s
242 lines = ExpandMacroDefinition(lines, pos, name_pattern, macro, non_expander) 242 lines = ExpandMacroDefinition(lines, pos, name_pattern, macro, non_expander)
243 243
244 244
245 INLINE_CONSTANT_PATTERN = re.compile(r'define\s+([a-zA-Z0-9_]+)\s*=\s*([^;\n]+)[ ;\n]') 245 INLINE_CONSTANT_PATTERN = re.compile(r'define\s+([a-zA-Z0-9_]+)\s*=\s*([^;\n]+); \n')
246 246
247 def ExpandInlineConstants(lines): 247 def ExpandInlineConstants(lines):
248 pos = 0 248 pos = 0
249 while True: 249 while True:
250 const_match = INLINE_CONSTANT_PATTERN.search(lines, pos) 250 const_match = INLINE_CONSTANT_PATTERN.search(lines, pos)
251 if const_match is None: 251 if const_match is None:
252 # no more constants 252 # no more constants
253 return lines 253 return lines
254 name = const_match.group(1) 254 name = const_match.group(1)
255 replacement = const_match.group(2) 255 replacement = const_match.group(2)
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after
595 JS2C(args[2:], 595 JS2C(args[2:],
596 args[0], 596 args[0],
597 args[1], 597 args[1],
598 options.raw, 598 options.raw,
599 options.startup_blob, 599 options.startup_blob,
600 options.js) 600 options.js)
601 601
602 602
603 if __name__ == "__main__": 603 if __name__ == "__main__":
604 main() 604 main()
OLDNEW
« no previous file with comments | « src/third_party/fdlibm/fdlibm.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698