Given an AST, compute its last statement and replace it with a
return statement.
339874
function addReturnNode(ast: Object): Object {
  const statements = ast.program.body;
  const lastStatement = statements[statements.length - 1];
  return statements
    .slice(0, -1)
    .concat(t.returnStatement(lastStatement.expression));
}
33142
def get_final(self):
        """"""
        if self.prec is None:
            return self.x
        else:
            return self.prec.undo(self.x)
547576
def get_return_from(self, check):
        
        for prop in ['exit_status', 'output', 'long_output', 'check_time', 'execution_time',
                     'perf_data', 'u_time', 's_time']:
            setattr(self, prop, getattr(check, prop))
854473
def p_try_statement_2(self, p):
        """"""
        p[0] = ast.Try(statements=p[2], fin=p[3])
610370
def from_statement(cls, statement):
        
        if statement[0] in ["TS", "TIMESTAMP", "UTCTIMESTAMP", "UTCTS"]:
            return TimestampFunction.from_statement(statement)
        elif statement[0] in ["NOW", "UTCNOW"]:
            return NowFunction.from_statement(statement)
        else:
            raise SyntaxError("Unknown function %r" % statement[0])
888432
def last(predicate=None):
    """"""

    predicate = true if predicate is None else predicate

    def last_transducer(reducer):
        return Last(reducer, predicate)

    return last_transducer
1314784
def eval_ast(self, ast):
        
        # If there was no last value, it was not constrained, so we can use
        # anything.
        new_ast = ast.replace_dict(self.replacements, leaf_operation=self._leaf_op)
        return backends.concrete.eval(new_ast, 1)[0]
456073
def refactor_ifs(stmnt, ifs):
    '''
    
    '''
    if isinstance(stmnt, _ast.BoolOp):
        test, right = stmnt.values
        if isinstance(stmnt.op, _ast.Or):
            test = _ast.UnaryOp(op=_ast.Not(), operand=test, lineno=0, col_offset=0)

        ifs.append(test)

        return refactor_ifs(right, ifs)
    return stmnt
1065812
def dump_ast(ast, indent=' ', newline='\n'):
    '''
    
    
    
    '''
    
    visitor = ASTPrinter(indent=indent, level=0, newline=newline)
    visitor.visit(ast)
    return visitor.dumps()
1041079
function lastEach (obj, iterate, context) {
  if (obj) {
    return (isArray(obj) ? lastArrayEach : lastObjectEach)(obj, iterate, context || this)
  }
  return obj
}
1136169
def _handle_return(state: GlobalState) -> None:
        
        stack = state.mstate.stack
        try:
            offset, length = get_concrete_int(stack[-1]), get_concrete_int(stack[-2])
        except TypeError:
            return
        for element in state.mstate.memory[offset : offset + length]:
            if not isinstance(element, Expression):
                continue
            for annotation in element.annotations:
                if isinstance(annotation, OverUnderflowAnnotation):
                    state.annotate(
                        OverUnderflowStateAnnotation(
                            annotation.overflowing_state,
                            annotation.operator,
                            annotation.constraint,
                        )
                    )
385394
private static void convertLastReturnToStatement(
      Node block, String resultName) {
    Node ret = block.getLastChild();
    checkArgument(ret.isReturn());
    Node resultNode = getReplacementReturnStatement(ret, resultName);

    if (resultNode == null) {
      block.removeChild(ret);
    } else {
      resultNode.useSourceInfoIfMissingFromForTree(ret);
      block.replaceChild(ret, resultNode);
    }
  }
1114750
def _re_raise_as(NewExc, *args, **kw):
    """"""
    etype, val, tb = sys.exc_info()
    raise NewExc(*args, **kw), None, tb
