static PyObject * find_pretty_printer_from_objfiles (PyObject *value) { struct objfile *obj; ALL_OBJFILES (obj) { PyObject *objf = objfile_to_objfile_object (obj); if (!objf) { /* Ignore the error and continue. */ PyErr_Clear (); continue; } gdbpy_ref<> pp_list (objfpy_get_printers (objf, NULL)); gdbpy_ref<> function (search_pp_list (pp_list.get (), value)); /* If there is an error in any objfile list, abort the search and exit. */ if (function == NULL) return NULL; if (function != Py_None) return function.release (); } Py_RETURN_NONE; }
static PyObject * find_pretty_printer_from_progspace (PyObject *value) { PyObject *obj = pspace_to_pspace_object (current_program_space); if (!obj) return NULL; gdbpy_ref<> pp_list (pspy_get_printers (obj, NULL)); return search_pp_list (pp_list.get (), value); }
static PyObject * find_pretty_printer_from_gdb (PyObject *value) { /* Fetch the global pretty printer list. */ if (gdb_python_module == NULL || ! PyObject_HasAttrString (gdb_python_module, "pretty_printers")) Py_RETURN_NONE; gdbpy_ref<> pp_list (PyObject_GetAttrString (gdb_python_module, "pretty_printers")); if (pp_list == NULL || ! PyList_Check (pp_list.get ())) Py_RETURN_NONE; return search_pp_list (pp_list.get (), value); }
// Render the given term into the output stream. void print(std::ostream& os, Tree* t) { if (not t) { os << "<null>"; return; } switch (t->kind) { case id_tree: return pp_terminal(os, as<Id_tree>(t)); case lit_tree: return pp_terminal(os, as<Lit_tree>(t)); case var_tree: return pp_var(os, as<Var_tree>(t)); case init_tree: return pp_init(os, as<Init_tree>(t)); case abs_tree: return pp_abs(os, as<Abs_tree>(t)); case fn_tree: return pp_fn(os, as<Fn_tree>(t)); case app_tree: return pp_app(os, as<App_tree>(t)); case if_tree: return pp_if(os, as<If_tree>(t)); case succ_tree: return pp_succ(os, as<Succ_tree>(t)); case pred_tree: return pp_pred(os, as<Pred_tree>(t)); case ls_tree: return pp_ls(os, as<Ls_tree>(t));//Rishi case mkdir_tree: return pp_mkdir(os, as<Mkdir_tree>(t));//Rishi case rmdir_tree: return pp_rmdir(os, as<Rmdir_tree>(t));//Rishi case cd_tree: return pp_cd(os, as<Cd_tree>(t));//Rishi case mv_tree: return pp_mv(os, as<Mv_tree>(t));//Rishi case iszero_tree: return pp_iszero(os, as<Iszero_tree>(t)); case arrow_tree: return pp_arrow(os, as<Arrow_tree>(t)); case def_tree: return pp_def(os, as<Def_tree>(t)); case print_tree: return pp_print(os, as<Print_tree>(t)); case typeof_tree: return pp_typeof(os, as<Typeof_tree>(t)); case tuple_tree: return pp_tuple(os, as<Tuple_tree>(t)); case list_tree: return pp_list(os, as<List_tree>(t)); case variant_tree: return pp_variant(os, as<Variant_tree>(t)); case comma_tree: return pp_comma(os, as<Comma_tree>(t)); case dot_tree: return pp_dot(os, as<Dot_tree>(t)); case prog_tree: return pp_prog(os, as<Prog_tree>(t)); } lang_unreachable(format("print unknown node '{}'", node_name(t))); }