Split functions into many files, remove string from std.

This commit is contained in:
Danila Fedorin 2018-09-01 23:19:28 -07:00
parent 3c949c9ed3
commit 22ac8ba2d0
13 changed files with 90 additions and 55 deletions

View File

@ -1,5 +1,9 @@
#pragma once
extern "C" {
#include "libabacus.h"
}
#define FUNCTION(name) libab_result function_##name( \
libab* ab, libab_ref* scope, libab_ref_vec* params, libab_ref* into)

View File

@ -1,44 +1,5 @@
#pragma once
#include "ref.hpp"
#include "util.hpp"
#include "function_utils.hpp"
extern "C" {
#include "libabacus.h"
}
FUNCTION(print_string);
FUNCTION(to_string_num);
FUNCTION(to_string_bool);
FUNCTION(to_string_unit);
FUNCTION(plus);
FUNCTION(minus);
FUNCTION(times);
FUNCTION(divide);
FUNCTION(pow);
FUNCTION(lt);
FUNCTION(lte);
FUNCTION(equals);
FUNCTION(gt);
FUNCTION(gte);
FUNCTION(negate);
FUNCTION(factorial);
FUNCTION(ln);
FUNCTION(exp);
FUNCTION(sqrt);
FUNCTION(sin);
FUNCTION(cos);
FUNCTION(tan);
FUNCTION(arcsin);
FUNCTION(arccos);
FUNCTION(arctan);
FUNCTION(quit);
FUNCTION(request_precision);
#include "operator_functions.hpp"
#include "other_functions.hpp"
#include "trig_functions.hpp"

View File

@ -0,0 +1,18 @@
#pragma once
#include "function_utils.hpp"
FUNCTION(plus);
FUNCTION(minus);
FUNCTION(times);
FUNCTION(divide);
FUNCTION(pow);
FUNCTION(lt);
FUNCTION(lte);
FUNCTION(equals);
FUNCTION(gt);
FUNCTION(gte);
FUNCTION(negate);
FUNCTION(factorial);

View File

@ -0,0 +1,8 @@
#pragma once
#include "function_utils.hpp"
FUNCTION(ln);
FUNCTION(exp);
FUNCTION(sqrt);

View File

@ -0,0 +1,6 @@
#pragma once
#include "function_utils.hpp"
FUNCTION(quit);
FUNCTION(request_precision);

View File

@ -0,0 +1,8 @@
#pragma once
#include "function_utils.hpp"
FUNCTION(print_string);
FUNCTION(to_string_num);
FUNCTION(to_string_bool);
FUNCTION(to_string_unit);

View File

@ -0,0 +1,12 @@
#pragma once
#include "function_utils.hpp"
FUNCTION(sin);
FUNCTION(cos);
FUNCTION(tan);
FUNCTION(arcsin);
FUNCTION(arccos);
FUNCTION(arctan);

View File

@ -44,14 +44,6 @@ void abacus::add_operator_postfix(const std::string& op, const std::string& func
}
void abacus::add_standard() {
add_function("quit", function_quit, "()->unit");
add_function("request_precision", function_request_precision, "(num)->unit");
add_function("print", function_print_string, "(str)->unit");
add_function("to_string", function_to_string_num, "(num)->str");
add_function("to_string", function_to_string_bool, "(bool)->str");
add_function("to_string", function_to_string_unit, "(unit)->str");
add_function("lt", function_lt, "(num, num)->num");
add_function("lte", function_lte, "(num, num)->num");
add_function("equals", function_equals, "(num, num)->num");

View File

@ -7,7 +7,8 @@
#include <sstream>
#include "types.hpp"
#include "ref.hpp"
#include "function_utils.hpp"
#include "repl_functions.hpp"
#include "string_functions.hpp"
#include "abacus.hpp"
extern "C" {
#include "libabacus.h"
@ -48,6 +49,14 @@ int main() {
size_t index = 0;
ab.add_standard();
ab.add_function("quit", function_quit, "()->unit");
ab.add_function("request_precision", function_request_precision, "(num)->unit");
ab.add_function("print", function_print_string, "(str)->unit");
ab.add_function("to_string", function_to_string_num, "(num)->str");
ab.add_function("to_string", function_to_string_bool, "(bool)->str");
ab.add_function("to_string", function_to_string_unit, "(unit)->str");
run_rc(ab);
while(!close_requested) {
char* data = readline(" > ");

View File

@ -1,4 +1,11 @@
#include "functions.hpp"
#include "operator_functions.hpp"
#include <mpfr.h>
#include "types.hpp"
#include "ref.hpp"
#include "util.hpp"
extern "C" {
#include "util.h"
}
FUNCTION_MPFR2(plus, add)
FUNCTION_MPFR2(minus, sub)

View File

@ -1,4 +1,7 @@
#include "functions.hpp"
#include "other_functions.hpp"
#include <mpfr.h>
#include "types.hpp"
#include "util.hpp"
FUNCTION_MPFR(ln, log);
FUNCTION_MPFR(exp, exp);

View File

@ -1,4 +1,7 @@
#include "functions.hpp"
#include "string_functions.hpp"
#include "ref.hpp"
#include "types.hpp"
#include "util.hpp"
#include <string>
#include <iostream>

View File

@ -1,4 +1,8 @@
#include "functions.hpp"
#include "trig_functions.hpp"
#include <mpfr.h>
#include "ref.hpp"
#include "types.hpp"
#include "util.hpp"
FUNCTION_MPFR(sin, sin);
FUNCTION_MPFR(cos, cos);