Code cleanup.
git-svn-id: http://llvm-py.googlecode.com/svn/trunk@47 8d1e9007-1d4e-0410-b67e-1979fd6579aa
This commit is contained in:
parent
b0a11dbbbc
commit
b52355d84e
11 changed files with 588 additions and 212 deletions
40
llvm/core.py
40
llvm/core.py
|
|
@ -1,3 +1,33 @@
|
|||
#
|
||||
# Copyright (c) 2008, Mahadevan R All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
#
|
||||
# * Redistributions of source code must retain the above copyright notice,
|
||||
# this list of conditions and the following disclaimer.
|
||||
#
|
||||
# * Redistributions in binary form must reproduce the above copyright notice,
|
||||
# this list of conditions and the following disclaimer in the documentation
|
||||
# and/or other materials provided with the distribution.
|
||||
#
|
||||
# * Neither the name of this software, nor the names of its
|
||||
# contributors may be used to endorse or promote products derived from
|
||||
# this software without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
|
||||
"""Core classes of LLVM.
|
||||
|
||||
The llvm.core module contains classes and constants required to build the
|
||||
|
|
@ -880,6 +910,8 @@ class Module(llvm.Ownable):
|
|||
return Function.get(self, name)
|
||||
|
||||
def get_or_insert_function(self, ty, name):
|
||||
"""Like get_function_named(), but does add_function() first, if
|
||||
function is not present."""
|
||||
return Function.get_or_insert(self, ty, name)
|
||||
|
||||
@property
|
||||
|
|
@ -1143,6 +1175,7 @@ class FunctionType(Type):
|
|||
|
||||
|
||||
class StructType(Type):
|
||||
"""Represents a structure type."""
|
||||
|
||||
def __init__(self, ptr, kind):
|
||||
"""DO NOT CALL DIRECTLY.
|
||||
|
|
@ -1152,19 +1185,26 @@ class StructType(Type):
|
|||
|
||||
@property
|
||||
def element_count(self):
|
||||
"""Number of elements (members) in the structure.
|
||||
|
||||
Same as len(obj.elements), but faster."""
|
||||
return _core.LLVMCountStructElementTypes(self.ptr)
|
||||
|
||||
@property
|
||||
def elements(self):
|
||||
"""An iterable that yieldsd Type objects, representing the types of the
|
||||
elements (members) of the structure, in order."""
|
||||
pp = _core.LLVMGetStructElementTypes(self.ptr)
|
||||
return [ _make_type(p, _core.LLVMGetTypeKind(p)) for p in pp ]
|
||||
|
||||
@property
|
||||
def packed(self):
|
||||
"""True if the structure is packed, False otherwise."""
|
||||
return _core.LLVMIsPackedStruct(self.ptr) != 0
|
||||
|
||||
|
||||
class ArrayType(Type):
|
||||
"""Represents an array type."""
|
||||
|
||||
def __init__(self, ptr, kind):
|
||||
"""DO NOT CALL DIRECTLY.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue