Exemplo n.º 1
0
def _get_layouts_and_types(program, layouts_to_compute):
  """A function that computes layouts and type definitions from AST tree."""
  functions_ = functions.get_64bit_functions()
  expression_evaluator = _get_expression_evaluator(functions_)
  type_collector = _get_type_collector(expression_evaluator)
  types = type_collector.collect_types(program)
  types.update(types_module.get_64bit_types())
  layout_computer = _get_layout_computer(expression_evaluator, types)

  def _sizeof(type_name):
    return layout_computer.compute_layout(types[type_name]).bit_size // 8
  functions_['sizeof'] = _sizeof

  layouts = {}
  for name in layouts_to_compute:
    layouts[name] = layout_computer.compute_layout(types[name])

  return layouts, types
Exemplo n.º 2
0
def _get_layouts_and_types(program, layouts_to_compute):
    """A function that computes layouts and type definitions from AST tree."""
    functions_ = functions.get_64bit_functions()
    expression_evaluator = _get_expression_evaluator(functions_)
    type_collector = _get_type_collector(expression_evaluator)
    types = type_collector.collect_types(program)
    types.update(types_module.get_64bit_types())
    layout_computer = _get_layout_computer(expression_evaluator, types)

    def _sizeof(type_name):
        return layout_computer.compute_layout(types[type_name]).bit_size // 8

    functions_['sizeof'] = _sizeof

    layouts = {}
    for name in layouts_to_compute:
        layouts[name] = layout_computer.compute_layout(types[name])

    return layouts, types
Exemplo n.º 3
0
 def setUp(self):
   self.functions = functions.get_64bit_functions()