def _generateStatementSequenceCode(statement_sequence, emit, context):
    if statement_sequence is None:
        return

    for statement in statement_sequence.subnode_statements:
        if shallTraceExecution():
            source_ref = statement.getSourceReference()

            statement_repr = repr(statement)
            source_repr = source_ref.getAsString()

            if python_version >= 0x300:
                statement_repr = statement_repr.encode("utf8")
                source_repr = source_repr.encode("utf8")

            emit(getStatementTrace(source_repr, statement_repr))

        # Might contain frame statement sequences as children.
        if statement.isStatementsFrame():
            from .FrameCodes import generateStatementsFrameCode

            generateStatementsFrameCode(
                statement_sequence=statement, emit=emit, context=context
            )
        else:
            with withSubCollector(emit, context) as statement_emit:
                generateStatementCode(
                    statement=statement, emit=statement_emit, context=context
                )
Пример #2
0
def _generateStatementSequenceCode(statement_sequence, emit, context):
    if statement_sequence is None:
        return

    for statement in statement_sequence.getStatements():
        if shallTraceExecution():
            source_ref = statement.getSourceReference()

            statement_repr = repr(statement)
            source_repr = source_ref.getAsString()

            if python_version >= 300:
                statement_repr = statement_repr.encode("utf8")
                source_repr = source_repr.encode("utf8")

            emit(getStatementTrace(source_repr, statement_repr))

        # Might contain frame statement sequences as children.
        if statement.isStatementsFrame():
            from .FrameCodes import generateStatementsFrameCode

            generateStatementsFrameCode(statement_sequence=statement,
                                        emit=emit,
                                        context=context)
        else:
            context.pushCleanupScope()

            with context.variable_storage.withLocalStorage():
                statement_codes = SourceCodeCollector()

                generateStatementCode(statement=statement,
                                      emit=statement_codes,
                                      context=context)

                statement_declarations = (
                    context.variable_storage.makeCLocalDeclarations())

                block = False
                for s in statement_declarations:
                    if not block:
                        emit("{")

                        block = True
                    emit(indented(s))

                statement_codes.emitTo(emit,
                                       1 if statement_declarations else 0)
                if block:
                    emit("}")

            context.popCleanupScope()
Пример #3
0
def _generateStatementSequenceCode(statement_sequence, emit, context):
    if statement_sequence is None:
        return

    for statement in statement_sequence.getStatements():
        if shallTraceExecution():
            source_ref = statement.getSourceReference()

            statement_repr = repr(statement)
            source_repr = source_ref.getAsString()

            if python_version >= 300:
                statement_repr = statement_repr.encode("utf8")
                source_repr = source_repr.encode("utf8")

            emit(getStatementTrace(source_repr, statement_repr))

        # Might contain frame statement sequences as children.
        if statement.isStatementsFrame():
            from .FrameCodes import generateStatementsFrameCode

            generateStatementsFrameCode(
                statement_sequence=statement, emit=emit, context=context
            )
        else:
            context.pushCleanupScope()

            with context.variable_storage.withLocalStorage():
                statement_codes = SourceCodeCollector()

                generateStatementCode(
                    statement=statement, emit=statement_codes, context=context
                )

                statement_declarations = (
                    context.variable_storage.makeCLocalDeclarations()
                )

                block = False
                for s in statement_declarations:
                    if not block:
                        emit("{")

                        block = True
                    emit(indented(s))

                statement_codes.emitTo(emit, 1 if statement_declarations else 0)
                if block:
                    emit("}")

            context.popCleanupScope()