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

Unified Diff: pnacl/driver/driver_env.py

Issue 454593002: PNaCl driver: Add libgcc to mixed native/bitcode links (Closed) Base URL: svn://svn.chromium.org/native_client/trunk/src/native_client
Patch Set: review, update expr parser to only evaluate ternary operands when needed 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 | « no previous file | pnacl/driver/nativeld.py » ('j') | pnacl/driver/pnacl-driver.py » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pnacl/driver/driver_env.py
diff --git a/pnacl/driver/driver_env.py b/pnacl/driver/driver_env.py
index 043fefe95191c94af6e9d22f4ce0043c4e06bb30..3cae697f1f3ac0a9c7b9fddb8f43387b31af7b44 100755
--- a/pnacl/driver/driver_env.py
+++ b/pnacl/driver/driver_env.py
@@ -50,6 +50,14 @@ INITIAL_ENV = {
'BASE_LIB_X8664' : '${BASE}/lib-bc-x86-64',
'BASE_LIB_ARM' : '${BASE}/lib-bc-arm',
+ 'LIBS_NATIVE_ARCH' : '${LIBS_NATIVE_%ARCH%}',
+ 'LIBS_NATIVE_ARM' : '${BASE_LIB_NATIVE}arm',
+ 'LIBS_NATIVE_ARM_NONSFI' : '${BASE_LIB_NATIVE}arm-nonsfi',
+ 'LIBS_NATIVE_X8632' : '${BASE_LIB_NATIVE}x86-32',
+ 'LIBS_NATIVE_X8632_NONSFI' : '${BASE_LIB_NATIVE}x86-32-nonsfi',
+ 'LIBS_NATIVE_X8664' : '${BASE_LIB_NATIVE}x86-64',
+ 'LIBS_NATIVE_MIPS32' : '${BASE_LIB_NATIVE}mips32',
+
'BASE_LLVM_BIN' : '${BASE_LLVM}/bin',
'TRANSLATOR_BIN' :
'${BASE_TOOLCHAIN}/pnacl_translator/${STANDARD_ARCH}/bin',
@@ -207,6 +215,23 @@ def FindFirst(s, pos, strset):
pos = min(m)
return (m[pos], pos)
+# Find the first instance of a terminating character, skipping over nested
+# brace expressions.
+def FindTerm(s, pos, terminators):
+ depth = 0
+ end = pos
+ for c in s[pos:]:
+ if c == '{':
+ depth += 1
+ elif depth > 0 and c == '}':
+ depth -= 1
+ else:
+ for t in terminators:
+ if s.find(t, end) == end:
+ return end
+ end += 1
+ return end
+
class Environment(object):
functions = {}
@@ -467,12 +492,22 @@ class Environment(object):
(is_cond_true,i) = self.eval_bool_expr(s, pos, ['?']+terminators)
assert(i < len(s) and s[i] == '?')
- (if_true_expr, j) = self.eval_expr(s, i+1, [' : ']+terminators)
+ if is_cond_true:
+ (if_true_expr, j) = self.eval_expr(s, i+1, [' : ']+terminators)
+ else:
+ # Don't evaluate the expr (it won't be used), just find its end.
+ assert terminators[0] == '}'
+ j = FindTerm(s, i+1, [' : '] + terminators)
if j == len(s):
return ('', j) # Error one level up
if s[j:j+3] == ' : ':
- (if_false_expr,j) = self.eval_expr(s, j+3, terminators)
+ if not is_cond_true:
+ (if_false_expr,j) = self.eval_expr(s, j+3, terminators)
+ else:
+ # Don't evaluate the expr (it won't be used), just find its end.
+ assert terminators[0] == '}'
+ j = FindTerm(s, j + 3, terminators)
if j == len(s):
# This is an error condition one level up.
return ('', j)
« no previous file with comments | « no previous file | pnacl/driver/nativeld.py » ('j') | pnacl/driver/pnacl-driver.py » ('J')

Powered by Google App Engine
This is Rietveld 408576698