Skip to content

Commit e263c1d

Browse files
committed
Fix E302: expected 2 blank lines, found 1
1 parent da3ba19 commit e263c1d

94 files changed

Lines changed: 337 additions & 0 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

nativepython/codebase_compiler.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626

2727
typeWrapper = lambda t: python_to_native_converter.typedPythonTypeToTypeWrapper(t)
2828

29+
2930
class CompiledCodebase:
3031
def __init__(self, codebase, sharedObject, nativeTargets, typedTargets):
3132
self.codebase = codebase
@@ -51,6 +52,7 @@ def install(self):
5152
[i.typeRepresentation for i in callTarget.input_types]
5253
)
5354

55+
5456
class CodebaseCompiler:
5557
def __init__(self, codebase):
5658
self.codebase = codebase

nativepython/conversion_exception.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,6 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15+
1516
class ConversionException(Exception):
1617
pass

nativepython/expression_conversion_context.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
StackSlot={"name": str, "expr": native_ast.Expression}
3838
)
3939

40+
4041
class ExpressionConversionContext(object):
4142
"""Context class when we're converting a single compound expression.
4243

nativepython/function_conversion_context.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,11 @@
2929

3030
typeWrapper = lambda t: nativepython.python_object_representation.typedPythonTypeToTypeWrapper(t)
3131

32+
3233
class FunctionOutput:
3334
pass
3435

36+
3537
class FunctionConversionContext(object):
3638
"""Helper function for converting a single python function."""
3739
def __init__(self, converter, identity, ast_arg, statements, input_types, output_type, free_variable_lookup):

nativepython/llvm_compiler.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949

5050
assert pointer_size == native_ast_to_llvm.pointer_size
5151

52+
5253
def sizeof_native_type(native_type):
5354
if native_type.matches.Void:
5455
return 0
@@ -60,6 +61,8 @@ def sizeof_native_type(native_type):
6061

6162
#there can be only one llvm engine alive at once.
6263
_engineCache = []
64+
65+
6366
def create_execution_engine():
6467
if _engineCache:
6568
return _engineCache[0]
@@ -80,6 +83,7 @@ def create_execution_engine():
8083

8184
return engine, pass_manager
8285

86+
8387
class NativeFunctionPointer:
8488
def __init__(self, fname, fp, input_types, output_type):
8589
self.fp = fp
@@ -91,6 +95,7 @@ def __repr__(self):
9195
return "NativeFunctionPointer(name=%s,addr=%x,in=%s,out=%s)" \
9296
% (self.fname, self.fp, [str(x) for x in self.input_types], str(self.output_type))
9397

98+
9499
class BinarySharedObject:
95100
"""Models a shared object library (.so) loadable on linux systems."""
96101
def __init__(self, binaryForm):

nativepython/native_ast.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,18 @@
1515
from typed_python import *
1616
import textwrap
1717

18+
1819
def indent(x, indentBy=" "):
1920
return textwrap.indent(str(x), indentBy)
2021

22+
2123
def type_attr_ix(t, attr):
2224
for i in range(len(t.element_types)):
2325
if t.element_types[i][0] == attr:
2426
return i
2527
return None
2628

29+
2730
def type_str(c):
2831
if c.matches.Function:
2932
return "func((%s)->%s%s)" % (
@@ -48,6 +51,7 @@ def type_str(c):
4851

4952
assert False, type(c)
5053

54+
5155
def raising(e):
5256
raise e
5357

@@ -78,6 +82,7 @@ def const_truth_value(c):
7882
return c.val != 0
7983
return False
8084

85+
8186
def const_str(c):
8287
if c.matches.Float:
8388
if c.bits == 64:
@@ -163,6 +168,7 @@ def const_str(c):
163168
can_throw=bool
164169
)
165170

171+
166172
def filterCallTargetArgs(args):
167173
"""Given a list of native expressions or typed expressions, filter them down,
168174
dropping 'empty' arguments, as per our calling convention."""
@@ -190,6 +196,7 @@ def filterCallTargetArgs(args):
190196
call=lambda self, *args: Expression.Call(target=self, args=filterCallTargetArgs(args))
191197
)
192198

199+
193200
def teardown_str(self):
194201
if self.matches.Always:
195202
return str(self.expr)
@@ -203,6 +210,7 @@ def teardown_str(self):
203210
__str__=teardown_str
204211
)
205212

213+
206214
def expr_concatenate(self, other):
207215
if self.matches.Constant:
208216
return other
@@ -326,6 +334,7 @@ def expr_str(self):
326334

327335
assert False
328336

337+
329338
def expr_is_simple(expr):
330339
if expr.matches.StackSlot:
331340
return True
@@ -440,35 +449,43 @@ def ensureExpr(x):
440449
trueExpr = Expression.Constant(val=Constant.Int(bits=1, val=1, signed=False))
441450
falseExpr = Expression.Constant(val=Constant.Int(bits=1, val=0, signed=False))
442451

452+
443453
def const_float_expr(f):
444454
return Expression.Constant(
445455
val=Constant.Float(bits=64, val=f)
446456
)
447457

458+
448459
def const_int_expr(i):
449460
return Expression.Constant(
450461
val=Constant.Int(bits=64, val=i, signed=True)
451462
)
452463

464+
453465
def const_int32_expr(i):
454466
return Expression.Constant(
455467
val=Constant.Int(bits=32, val=i, signed=True)
456468
)
457469

470+
458471
def const_uint8_expr(i):
459472
return Expression.Constant(
460473
val=Constant.Int(bits=8, val=i, signed=False)
461474
)
462475

476+
463477
def const_bool_expr(i):
464478
return Expression.Constant(
465479
val=Constant.Int(bits=1, val=i, signed=False)
466480
)
467481

482+
468483
def const_utf8_cstr(i):
469484
return Expression.Constant(
470485
val=Constant.ByteArray(val=i.encode('utf-8'))
471486
)
487+
488+
472489
def const_bytes_cstr(i):
473490
return Expression.Constant(
474491
val=Constant.ByteArray(val=i)
@@ -495,5 +512,6 @@ def const_bytes_cstr(i):
495512
Int64 = Type.Int(bits=64, signed=True)
496513
Int32 = Type.Int(bits=32, signed=True)
497514

515+
498516
def var(name):
499517
return Expression.Variable(name=name)

nativepython/native_ast_to_llvm.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,17 @@
2727
#just hardcoded for now. We check this in the compiler to ensure it's consistent.
2828
pointer_size = 8
2929

30+
3031
def llvm_bool(i):
3132
return llvmlite.ir.Constant(llvm_i1, i)
3233

34+
3335
def assertTagDictsSame(left_tags, right_tags):
3436
for which in [left_tags, right_tags]:
3537
for tag in which:
3638
assert tag in left_tags and tag in right_tags and right_tags[tag] is left_tags[tag], "Tag %s is not the same" % tag
3739

40+
3841
def type_to_llvm_type(t):
3942
if t.matches.Void:
4043
return llvmlite.ir.VoidType()
@@ -73,6 +76,8 @@ def type_to_llvm_type(t):
7376
assert False, "Can't handle %s yet" % t
7477

7578
strings_ever = [0]
79+
80+
7681
def constant_to_typed_llvm_value(module, builder, c):
7782
if c.matches.Float and c.bits == 64:
7883
return TypedLLVMValue(
@@ -132,6 +137,7 @@ def constant_to_typed_llvm_value(module, builder, c):
132137

133138
assert False, c
134139

140+
135141
class TypedLLVMValue(object):
136142
def __init__(self, llvm_value, native_type):
137143
object.__init__(self)
@@ -152,6 +158,7 @@ def __str__(self):
152158
def __repr__(self):
153159
return str(self)
154160

161+
155162
class TeardownOnScopeExit:
156163
def __init__(self, converter, parent_scope):
157164
self.converter = converter
@@ -337,6 +344,7 @@ def generate_trycatch_unwind(self, target_resume_block, generator):
337344

338345
generator(tags, target_resume_block)
339346

347+
340348
class FunctionConverter:
341349
def __init__(self,
342350
module,
@@ -1100,6 +1108,7 @@ def generate_teardowns(new_tags):
11001108

11011109
assert False, "can't handle %s" % repr(expr)
11021110

1111+
11031112
def populate_needed_externals(external_function_references, module):
11041113
def define(fname, output, inputs, vararg=False):
11051114
external_function_references[fname] = \
@@ -1118,6 +1127,7 @@ def define(fname, output, inputs, vararg=False):
11181127
define("__cxa_begin_catch", llvm_i8ptr, [llvm_i8ptr])
11191128
define("__gxx_personality_v0", llvm_i32, [], vararg=True)
11201129

1130+
11211131
class Converter(object):
11221132
def __init__(self):
11231133
object.__init__(self)

nativepython/native_ast_to_llvm_test.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ def externalCallTarget(name, output, *inputs):
3232
)
3333
)
3434

35+
3536
class TestNativeAstToLlvm(unittest.TestCase):
3637
def test_teardowns(self):
3738
converter = native_ast_to_llvm.Converter()

nativepython/python_object_representation.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,13 @@
2929

3030
_type_to_type_wrapper_cache = {}
3131

32+
3233
def typedPythonTypeToTypeWrapper(t):
3334
if t not in _type_to_type_wrapper_cache:
3435
_type_to_type_wrapper_cache[t] = _typedPythonTypeToTypeWrapper(t)
3536
return _type_to_type_wrapper_cache[t]
3637

38+
3739
def _typedPythonTypeToTypeWrapper(t):
3840
if isinstance(t, Wrapper):
3941
return t
@@ -103,6 +105,7 @@ def _typedPythonTypeToTypeWrapper(t):
103105

104106
assert False, t
105107

108+
106109
def pythonObjectRepresentation(context, f):
107110
if f is len:
108111
return TypedExpression(context, native_ast.nullExpr, LenWrapper(), False)

nativepython/python_to_native_converter.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030

3131
typeWrapper = lambda t: nativepython.python_object_representation.typedPythonTypeToTypeWrapper(t)
3232

33+
3334
class NativeFunctionConversionContext:
3435
def __init__(self, converter, input_types, output_type, generatingFunction):
3536
self.varnames = 0
@@ -118,6 +119,7 @@ def __str__(self):
118119
str(self.output_type)
119120
)
120121

122+
121123
class PythonToNativeConverter(object):
122124
def __init__(self):
123125
object.__init__(self)

0 commit comments

Comments
 (0)