evaluate node in program
763603
def evaluate(self,n, features, stack_float, stack_bool,labels=None):
        """"""
        np.seterr(all='ignore')
        if len(stack_float) >= n.arity['f'] and len(stack_bool) >= n.arity['b']:
            if n.out_type == 'f':
                stack_float.append(
                    self.safe(self.eval_dict[n.name](n,features,stack_float,
                                                     stack_bool,labels)))
                if (np.isnan(stack_float[-1]).any() or
                    np.isinf(stack_float[-1]).any()):
                    print("problem operator:",n)
            else:
                stack_bool.append(self.safe(self.eval_dict[n.name](n,features,
                                                                   stack_float,
                                                                   stack_bool,
                                                                   labels)))
                if np.isnan(stack_bool[-1]).any() or np.isinf(stack_bool[-1]).any():
                    print("problem operator:",n)
168281
private @Nonnull NodeList evaluate(String xpath) {
        try {
            XPathExpression expr = xpf.newXPath().compile(xpath);
            return (NodeList) expr.evaluate(node, XPathConstants.NODESET);
        } catch (XPathExpressionException ex) {
            throw new IllegalArgumentException("Invalid XPath '" + xpath + "'", ex);
        }
    }
724428
function processNode(node) {
            const entity = node.code.trim()
            if (!entity) {
                context.report({
                    node,
                    messageId: "missing",
                })
            }
        }
1209213
async def eval(self, text, opts=None, user=None):
        '''
        
        '''
        if user is None:
            user = self.auth.getUserByName('root')

        await self.boss.promote('storm', user=user, info={'query': text})
        async with await self.snap(user=user) as snap:
            async for node in snap.eval(text, opts=opts, user=user):
                yield node
1310449
function checkNodeIndent(node, neededIndent) {
            const actualIndent = getNodeIndent(node, false);

            if (
                node.type !== "ArrayExpression" &&
                node.type !== "ObjectExpression" &&
                (actualIndent.goodChar !== neededIndent || actualIndent.badChar !== 0) &&
                isNodeFirstInLine(node)
            ) {
                report(node, neededIndent, actualIndent.space, actualIndent.tab);
            }

            if (node.type === "IfStatement" && node.alternate) {
                const elseToken = sourceCode.getTokenBefore(node.alternate);

                checkNodeIndent(elseToken, neededIndent);

                if (!isNodeFirstInLine(node.alternate)) {
                    checkNodeIndent(node.alternate, neededIndent);
                }
            }

            if (node.type === "TryStatement" && node.handler) {
                const catchToken = sourceCode.getFirstToken(node.handler);

                checkNodeIndent(catchToken, neededIndent);
            }

            if (node.type === "TryStatement" && node.finalizer) {
                const finallyToken = sourceCode.getTokenBefore(node.finalizer);

                checkNodeIndent(finallyToken, neededIndent);
            }

            if (node.type === "DoWhileStatement") {
                const whileToken = sourceCode.getTokenAfter(node.body);

                checkNodeIndent(whileToken, neededIndent);
            }
        }
310060
def process_node(node):
    """"""
    value = node['value']
    mname = node['name']
    typeid = node['typeid']
    if typeid == 52: # StructDataValue
        obj = {}
        for el in value['elements']:
            key, val = process_node(el)
            obj[key] = val

        if value['struct_type'] != 'dict':
            # Value is not a dict
            klass = objimp.import_object(value['struct_type'])
            newobj = klass.__new__(klass)
            if hasattr(newobj, '__setstate__'):
                newobj.__setstate__(obj)
            else:
                newobj.__dict__ = obj
            obj = newobj
    elif typeid == 9:
        data = value['data']
        dim = value['dimension']
        shape = dim['height'], dim['width']
        obj = data
    elif typeid == 90: # StructDataValueList
        obj = []
        for el in value:
            sobj = {}
            for sel in el['elements']:
                key, val = process_node(sel)
                sobj[key] = val
            obj.append(sobj)

    elif typeid == 45: # Frame
        obj = dataframe.DataFrame(frame=os.path.abspath(value['path']))
    else:
        obj = value

    return mname, obj
