37 lines
768 B
C++
37 lines
768 B
C++
#include "fun.hpp"
|
|
|
|
std::shared_ptr<Constant> println(STDARGS args)
|
|
{
|
|
std::string sep;
|
|
|
|
for (auto const& arg: args)
|
|
{
|
|
std::cout << sep << arg->string();
|
|
sep = " ";
|
|
}
|
|
|
|
std::cout << std::endl;
|
|
|
|
return std::make_shared<Constant>(TYPE_NIL, args[0]->loc());
|
|
}
|
|
|
|
std::shared_ptr<Constant> assert_eq(STDARGS args)
|
|
{
|
|
bool equals = args[0]->equals(*args[1]);
|
|
auto loc = args[0]->loc();
|
|
|
|
if (!equals)
|
|
{
|
|
std::cerr << loc.file_path().string() << ":" << loc.line();
|
|
std::cerr << " ASSERTION FAILED: ";
|
|
|
|
std::cerr << "expected '" << args[0]->string() << "', "
|
|
<< "got '" << args[1]->string() << "'."
|
|
<< std::endl;
|
|
|
|
exit(-1);
|
|
}
|
|
|
|
return std::make_shared<Constant>(TYPE_NIL, loc, 0);
|
|
}
|