def _build_function_definition(prototype, header): node = nodes.FunctionDefinition() state = _State() state.constants = prototype.constants state.debuginfo = prototype.debuginfo state.header = header node._upvalues = prototype.constants.upvalue_references node._debuginfo = prototype.debuginfo node._instructions_count = len(prototype.instructions) if prototype.first_line_number: setattr(node, "_lineinfo", (prototype.first_line_number, prototype.lines_count)) node.arguments.contents = _build_function_arguments(state, prototype) if prototype.flags.is_variadic: node.arguments.contents.append(nodes.Vararg()) instructions = prototype.instructions node.statements.contents = _build_function_blocks(state, instructions) return node
def _build_function(state, slot): prototype = state.constants.complex_constants[slot] try: return _build_function_definition(prototype, state.header) except Exception as err: if not handle_invalid_functions: raise err fd = nodes.FunctionDefinition() fd.error = err return fd
def _build_function_definition(prototype, slot_index): node = nodes.FunctionDefinition() state = _State() state.constants = prototype.constants state.debuginfo = prototype.debuginfo state.slot_index = slot_index node._upvalues = prototype.constants.upvalue_references node._debuginfo = prototype.debuginfo node._instructions_count = len(prototype.instructions) node.arguments.contents = _build_function_arguments(state, prototype) if prototype.flags.is_variadic: node.arguments.contents.append(nodes.Vararg()) instructions = prototype.instructions node.statements.contents = _build_function_blocks(state, instructions) return node