406495
def if_node(node, indent)
      # Check if we have any condition met, or an else branch
      node[@value].each_with_index do |value, index|
        # If we have a branch that meets the condition, generate code for the
        # children related to that specific branch
        case value
        when node[@value].first then buffer_eval "if #{value}"
        when node[@value].last then buffer_eval "else"
        else buffer_eval "elsif #{value}"
        end

        # Evaluate child nodes
        node[@children][index].each do |child|
          root child, indent
        end
      end

      # End
      buffer_eval "end"
    end
513714
function evaluateNthRootForChildren(node) {
  const newNode = clone(node);

  const substeps = [];
  for (let i = 0; i < newNode.args.length; i++) {
    const child = newNode.args[i];
    const childNodeStatus = nthRoot(child);
    if (childNodeStatus.hasChanged()) {
      newNode.args[i] = childNodeStatus.newNode;
      substeps.push(Node.Status.childChanged(newNode, childNodeStatus, i));
    }
  }

  if (substeps.length === 0) {
    return Node.Status.noChange(node);
  }
  else if (substeps.length === 1) {
    return substeps[0];
  }
  else {
    return Node.Status.nodeChanged(
      ChangeTypes.EVALUATE_DISTRIBUTED_NTH_ROOT, node, newNode, true, substeps);
  }
}
913304
public void evaluate(Tree guess, Tree gold, PrintWriter pw) {
    evaluate(guess, gold, pw, 1.0);
  }
871939
def ifelse(self, node):
        ''
        _, cond, _, cons, _, alt = node
        return self.eval(cons) if self.eval(cond) else self.eval(alt)
1113479
def evaluate(self, node: InstanceNode) -> XPathValue:
        
        return self._eval(XPathContext(node, node, 1, 1))
