jak-project/common/goos/PrettyPrinter.h
water111 a870bb53e4
[Decompiler] Expression 5 (#218)
* new method of inline-array-class

* up to new array

* wip side effect stuff

* prepare for pop barrier stuff

* add pop barrier

* add local vars hack to compiler

* fix bug, make sort work

* add test for array

* bug fixes

* another bug fix

* refactoring env variable print for casts

* more tweaks

* updates

* final cleanup

* codacy fixes
2021-02-01 20:41:37 -05:00

55 lines
1.6 KiB
C++

#pragma once
/*!
* @file PrettyPrinter.h
* A Pretty Printer for GOOS.
* It is not very good, but significantly better than putting everything on one line
*/
#include <string>
#include <vector>
#include "common/goos/Object.h"
#include "common/goos/Reader.h"
namespace pretty_print {
// main pretty print function
std::string to_string(const goos::Object& obj, int line_length = 80);
// string -> object (as a symbol)
goos::Object to_symbol(const std::string& str);
// list with a single symbol from a string
goos::Object build_list(const std::string& str);
// wrap an object in a list
goos::Object build_list(const goos::Object& obj);
// build a list out of a vector of forms
goos::Object build_list(const std::vector<goos::Object>& objects);
// build a list out of an array of forms
goos::Object build_list(const goos::Object* objects, int count);
// build a list out of a vector of strings that are converted to symbols
goos::Object build_list(const std::vector<std::string>& symbols);
// fancy wrapper functions. Due to template magic these can call each other
// and accept mixed arguments!
template <typename... Args>
goos::Object build_list(const goos::Object& car, Args... rest);
template <typename... Args>
goos::Object build_list(const std::string& str, Args... rest) {
return goos::PairObject::make_new(to_symbol(str), build_list(rest...));
}
template <typename... Args>
goos::Object build_list(const goos::Object& car, Args... rest) {
return goos::PairObject::make_new(car, build_list(rest...));
}
goos::Reader& get_pretty_printer_reader();
} // namespace pretty_print