Split functions into many files, remove string from std.

master
Danila Fedorin 5 years ago
parent 3c949c9ed3
commit 22ac8ba2d0
  1. 4
      include/function_utils.hpp
  2. 45
      include/functions.hpp
  3. 18
      include/operator_functions.hpp
  4. 8
      include/other_functions.hpp
  5. 6
      include/repl_functions.hpp
  6. 8
      include/string_functions.hpp
  7. 12
      include/trig_functions.hpp
  8. 8
      src/abacus.cpp
  9. 11
      src/main.cpp
  10. 9
      src/operator_functions.cpp
  11. 5
      src/other_functions.cpp
  12. 5
      src/string_functions.cpp
  13. 6
      src/trig_functions.cpp

@ -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)

@ -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"

@ -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);

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

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

@ -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);

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

@ -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");

@ -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(" > ");

@ -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)

@ -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);

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

@ -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);

Loading…
Cancel
Save