989199
function dom (tree, node, data) {
  let findElseBranch = false
  let logical = false

  function getValue (data, info, str) {
    if (!EQ_RE.test(str)) return str
    let exp = str.replace(EQ_RE, '')
    if (FMT_RE.test(exp)) exp = '__format(' + exp + ')'
    logical = true
    const value = common.scopedExpression(data, info, exp)
    return value // he.escape(value + '')
  }

  function compile (child, index) {
    // if (child.dom) return node.appendChild(child.dom)
    const locationData = { pos: child.pos || {}, location }

    // if (child.unescaped) {
    //  child.content = he.escape(child.content)
    // }

    const firstLetter = child.tagOrSymbol.charCodeAt(0)

    //
    // first handle any flow control statements
    //
    if (child.tagOrSymbol === 'else') {
      if (!findElseBranch) return

      logical = true
      // if this is an else-if
      if (IF_RE.test(child.content)) {
        const exp = child.content.replace(IF_RE, '')
        if (common.scopedExpression(data, locationData, exp)) {
          findElseBranch = false
          const branch = document.createDocumentFragment()
          const children = dom(child, branch, data)
          if (children) node.appendChild(branch)
        }
        return
      }

      findElseBranch = false
      const branch = document.createDocumentFragment()
      const children = dom(child, branch, data)
      if (children) node.appendChild(branch)
      return
    }

    if (child.tagOrSymbol === 'comment') {
      const comment = document.createComment(child.content)
      node.appendChild(comment)
      return
    }

    if (child.tagOrSymbol === 'if') {
      logical = true
      if (common.scopedExpression(data, locationData, child.content)) {
        const branch = document.createDocumentFragment()
        const children = dom(child, branch, data)
        if (children) node.appendChild(branch)
        return
      }
      findElseBranch = true
      return
    }

    if (child.tagOrSymbol === 'while') {
      logical = true
      while (common.scopedExpression(data, locationData, child.content)) {
        const children = dom(child, node, data)
        if (children) node.appendChild(children)
      }
      return
    }

    if (child.tagOrSymbol === 'for') {
      logical = true

      const parts = child.content.split(IN_RE)
      if (!parts[0]) common.die(locationData, 'TypeError', 'Unknown mixin')

      const object = common.scopedExpression(data, locationData, parts[1])

      common.each(object, function (val, key) {
        // determine if there are identifiers for key and value
        const identifiers = parts[0].split(',')
        const keyIdentifier = identifiers[0]
        const valIdentifier = identifiers[1]
        const locals = { [keyIdentifier]: key }

        if (valIdentifier) {
          locals[valIdentifier] = val
        }
        // create a new shallow scope so that locals don't persist
        const scope = Object.assign({}, data, locals)
        const children = dom(child, node, scope)
        if (children) node.appendChild(children)
      })
      return
    }

    if (child.tagOrSymbol === 'each') {
      common.die(locationData, 'TypeError', 'Each not supported (use for)')
    }

    // treat all piped text as plain content
    if (child.tagOrSymbol === '|') {
      return (node.textContent += getValue(data, locationData, child.content))
    }

    if (firstLetter === HYPHEN) {
      common.die(locationData, 'Error', 'No inline code!')
    }

    /* if (firstLetter === COLON && cb) {
      logical = true
      const name = 'jstransformer-' + child.tagOrSymbol.slice(1)
      let t = null
      try {
        t = transformer(require(name))
      } catch (ex) {
        common.die(child.pos, 'Error', fmt('%s not installed', name))
      }
      const path = child.content
      const data = cb({ path, location })
      const parsed = t.render(data.tree, child.attributes)
      node.textContent += parsed.body
      return
    }

    // anything prefixed with '+' is a mixin call.
    if (firstLetter === PLUS && cb) {
      logical = true
      const name = child.tagOrSymbol.slice(1)
      if (!cache[name]) {
        common.die(child.pos, 'TypeError', 'Unknown mixin')
      }

      const locals = {}
      const args = Object.keys(child.attributes).map(attr => {
        return common.scopedExpression(data, child.pos, attr)
      })

      cache[name].keys.map((k, index) => (locals[k] = args[index]))
      const scope = Object.assign({}, data, locals)
      const children = dom(cache[name].child, node, scope)
      node.appendChild(children)
      return
    } */

    // defines a mixin
    if (firstLetter >= A && firstLetter <= Z) {
      logical = true
      const keys = Object.keys(child.attributes)
      cache[child.tagOrSymbol] = { child, keys }
      return
    }

    //
    // everything else is a tag
    //
    const props = common.resolveTagOrSymbol(child.tagOrSymbol)

    let el = document.createElement(props.tagname)

    if (props.id) el.id = props.id
    if (props.classname) el.className = props.classname

    if (child.attributes) {
      Object.keys(child.attributes).map(key => {
        let value = child.attributes[key]

        // if this attribute is a boolean, make its value its key
        if (typeof value === 'boolean') {
          el.setAttribute(key, key)
        }

        if (value) {
          // all values are expressions
          value = common.scopedExpression(data, locationData, value)
          // a class should not be empty
          if (key === 'class' && !value) return

          // data-* attributes should be escaped
          if (key.indexOf('data-') === 0) {
            if (typeof value !== 'string' && typeof value !== 'number') {
              value = JSON.stringify(value)
            }
          }
        }
        el.setAttribute(key, value)
      })
    }

    if (child.content) {
      el.textContent = (child.tagOrSymbol === 'script')
        ? child.content
        : getValue(data, locationData, child.content)
    }

    // nothing left to decide, recurse if there are child nodes
    if (child.children.length) {
      const children = dom(child, el, data)
      if (children) node.appendChild(children)
    }

    // if this is not a logical node, we can make an optimization
    // if (!logical) child.dom = el
    node.appendChild(el)
  }

  if (tree.children && tree.children.length) {
    tree.children.map(compile)
  }
  return node
}
255440
public static Object evaluate(Node node, String xPathExpression,
            NamespaceContext nsContext, XPathExpressionResult resultType) {
        if (resultType.equals(XPathExpressionResult.NODE)) {
            Node resultNode = evaluateAsNode(node, xPathExpression, nsContext);

            if (resultNode.getNodeType() == Node.ELEMENT_NODE) {
                if (resultNode.getFirstChild() != null) {
                    return resultNode.getFirstChild().getNodeValue();
                } else {
                    return "";
                }
            } else {
                return resultNode.getNodeValue();
            }
        } else if (resultType.equals(XPathExpressionResult.NODESET)) {
            NodeList resultNodeList = evaluateAsNodeList(node, xPathExpression, nsContext);

            List<String> values = new ArrayList<>();
            for (int i = 0; i < resultNodeList.getLength(); i++) {
                Node resultNode = resultNodeList.item(i);

                if (resultNode.getNodeType() == Node.ELEMENT_NODE) {
                    if (resultNode.getFirstChild() != null) {
                        values.add(resultNode.getFirstChild().getNodeValue());
                    } else {
                        values.add("");
                    }
                } else {
                    values.add(resultNode.getNodeValue());
                }
            }

            return values;
        } else if (resultType.equals(XPathExpressionResult.STRING)) {
            return evaluateAsString(node, xPathExpression, nsContext);
        } else {
            Object result = evaluateAsObject(node, xPathExpression, nsContext, resultType.getAsQName());

            if (result == null) {
                throw new CitrusRuntimeException("No result for XPath expression: '" + xPathExpression + "'");
            }

            if (resultType.equals(XPathExpressionResult.INTEGER)) {
                return (int) Math.round((Double) result);
            }

            return result;
        }
    }
