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

Unified Diff: tools/js2c.py

Issue 411263004: Implement trigonometric functions using a fdlibm port. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: addressed comments Created 6 years, 5 months 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 side-by-side diff with in-line comments
Download patch
« third_party/fdlibm/README.v8 ('K') | « tools/gyp/v8.gyp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/js2c.py
diff --git a/tools/js2c.py b/tools/js2c.py
index 3e56667552721d1b4e478593f67a4bb754fa7a02..9f919d4b3b48b57d1783c2c695090fedd5db81ad 100755
--- a/tools/js2c.py
+++ b/tools/js2c.py
@@ -218,6 +218,27 @@ def ExpandInlineMacros(lines):
lines = ExpandMacroDefinition(lines, pos, name_pattern, macro, non_expander)
+INLINE_CONSTANT_PATTERN = re.compile(r'const\s+([a-zA-Z0-9_]+)\s*=\s*([^\n]+)\n')
+
+def ExpandInlineConstants(lines):
+ pos = 0
+ while True:
+ const_match = INLINE_CONSTANT_PATTERN.search(lines, pos)
+ if const_match is None:
+ # no more constants
+ return lines
+ name = const_match.group(1)
+ replacement = const_match.group(2)
+ name_pattern = re.compile("\\b%s\\b" % name)
+
+ # remove constant definition and replace
+ lines = (lines[:const_match.start()] +
+ re.sub(name_pattern, replacement, lines[const_match.end():]))
+
+ # advance position to where the constant defintion was
+ pos = const_match.start()
+
+
HEADER_TEMPLATE = """\
// Copyright 2011 Google Inc. All Rights Reserved.
@@ -333,6 +354,7 @@ def BuildFilterChain(macro_filename):
filter_chain.extend([
RemoveCommentsAndTrailingWhitespace,
ExpandInlineMacros,
+ ExpandInlineConstants,
Validate,
jsmin.JavaScriptMinifier().JSMinify
])
« third_party/fdlibm/README.v8 ('K') | « tools/gyp/v8.gyp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698