Skip to content

Commit

Permalink
License
Browse files Browse the repository at this point in the history
  • Loading branch information
smaludzi committed May 26, 2018
1 parent 3a8e981 commit 754a231
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 4 deletions.
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2018 smaludzi
Copyright (c) 2018 Slawomir Maludzinski

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
16 changes: 16 additions & 0 deletions libmath.c
Original file line number Diff line number Diff line change
Expand Up @@ -120,4 +120,20 @@ void libmath_add_funcs(func_list * funcs)
func_list_add_end(funcs, libmath_func_pow_new());
}

const char * libmath_func_to_str(libmath_func math_id)
{
switch (math_id)
{
case LIB_MATH_UNKNOWN: return "unknown";
case LIB_MATH_SIN: return "sin";
case LIB_MATH_COS: return "cos";
case LIB_MATH_TAN: return "tan";
case LIB_MATH_EXP: return "exp";
case LIB_MATH_LOG: return "log";
case LIB_MATH_SQRT: return "sqrt";
case LIB_MATH_POW: return "pow";
}
return "unknown";
}


2 changes: 2 additions & 0 deletions libmath.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,7 @@ func * libmath_func_sqrt_new();

void libmath_add_funcs(func_list * funcs);

const char * libmath_func_to_str(libmath_func math_id);

#endif /* __LIBMATH_H__ */

4 changes: 2 additions & 2 deletions sample/sample5.nev
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ func deg2rad(float deg) -> float
return deg * 3.14159265359 / 180;
}

func trig() -> (float) -> float
func get_func() -> (float) -> float
{
return cos;
}

func main() -> float
{
return trig()(deg2rad(30));
return get_func()(deg2rad(60));
}


4 changes: 3 additions & 1 deletion vm.c
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,9 @@ void vm_execute_build_in(vm * machine, bytecode * code)

if (fetestexcept(FE_INVALID | FE_DIVBYZERO | FE_OVERFLOW | FE_UNDERFLOW))
{
print_error_msg(machine->line_no, "an error occurred in the mathematical function\n");
print_error_msg(machine->line_no,
"an error occurred in build in function %s\n",
libmath_func_to_str(code->build_in.id));
machine->running = VM_ERROR;
return;
}
Expand Down

0 comments on commit 754a231

Please sign in to comment.