Convert a list of Instruction objects to a list of AST body nodes.
354061
def instrs_to_body(instrs, context):
    
    stack = []
    body = []
    process_instrs(instrs, stack, body, context)

    if stack:
        raise DecompilationError(
            "Non-empty stack at the end of instrs_to_body(): %s." % stack
        )
    return body
893407
def set_instructions(self, instructions):
        
        if self.code == None:
            return []
        return self.code.get_bc().set_instructions(instructions)
440877
@Override
  protected PyExpr visitListLiteralNode(ListLiteralNode node) {
    return PyExprUtils.convertIterableToPyListExpr(
        node.getChildren().stream().map(n -> visit(n)).collect(Collectors.toList()));
  }
907753
function convertFakeListsToProperLists(node) {
          var currentListNode, prevListNode, lastLevel = 1;

          function getText(node) {
            var txt = '';

            if (node.type === 3) {
              return node.value;
            }

            if ((node = node.firstChild)) {
              do {
                txt += getText(node);
              } while ((node = node.next));
            }

            return txt;
          }

          function trimListStart(node, regExp) {
            if (node.type === 3) {
              if (regExp.test(node.value)) {
                node.value = node.value.replace(regExp, '');
                return false;
              }
            }

            if ((node = node.firstChild)) {
              do {
                if (!trimListStart(node, regExp)) {
                  return false;
                }
              } while ((node = node.next));
            }

            return true;
          }

          function removeIgnoredNodes(node) {
            if (node._listIgnore) {
              node.remove();
              return;
            }

            if ((node = node.firstChild)) {
              do {
                removeIgnoredNodes(node);
              } while ((node = node.next));
            }
          }

          function convertParagraphToLi(paragraphNode, listName, start) {
            var level = paragraphNode._listLevel || lastLevel;

            // Handle list nesting
            if (level != lastLevel) {
              if (level < lastLevel) {
                // Move to parent list
                if (currentListNode) {
                  currentListNode = currentListNode.parent.parent;
                }
              } else {
                // Create new list
                prevListNode = currentListNode;
                currentListNode = null;
              }
            }

            if (!currentListNode || currentListNode.name != listName) {
              prevListNode = prevListNode || currentListNode;
              currentListNode = new Node(listName, 1);

              if (start > 1) {
                currentListNode.attr('start', '' + start);
              }

              paragraphNode.wrap(currentListNode);
            } else {
              currentListNode.append(paragraphNode);
            }

            paragraphNode.name = 'li';

            // Append list to previous list if it exists
            if (level > lastLevel && prevListNode) {
              prevListNode.lastChild.append(currentListNode);
            }

            lastLevel = level;

            // Remove start of list item "1. " or "&middot; " etc
            removeIgnoredNodes(paragraphNode);
            trimListStart(paragraphNode, /^\u00a0+/);
            trimListStart(paragraphNode, /^\s*([\u2022\u00b7\u00a7\u25CF]|\w+\.)/);
            trimListStart(paragraphNode, /^\u00a0+/);
          }

          // Build a list of all root level elements before we start
          // altering them in the loop below.
          var elements = [], child = node.firstChild;
          while (typeof child !== 'undefined' && child !== null) {
            elements.push(child);

            child = child.walk();
            if (child !== null) {
              while (typeof child !== 'undefined' && child.parent !== node) {
                child = child.walk();
              }
            }
          }

          for (var i = 0; i < elements.length; i++) {
            node = elements[i];

            if (node.name == 'p' && node.firstChild) {
              // Find first text node in paragraph
              var nodeText = getText(node);

              // Detect unordered lists look for bullets
              if (isBulletList(nodeText)) {
                convertParagraphToLi(node, 'ul');
                continue;
              }

              // Detect ordered lists 1., a. or ixv.
              if (isNumericList(nodeText)) {
                // Parse OL start number
                var matches = /([0-9]+)\./.exec(nodeText);
                var start = 1;
                if (matches) {
                  start = parseInt(matches[1], 10);
                }

                convertParagraphToLi(node, 'ol', start);
                continue;
              }

              // Convert paragraphs marked as lists but doesn't look like anything
              if (node._listLevel) {
                convertParagraphToLi(node, 'ul', 1);
                continue;
              }

              currentListNode = null;
            } else {
              // If the root level element isn't a p tag which can be
              // processed by convertParagraphToLi, it interrupts the
              // lists, causing a new list to start instead of having
              // elements from the next list inserted above this tag.
              prevListNode = currentListNode;
              currentListNode = null;
            }
          }
        }
880293
def _to_list(sc, cols, converter=None):
    
    if converter:
        cols = [converter(c) for c in cols]
    return sc._jvm.PythonUtils.toList(cols)
1227024
def transform_dot(self, node, results):
        """"""
        module_dot = results.get("bare_with_attr")
        member = results.get("member")
        new_name = None
        if isinstance(member, list):
            member = member[0]
        for change in MAPPING[module_dot.value]:
            if member.value in change[1]:
                new_name = change[0]
                break
        if new_name:
            module_dot.replace(Name(new_name,
                                    prefix=module_dot.prefix))
        else:
            self.cannot_convert(node, "This is an invalid module element")
