~yolanda.robla/ubuntu/trusty/nodejs/add_distribution

« back to all changes in this revision

Viewing changes to deps/v8/tools/js2c.py

  • Committer: Package Import Robot
  • Author(s): Jérémy Lal
  • Date: 2013-08-14 00:16:46 UTC
  • mfrom: (7.1.40 sid)
  • Revision ID: package-import@ubuntu.com-20130814001646-bzlysfh8sd6mukbo
Tags: 0.10.15~dfsg1-4
* Update 2005 patch, adding a handful of tests that can fail on
  slow platforms.
* Add 1004 patch to fix test failures when writing NaN to buffer
  on mipsel.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
#!/usr/bin/env python
2
2
#
3
 
# Copyright 2006-2008 the V8 project authors. All rights reserved.
 
3
# Copyright 2012 the V8 project authors. All rights reserved.
4
4
# Redistribution and use in source and binary forms, with or without
5
5
# modification, are permitted provided that the following conditions are
6
6
# met:
128
128
      end = pattern_match.end()
129
129
      assert lines[end - 1] == '('
130
130
      last_match = end
131
 
      arg_index = 0
 
131
      arg_index = [0]  # Wrap state into array, to work around Python "scoping"
132
132
      mapping = { }
133
133
      def add_arg(str):
134
134
        # Remember to expand recursively in the arguments
135
135
        replacement = ExpandMacros(str.strip(), macros)
136
 
        mapping[macro.args[arg_index]] = replacement
 
136
        mapping[macro.args[arg_index[0]]] = replacement
 
137
        arg_index[0] += 1
137
138
      while end < len(lines) and height > 0:
138
139
        # We don't count commas at higher nesting levels.
139
140
        if lines[end] == ',' and height == 1:
194
195
      macro_match = MACRO_PATTERN.match(line)
195
196
      if macro_match:
196
197
        name = macro_match.group(1)
197
 
        args = map(string.strip, macro_match.group(2).split(','))
 
198
        args = [match.strip() for match in macro_match.group(2).split(',')]
198
199
        body = macro_match.group(3).strip()
199
200
        macros.append((re.compile("\\b%s\\(" % name), TextMacro(args, body)))
200
201
      else:
201
202
        python_match = PYTHON_MACRO_PATTERN.match(line)
202
203
        if python_match:
203
204
          name = python_match.group(1)
204
 
          args = map(string.strip, python_match.group(2).split(','))
 
205
          args = [match.strip() for match in python_match.group(2).split(',')]
205
206
          body = python_match.group(3).strip()
206
207
          fun = eval("lambda " + ",".join(args) + ': ' + body)
207
208
          macros.append((re.compile("\\b%s\\(" % name), PythonMacro(args, fun)))