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) |