~ubuntu-branches/debian/experimental/nuitka/experimental

« back to all changes in this revision

Viewing changes to nuitka/codegen/ConstantCodes.py

  • Committer: Package Import Robot
  • Author(s): Kay Hayen
  • Date: 2015-04-06 17:20:44 UTC
  • mfrom: (1.1.37)
  • Revision ID: package-import@ubuntu.com-20150406172044-grhy9sk7g0whu2ag
Tags: 0.5.12+ds-1
New upstream release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
288
288
    if constant_identifier in done:
289
289
        return
290
290
 
 
291
    if Options.shallTraceExecution():
 
292
        emit("""puts("Creating constant: %s");""" % constant_identifier)
 
293
 
291
294
    # Then it's a real named constant not yet created.
292
295
    __addConstantInitCode(context, emit, check, constant_type, constant_value,
293
296
                          constant_identifier, module_level)
367
370
            # MININT when used. We work around that warning here.
368
371
            emit(
369
372
                """\
370
 
%s = PyLong_FromLong( %sl ); // To be corrected in next line.
 
373
%s = PyLong_FromLong( %sl ); // To be corrected with -1 in-place next lines.
 
374
CHECK_OBJECT( const_int_pos_1 );
371
375
%s = PyNumber_InPlaceSubtract( %s, const_int_pos_1 );""" % (
372
376
                    constant_identifier,
373
377
                    min_signed_long,
741
745
 
742
746
    check = SourceCodeCollector()
743
747
 
744
 
    # Sort items by length and name, so we are determistic and pretty.
 
748
    # Sort items by length and name, so we are deterministic and pretty.
745
749
    sorted_constants = sorted(
746
750
        iterItems(context.getConstants()),
747
 
        key = lambda k: (len(k), k )
 
751
        key = lambda k: (len(k[0]), k[0])
748
752
    )
749
753
 
750
754
    for constant_identifier, constant_value in sorted_constants:
764
768
def getConstantsDeclCode(context):
765
769
    statements = []
766
770
 
767
 
    # Sort items by length and name, so we are determistic and pretty.
 
771
    # Sort items by length and name, so we are deterministic and pretty.
768
772
    sorted_constants = sorted(
769
773
        iterItems(context.getConstants()),
770
 
        key = lambda k: (len(k), k )
 
774
        key = lambda k: (len(k[0]), k[0])
771
775
    )
772
776
 
773
777
    for constant_identifier, constant_value in sorted_constants:
917
921
 
918
922
    sorted_constants = sorted(
919
923
        module_context.getConstants(),
920
 
        key = lambda k: (len(k), k)
 
924
        key = lambda k: (len(k[0]), k[0])
921
925
    )
922
926
 
923
927
    global_context = module_context.global_context