492197
def build_body(cls: Type[AN], body: List[ast.stmt]) -> List:
        
        act_nodes = []  # type: List[ActNode]
        for child_node in body:
            act_nodes += ActNode.build(child_node)
        return act_nodes
85210
def _as_list(obj):
    """"""
    if obj is None:
        return None
    elif isinstance(obj, string_types):
        return [obj]
    elif isinstance(obj, tuple):
        return list(obj)
    elif not hasattr(obj, '__len__'):
        return [obj]
    else:
        return obj
142462
def convert_the_getters(getters):
    
    return_list = []
    for getter in getters:
        
        if isinstance(getter,basestring):
            out_args = ""
            method_name = getter
            
        else:
            method_name, a = getter
            
            out_args = convert_the_args(a)
            
        return_list.append( (method_name, out_args) )
    return return_list
1328630
def _assemble_conversion(self, stmt):
        """"""
        pybel_lists = ([], [])
        for pybel_list, agent_list in \
                            zip(pybel_lists, (stmt.obj_from, stmt.obj_to)):
            for agent in agent_list:
                node = _get_agent_grounding(agent)
                # TODO check for missing grounding?
                pybel_list.append(node)

        rxn_node_data = reaction(
            reactants=pybel_lists[0],
            products=pybel_lists[1],
        )
        obj_node = self.model.add_node_from_data(rxn_node_data)
        obj_edge = None  # TODO: Any edge information possible here?
        # Add node for controller, if there is one
        if stmt.subj is not None:
            subj_attr, subj_edge = _get_agent_node(stmt.subj)
            subj_node = self.model.add_node_from_data(subj_attr)
            edge_data_list = _combine_edge_data(pc.DIRECTLY_INCREASES,
                                           subj_edge, obj_edge, stmt.evidence)
            for edge_data in edge_data_list:
                self.model.add_edge(subj_node, obj_node, **edge_data)
850225
def get_class_methods(cls):
    
    return [
        node
        for node in cls.body
        if isinstance(node, ast.FunctionDef)
    ]
302138
def to_body(self):
        """"""
        body = [self.code, 0x00, self.ctl1, self.ctl2,
                (self.src_addr >> 8) & 0xff, (self.src_addr >> 0) & 0xff,
                (self.dst_addr >> 8) & 0xff, (self.dst_addr >> 0) & 0xff]
        if self.dptsize == 0 and (len(self.data) == 1) and ((self.data[0] & 0xC0) == 0):
            # less than 6 bit of data, pack into APCI byte
            body.extend([1, (self.tpci_apci >> 8) & 0xff,
                         ((self.tpci_apci >> 0) & 0xff) + self.data[0]])
        else:
            body.extend([1 + len(self.data), (self.tpci_apci >> 8) &
                         0xff, (self.tpci_apci >> 0) & 0xff])
            body.extend(self.data)

        return body
489546
def element_to_objects(payload: Dict) -> List:
    
    entities = []
    cls = MAPPINGS.get(payload.get('type'))
    if not cls:
        return []

    transformed = transform_attributes(payload, cls)
    entity = cls(**transformed)

    if hasattr(entity, "post_receive"):
        entity.post_receive()

    entities.append(entity)

    return entities
373602
def aslist(obj, sep=None, strip=True):
    
    if isinstance(obj, (basestring)):
        lst = obj.split(sep)
        if strip:
            lst = [v.strip() for v in lst]
        return lst
    elif isinstance(obj, (list, tuple)):
        return obj
    elif obj is None:
        return []
    else:
        return [obj]
1266812
def transform(self, node, results):
        
        """
        params = results.get(u"params")
        ret = results.get(u"ret")
        if ret is not None:
            assert ret.prev_sibling.type == token.RARROW, u"Invalid return annotation"
            self.warn_once(node, reason=warning_text)
            ret.prev_sibling.remove()
            ret.remove()
        if params is None: return
        if params.type == syms.typedargslist:
            # more than one param in a typedargslist
            for param in params.children:
                if param.type == syms.tname:
                    self.warn_once(node, reason=warning_text)
                    param.replace(param_without_annotations(param))
        elif params.type == syms.tname:
            # one param
            self.warn_once(node, reason=warning_text)
            params.replace(param_without_annotations(params))
244645
public Collection<Instruction> getInstructions() {
        return new AbstractCollection<Instruction>() {
            public Iterator<Instruction> iterator() {
                return new Iterator<Instruction>() {
                    private Instruction mNext = mFirst;

                    public boolean hasNext() {
                        return mNext != null;
                    }

                    public Instruction next() {
                        if (mNext == null) {
                            throw new NoSuchElementException();
                        }

                        Instruction current = mNext;
                        mNext = mNext.mNext;
                        return current;
                    }

                    public void remove() {
                        throw new UnsupportedOperationException();
                    }
                };
            }

            public int size() {
                int count = 0;
                for (Instruction i = mFirst; i != null; i = i.mNext) {
                    count++;
                }
                return count;
            }
        };
    }
81570
private static List<Object> asList(final int n, final Object[] o) {
        return Arrays.asList(o).subList(0, n);
    }