173211
function(node) {
                assertRangeValid(this);

                var parent = node.parentNode;
                var nodeIndex = getNodeIndex(node);

                if (!parent) {
                    throw new DOMException("NOT_FOUND_ERR");
                }

                var startComparison = this.comparePoint(parent, nodeIndex),
                    endComparison = this.comparePoint(parent, nodeIndex + 1);

                if (startComparison < 0) { // Node starts before
                    return (endComparison > 0) ? n_b_a : n_b;
                } else {
                    return (endComparison > 0) ? n_a : n_i;
                }
            }
1264308
def each_node(node, indent)
      # Process named variables for each structure
      variables = node[@value][1].clone

      # The each structure accept missing arguments as well, therefore we need to
      # substitute them with our defaults
      #
      # each in iterable
      # each value in iterable
      # each key, value in iterable

      # Value argument name provided only
      if variables.length == 1
        variables.unshift Settings::DEFAULT_EACH_KEY

      # Missing key and value arguments
      elsif variables.empty?
        variables[0] = Settings::DEFAULT_EACH_KEY
        variables[1] = Settings::DEFAULT_EACH_VALUE
      end

      # Choose whether to apply each with index (Arrays) or each (Hashes) methods
      #buffer_eval "_opulent_send_method = (#{node[@value][1]}.is_a?(Array) ? :each_with_index : :each)"
      case node[@value][0][0]
      when '[]'
        buffer_eval "#{node[@value][0][1]}.each_with_index do |#{variables.reverse.join ', '}|"
      else
        buffer_eval "#{node[@value][0][1]}.each do |#{variables.join ', '}|"
      end

      # Evaluate child nodes
      node[@children].each do |child|
        root child, indent
      end

      # End
      buffer_eval 'end'
    end
217576
def evaluate(parent, indent)
      # Accept eval or multiline eval syntax and return a new node,
      return unless accept :eval

      multiline = accept(:text)

      if multiline
        # Get first evaluation line
        evaluate_code = accept(:line_feed) || ''

        # Get all the lines which are more indented than the current one
        eval_node = [:evaluate, evaluate_code.strip, {}, nil, indent]
        eval_node[@value] += accept(:newline) || ''
        eval_node[@value] += get_indented_lines(indent)
      else
        evaluate_code = accept(:line_feed) || ''
        eval_node = [:evaluate, evaluate_code.strip, {}, [], indent]

        root eval_node, indent
      end

      parent[@children] << eval_node
    end
260643
async def nodes(self, text, opts=None, user=None):
        '''
        
        '''
        return [n async for n in self.eval(text, opts=opts, user=user)]