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

Unified Diff: tools/js2c.py

Issue 448643002: Reland "Implement trigonometric functions using a fdlibm port." (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: fix windows build and gc mole Created 6 years, 4 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
« no previous file with comments | « 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 60f088b7e1da4b1dbfd3c95a6981b17417271173..77485f6e22f5f698cbf7632c3fd7a3972ee6d2c2 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
])
« no previous file with comments | « tools/gyp/v8.gyp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698