Skip to content

Commit

Permalink
Minor changes
Browse files Browse the repository at this point in the history
  • Loading branch information
bksahu committed Aug 22, 2019
1 parent bc898b2 commit c7ff21d
Show file tree
Hide file tree
Showing 4 changed files with 182 additions and 149 deletions.
13 changes: 13 additions & 0 deletions nuitka/build/static_src/HelpersBuiltin.c
Expand Up @@ -253,6 +253,19 @@ PyObject *BUILTIN_STATICMETHOD(PyObject *value) {
return CALL_FUNCTION_WITH_SINGLE_ARG(NUITKA_ACCESS_BUILTIN(staticmethod), value);
}

/** The "zip" built-in.
*
**/

NUITKA_DEFINE_BUILTIN(zip)

PyObject *BUILTIN_ZIP(PyObject *value) {
NUITKA_ASSIGN_BUILTIN(zip);

return CALL_FUNCTION_WITH_SINGLE_ARG(NUITKA_ACCESS_BUILTIN(zip), value);
}


/** The "classmethod" built-in.
*
**/
Expand Down
31 changes: 24 additions & 7 deletions nuitka/codegen/BuiltinCodes.py
Expand Up @@ -30,6 +30,7 @@
)
from .ErrorCodes import getAssertionCode, getErrorExitBoolCode, getErrorExitCode
from .PythonAPICodes import generateCAPIObjectCode
from .TupleCodes import getTupleCreationCode


def generateBuiltinAbsCode(to_name, expression, emit, context):
Expand Down Expand Up @@ -434,13 +435,29 @@ def generateBuiltinClassmethodCode(to_name, expression, emit, context):


def generateBuiltinZipCode(to_name, expression, emit, context):
generateCAPIObjectCode(
to_name=to_name,
capi="BUILTIN_ZIP", # TODO: Write C code
arg_desc=(("zip_arg", expression.getValue()),),
may_raise=expression.mayRaiseException(BaseException),
conversion_check=decideConversionCheckNeeded(to_name, expression),
source_ref=expression.getCompatibleSourceReference(),
tmp_zip_args_name = context.allocateTempName("zip_args")

getTupleCreationCode(
to_name=tmp_zip_args_name,
elements=expression.getValue(),
emit=emit,
context=context,
)

# TODO: Create BUILTIN_ZIP that passes args to
# CALL_FUNCTION_WITH_POSARGS of builtin zip.

with withObjectCodeTemporaryAssignment(
to_name, "zip_value", expression, emit, context
) as value_name:
emit("%s = BUILTIN_ZIP(%s);" % (value_name, tmp_zip_args_name))

getErrorExitCode(
check_name=value_name,
release_name=tmp_zip_args_name,
needs_check=expression.mayRaiseException(BaseException),
emit=emit,
context=context,
)

context.addCleanupTempName(value_name)
6 changes: 6 additions & 0 deletions nuitka/nodes/BuiltinZipNodes.py
Expand Up @@ -29,6 +29,8 @@
)


# TODO: Add support for generator outlines and
# remove this node entirely.
class ExpressionBuiltinZip(ExpressionChildHavingBase):
kind = "EXPRESSION_BUILTIN_ZIP"

Expand Down Expand Up @@ -58,3 +60,7 @@ def computeExpression(self, trace_collection):
# [1,2,3] -> (1,2,3)

return self, None, None

# TODO: We should have an iteration handle.
# Length and values might be possible to predict
# if every argument iteration handle is capable of it.

0 comments on commit c7ff21d

Please sign in to comment.