def test_with_chained_typedef_references_ended_by_unresolvable_type(self):
     some_type = c_ast.CSimpleType(33, 42)
     some_other_type = c_ast.CSimpleType(42, 33)
     type_1_t = c_ast.CTypedef(
         name='type_1_t',
         type_definition=c_ast.CTypeReference('some_type'),
     )
     type_2_t = c_ast.CTypedef(
         name='type_2_t',
         type_definition=c_ast.CTypeReference('type_1_t'),
     )
     type_3_t = c_ast.CTypedef(
         name='type_3_t',
         type_definition=c_ast.CTypeReference('type_2_t'),
     )
     self.types.update({
         'some_type': some_type,
         'some_other_type': some_other_type,
         'type_1_t': type_1_t,
         'type_2_t': type_2_t,
         'type_3_t': type_3_t,
     })
     node = c_ast.CTypeReference('type_3_t')
     actual = self.typedef_resolving_visitor.resolve(node, self.types)
     expected = c_ast.CTypeReference('some_type')
     self.assertEqual(actual, expected)
 def test_resolve_with_type_reference_with_unresolvable_definition(self):
     self.types.update({
         'some_type_name': c_ast.CSimpleType(33, 42),
     })
     node = c_ast.CTypeReference('some_type_name')
     actual = self.typedef_resolving_visitor.resolve(node, self.types)
     self.assertEqual(actual, node)
 def test_resolve_with_typedef_with_unresolvable_type(self):
     other_type_reference = c_ast.CSimpleType(33, 42)
     node = c_ast.CTypedef(
         name='some_name',
         type_definition=other_type_reference,
     )
     actual = self.typedef_resolving_visitor.resolve(node, self.types)
     self.assertIsNone(actual)
예제 #4
0
 def test_get_64bit_types_with_ints(self):
     ints = [
         'int',
         'unsigned',
         'unsigned int',
         'signed',
         'signed int',
     ]
     for type_name in ints:
         actual = self.types[type_name]
         expected = c_ast.CSimpleType(32, 32)
         self.assertEqual(actual, expected)
예제 #5
0
 def test_get_64bit_types_with_long_longs(self):
     long_longs = [
         'long long',
         'unsigned long long',
         'signed long long',
         'long long int',
         'unsigned long long int',
         'signed long long int',
     ]
     for type_name in long_longs:
         actual = self.types[type_name]
         expected = c_ast.CSimpleType(64, 64)
         self.assertEqual(actual, expected)
예제 #6
0
 def test_get_64bit_types_with_shorts(self):
     shorts = [
         'short',
         'unsigned short',
         'signed short',
         'short int',
         'unsigned short int',
         'signed short int',
     ]
     for type_name in shorts:
         actual = self.types[type_name]
         expected = c_ast.CSimpleType(16, 16)
         self.assertEqual(actual, expected)
예제 #7
0
 def test_get_64_bit_types_with_size_t(self):
     actual = self.types['size_t']
     expected = c_ast.CSimpleType(64, 64)
     self.assertEqual(actual, expected)
예제 #8
0
 def test_get_64bit_types_with_bool(self):
     actual = self.types['_Bool']
     expected = c_ast.CSimpleType(8, 8)
     self.assertEqual(actual, expected)
예제 #9
0
 def test_get_64bit_types_with_chars(self):
     for type_name in 'char', 'unsigned char', 'signed char':
         actual = self.types[type_name]
         expected = c_ast.CSimpleType(8, 8)
         self.assertEqual(actual, expected)
예제 #10
0
파일: types.py 프로젝트: tklengyel/rekall
def get_64bit_types():
  """A functions returns a dict with type definitions for LP64 model.

  Verified with 64bit GCC.

  Returns:
    A dict from type names to type definitions  for LP64 model.
  """
  # Not perfect! Spaces should not be important!
  return {
      'char': c_ast.CSimpleType(8, 8),
      'unsigned char': c_ast.CSimpleType(8, 8),
      'signed char': c_ast.CSimpleType(8, 8),

      'short': c_ast.CSimpleType(16, 16),
      'unsigned short': c_ast.CSimpleType(16, 16),
      'signed short': c_ast.CSimpleType(16, 16),
      'short int': c_ast.CSimpleType(16, 16),
      'unsigned short int': c_ast.CSimpleType(16, 16),
      'signed short int': c_ast.CSimpleType(16, 16),

      'int': c_ast.CSimpleType(32, 32),
      'unsigned': c_ast.CSimpleType(32, 32),
      'unsigned int': c_ast.CSimpleType(32, 32),
      'signed': c_ast.CSimpleType(32, 32),
      'signed int': c_ast.CSimpleType(32, 32),

      'long': c_ast.CSimpleType(64, 64),
      'unsigned long': c_ast.CSimpleType(64, 64),
      'signed long': c_ast.CSimpleType(64, 64),
      'long int': c_ast.CSimpleType(64, 64),
      'unsigned long int': c_ast.CSimpleType(64, 64),
      'signed long int': c_ast.CSimpleType(64, 64),

      'long long': c_ast.CSimpleType(64, 64),
      'unsigned long long': c_ast.CSimpleType(64, 64),
      'signed long long': c_ast.CSimpleType(64, 64),
      'long long int': c_ast.CSimpleType(64, 64),
      'unsigned long long int': c_ast.CSimpleType(64, 64),
      'signed long long int': c_ast.CSimpleType(64, 64),

      '_Bool': c_ast.CSimpleType(8, 8),
      'size_t': c_ast.CSimpleType(64, 64),
  }
 def test_resolve_with_simple_type(self):
     node = c_ast.CSimpleType(33, 42)
     actual = self.typedef_resolving_visitor.resolve(node, self.types)
     self.assertIsNone(actual)