213540
function combineContiguousOutputStatements (ast) {
  traverse.traverse(ast, {
    enter: function (node, parent) {
      if (node.type !== 'BlockStatement') {
        return;
      }
      var prev = false;

      node.body = fast.reduce(node.body, function (body, statement) {
        if (
          !body.length ||
          statement.type !== 'ExpressionStatement' ||
          statement.expression.type !== 'AssignmentExpression' ||
          statement.expression.operator !== '+=' ||
          statement.expression.left.type !== 'Identifier' ||
          statement.expression.left.name !== 'html'
        ) {
          prev = false;
          body.push(statement);
          return body;
        }
        else if (!prev) {
          prev = statement;
          body.push(statement);
          return body;
        }
        prev.expression.right = {
          type: 'BinaryExpression',
          operator: '+',
          left: prev.expression.right,
          right: statement.expression.right
        };
        return body;
      }, []);
    }
  });
  return ast;
}
916905
function parseReturnStatement(node) {
        var argument = null;

        expectKeyword('return');

        if (!state.inFunctionBody) {
            tolerateError(Messages.IllegalReturn);
        }

        // 'return' followed by a space and an identifier is very common.
        if (source.charCodeAt(lastIndex) === 0x20) {
            if (isIdentifierStart(source.charCodeAt(lastIndex + 1))) {
                argument = parseExpression();
                consumeSemicolon();
                return node.finishReturnStatement(argument);
            }
        }

        if (hasLineTerminator) {
            // HACK
            return node.finishReturnStatement(null);
        }

        if (!match(';')) {
            if (!match('}') && lookahead.type !== Token.EOF) {
                argument = parseExpression();
            }
        }

        consumeSemicolon();

        return node.finishReturnStatement(argument);
    }
515667
def ast_value(val, scope, return_name=False):
    '''
    '''
    # :TODO: refactor the hell out of this
    try:
        if isinstance(val, (ast.Assign, ast.Delete)):
            if hasattr(val, 'value'):
                value = ast_value(val.value, scope)
            else:
                value = None
            for t in val.targets:
                name = ast_value(t, scope, return_name=True)
                if isinstance(t.ctx, ast.Del):
                    if name in scope:
                        scope.pop(name)
                elif isinstance(t.ctx, ast.Store):
                    scope[name] = value
            return
        elif isinstance(val, ast.Expr) and isinstance(val.value, ast.Name):
            return ast_value(val.value)

        if isinstance(val, ast.Name):
            if isinstance(val.ctx, ast.Load):
                if val.id == 'None':
                    return None
                elif val.id == 'True':
                    return True
                elif val.id == 'False':
                    return False

                if val.id in scope:
                    return scope[val.id]

                if return_name:
                    return val.id
            elif isinstance(val.ctx, ast.Store):
                if return_name:
                    return val.id
            return None

        if isinstance(val, ast.Subscript):
            toslice = ast_value(val.value, scope)
            theslice = ast_value(val.slice, scope)
            return toslice[theslice]
        elif isinstance(val, ast.Index):
            return ast_value(val.value, scope)
        elif isinstance(val, ast.Slice):
            lower = ast_value(val.lower)
            upper = ast_value(val.upper)
            step = ast_value(val.step)
            return slice(lower, upper, step)

        if isinstance(val, list):
            return [ast_value(x, scope) for x in val]
        elif isinstance(val, tuple):
            return tuple(ast_value(x, scope) for x in val)

        if isinstance(val, ast.Attribute):
            name = ast_value(val.value, scope, return_name=True)
            if isinstance(val.ctx, ast.Load):
                return '.'.join((name, val.attr))
            if return_name:
                return name
        elif isinstance(val, ast.keyword):
            return {val.arg: ast_value(val.value, scope)}
        elif isinstance(val, ast.List):
            return [ast_value(x, scope) for x in val.elts]
        elif isinstance(val, ast.Tuple):
            return tuple(ast_value(x, scope) for x in val.elts)
        elif isinstance(val, ast.Dict):
            return dict(zip([ast_value(x, scope) for x in val.keys],
                            [ast_value(x, scope) for x in val.values]))
        elif isinstance(val, ast.Num):
            return val.n
        elif isinstance(val, ast.Str):
            return val.s
        elif hasattr(ast, 'Bytes') and isinstance(val, ast.Bytes):
            return bytes(val.s)
    except Exception:
        # Don't care, just return None
        pass

    return None
1174089
private Context translateReturn(WyilFile.Stmt.Return stmt, Context context) {
		//
		Tuple<WyilFile.Expr> returns = stmt.getReturns();
		//
		if (returns.size() > 0) {
			// There is at least one return value. Therefore, we need to check
			// any preconditions for those return expressions and, potentially,
			// ensure any postconditions of the cnlosing function/method are
			// met.
			Pair<Expr[], Context> p = translateExpressionsWithChecks(returns, context);
			Expr[] exprs = p.first();
			context = p.second();
			//
			generateReturnTypeInvariantCheck(stmt, exprs, context);
			generatePostconditionChecks(stmt, exprs, context);
		}
		// Return null to signal that execution does not continue after this
		// return statement.
		return null;
	}