mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
Remove trailing whitespaces. This is just a cosmetic change.
This commit is contained in:
+1
-1
@@ -23,7 +23,7 @@
|
||||
//#define MRB_ENDIAN_BIG
|
||||
|
||||
/* argv max size in mrb_funcall */
|
||||
//#define MRB_FUNCALL_ARGC_MAX 16
|
||||
//#define MRB_FUNCALL_ARGC_MAX 16
|
||||
|
||||
/* number of object per heap page */
|
||||
//#define MRB_HEAP_PAGE_SIZE 1024
|
||||
|
||||
@@ -26,13 +26,13 @@
|
||||
double
|
||||
erfc(double x);
|
||||
|
||||
/*
|
||||
/*
|
||||
** Implementations of error functions
|
||||
** credits to http://www.digitalmars.com/archives/cplusplus/3634.html
|
||||
*/
|
||||
|
||||
/* Implementation of Error function */
|
||||
double
|
||||
double
|
||||
erf(double x)
|
||||
{
|
||||
static const double two_sqrtpi = 1.128379167095512574;
|
||||
@@ -55,24 +55,24 @@ erf(double x)
|
||||
}
|
||||
|
||||
/* Implementation of complementary Error function */
|
||||
double
|
||||
double
|
||||
erfc(double x)
|
||||
{
|
||||
static const double one_sqrtpi= 0.564189583547756287;
|
||||
double a = 1;
|
||||
double b = x;
|
||||
double c = x;
|
||||
double d = x*x+0.5;
|
||||
static const double one_sqrtpi= 0.564189583547756287;
|
||||
double a = 1;
|
||||
double b = x;
|
||||
double c = x;
|
||||
double d = x*x+0.5;
|
||||
double q1;
|
||||
double q2 = b/d;
|
||||
double n = 1.0;
|
||||
double t;
|
||||
if (fabs(x) < 2.2) {
|
||||
return 1.0 - erf(x);
|
||||
}
|
||||
if (x < 0.0) { /*signbit(x)*/
|
||||
return 2.0 - erfc(-x);
|
||||
}
|
||||
return 1.0 - erf(x);
|
||||
}
|
||||
if (x < 0.0) { /*signbit(x)*/
|
||||
return 2.0 - erfc(-x);
|
||||
}
|
||||
do {
|
||||
t = a*n+b*x;
|
||||
a = b;
|
||||
@@ -306,7 +306,7 @@ math_asinh(mrb_state *mrb, mrb_value obj)
|
||||
mrb_float x;
|
||||
|
||||
mrb_get_args(mrb, "f", &x);
|
||||
|
||||
|
||||
x = asinh(x);
|
||||
|
||||
return mrb_float_value(x);
|
||||
@@ -477,10 +477,10 @@ static mrb_value
|
||||
math_sqrt(mrb_state *mrb, mrb_value obj)
|
||||
{
|
||||
mrb_float x;
|
||||
|
||||
|
||||
mrb_get_args(mrb, "f", &x);
|
||||
x = sqrt(x);
|
||||
|
||||
|
||||
return mrb_float_value(x);
|
||||
}
|
||||
|
||||
@@ -544,7 +544,7 @@ math_frexp(mrb_state *mrb, mrb_value obj)
|
||||
{
|
||||
mrb_float x;
|
||||
int exp;
|
||||
|
||||
|
||||
mrb_get_args(mrb, "f", &x);
|
||||
x = frexp(x, &exp);
|
||||
|
||||
@@ -633,13 +633,13 @@ mrb_mruby_math_gem_init(mrb_state* mrb)
|
||||
{
|
||||
struct RClass *mrb_math;
|
||||
mrb_math = mrb_define_module(mrb, "Math");
|
||||
|
||||
|
||||
#ifdef M_PI
|
||||
mrb_define_const(mrb, mrb_math, "PI", mrb_float_value(M_PI));
|
||||
#else
|
||||
mrb_define_const(mrb, mrb_math, "PI", mrb_float_value(atan(1.0)*4.0));
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef M_E
|
||||
mrb_define_const(mrb, mrb_math, "E", mrb_float_value(M_E));
|
||||
#else
|
||||
@@ -660,7 +660,7 @@ mrb_mruby_math_gem_init(mrb_state* mrb)
|
||||
mrb_define_module_function(mrb, mrb_math, "acos", math_acos, ARGS_REQ(1));
|
||||
mrb_define_module_function(mrb, mrb_math, "atan", math_atan, ARGS_REQ(1));
|
||||
mrb_define_module_function(mrb, mrb_math, "atan2", math_atan2, ARGS_REQ(2));
|
||||
|
||||
|
||||
mrb_define_module_function(mrb, mrb_math, "sinh", math_sinh, ARGS_REQ(1));
|
||||
mrb_define_module_function(mrb, mrb_math, "cosh", math_cosh, ARGS_REQ(1));
|
||||
mrb_define_module_function(mrb, mrb_math, "tanh", math_tanh, ARGS_REQ(1));
|
||||
|
||||
@@ -352,8 +352,8 @@ mrb_struct_s_def(mrb_state *mrb, mrb_value klass)
|
||||
mrb_get_args(mrb, "*&", &argv, &argc, &b);
|
||||
if (argc == 0) { /* special case to avoid crash */
|
||||
rest = mrb_ary_new(mrb);
|
||||
}
|
||||
else {
|
||||
}
|
||||
else {
|
||||
if (argc > 0) name = argv[0];
|
||||
if (argc > 1) rest = argv[1];
|
||||
if (mrb_array_p(rest)) {
|
||||
@@ -378,7 +378,7 @@ mrb_struct_s_def(mrb_state *mrb, mrb_value klass)
|
||||
id = mrb_to_id(mrb, RARRAY_PTR(rest)[i]);
|
||||
RARRAY_PTR(rest)[i] = mrb_symbol_value(id);
|
||||
}
|
||||
}
|
||||
}
|
||||
st = make_struct(mrb, name, rest, struct_class(mrb));
|
||||
if (!mrb_nil_p(b)) {
|
||||
mrb_funcall(mrb, b, "call", 1, &st);
|
||||
|
||||
+1
-1
@@ -52,7 +52,7 @@ class Array
|
||||
|
||||
##
|
||||
# Alias for collect!
|
||||
#
|
||||
#
|
||||
# ISO 15.2.12.5.20
|
||||
alias map! collect!
|
||||
|
||||
|
||||
+2
-2
@@ -25,7 +25,7 @@ module Comparable
|
||||
# Return true if +self+ is less
|
||||
# than or equal to +other+.
|
||||
# Otherwise return false.
|
||||
#
|
||||
#
|
||||
# ISO 15.3.3.2.2
|
||||
def <= other
|
||||
cmp = self <=> other
|
||||
@@ -88,7 +88,7 @@ module Comparable
|
||||
end
|
||||
|
||||
##
|
||||
# Return true if +self+ is greater
|
||||
# Return true if +self+ is greater
|
||||
# than or equal to +min+ and
|
||||
# less than or equal to +max+.
|
||||
# Otherwise return false.
|
||||
|
||||
+6
-6
@@ -73,7 +73,7 @@ module Enumerable
|
||||
##
|
||||
# Call the given block for each element
|
||||
# which is yield by +each+. Append all
|
||||
# values of each block together and
|
||||
# values of each block together and
|
||||
# return this value.
|
||||
#
|
||||
# ISO 15.3.2.2.3
|
||||
@@ -89,7 +89,7 @@ module Enumerable
|
||||
# Call the given block for each element
|
||||
# which is yield by +each+. Return
|
||||
# +ifnone+ if no block value was true.
|
||||
# Otherwise return the first block value
|
||||
# Otherwise return the first block value
|
||||
# which had was true.
|
||||
#
|
||||
# ISO 15.3.2.2.4
|
||||
@@ -158,8 +158,8 @@ module Enumerable
|
||||
# Call the given block for each element
|
||||
# which is yield by +each+ and which return
|
||||
# value was true when invoking === with
|
||||
# +pattern+. Return an array with all
|
||||
# elements or the respective block values.
|
||||
# +pattern+. Return an array with all
|
||||
# elements or the respective block values.
|
||||
#
|
||||
# ISO 15.3.2.2.9
|
||||
def grep(pattern, &block)
|
||||
@@ -291,9 +291,9 @@ module Enumerable
|
||||
|
||||
##
|
||||
# Call the given block for each element
|
||||
# which is yield by +each+. Return an
|
||||
# which is yield by +each+. Return an
|
||||
# array which contains two arrays. The
|
||||
# first array contains all elements
|
||||
# first array contains all elements
|
||||
# whose block value was true. The second
|
||||
# array contains all elements whose
|
||||
# block value was false.
|
||||
|
||||
+1
-1
@@ -64,7 +64,7 @@ class Hash
|
||||
# it will be called for each element with
|
||||
# a duplicate key. The value of the block
|
||||
# will be the final value of this element.
|
||||
#
|
||||
#
|
||||
# ISO 15.2.13.4.22
|
||||
def merge(other, &block)
|
||||
h = {}
|
||||
|
||||
+2
-2
@@ -356,7 +356,7 @@ to_hash(mrb_state *mrb, mrb_value val)
|
||||
retrieve arguments from mrb_state.
|
||||
|
||||
mrb_get_args(mrb, format, ...)
|
||||
|
||||
|
||||
returns number of arguments parsed.
|
||||
|
||||
fortmat specifiers:
|
||||
@@ -774,7 +774,7 @@ mrb_mod_include_p(mrb_state *mrb, mrb_value mod)
|
||||
}
|
||||
return mrb_false_value();
|
||||
}
|
||||
|
||||
|
||||
static mrb_value
|
||||
mrb_mod_ancestors(mrb_state *mrb, mrb_value self)
|
||||
{
|
||||
|
||||
+4
-4
@@ -330,7 +330,7 @@ genop_peep(codegen_scope *s, mrb_code i, int val)
|
||||
|
||||
if (c1 == OP_SUB) c = -c;
|
||||
if (c > 127 || c < -127) break;
|
||||
if (0 <= c)
|
||||
if (0 <= c)
|
||||
s->iseq[s->pc-1] = MKOP_ABC(OP_ADDI, GETARG_A(i), GETARG_B(i), c);
|
||||
else
|
||||
s->iseq[s->pc-1] = MKOP_ABC(OP_SUBI, GETARG_A(i), GETARG_B(i), -c);
|
||||
@@ -1161,7 +1161,7 @@ codegen(codegen_scope *s, node *tree, int val)
|
||||
if (e) {
|
||||
if (val) pop();
|
||||
pos2 = new_label(s);
|
||||
genop(s, MKOP_sBx(OP_JMP, 0));
|
||||
genop(s, MKOP_sBx(OP_JMP, 0));
|
||||
dispatch(s, pos1);
|
||||
codegen(s, e, val);
|
||||
dispatch(s, pos2);
|
||||
@@ -1951,7 +1951,7 @@ codegen(codegen_scope *s, node *tree, int val)
|
||||
pop();
|
||||
sym = new_sym(s, mrb_intern(s->mrb, "compile"));
|
||||
genop(s, MKOP_ABC(OP_SEND, cursp(), sym, argc));
|
||||
mrb_gc_arena_restore(s->mrb, ai);
|
||||
mrb_gc_arena_restore(s->mrb, ai);
|
||||
push();
|
||||
}
|
||||
break;
|
||||
@@ -1999,7 +1999,7 @@ codegen(codegen_scope *s, node *tree, int val)
|
||||
pop();
|
||||
sym = new_sym(s, mrb_intern(s->mrb, "compile"));
|
||||
genop(s, MKOP_ABC(OP_SEND, cursp(), sym, argc));
|
||||
mrb_gc_arena_restore(s->mrb, ai);
|
||||
mrb_gc_arena_restore(s->mrb, ai);
|
||||
push();
|
||||
}
|
||||
else {
|
||||
|
||||
+2
-2
@@ -125,7 +125,7 @@ exc_inspect(mrb_state *mrb, mrb_value exc)
|
||||
mesg = mrb_attr_get(mrb, exc, mrb_intern(mrb, "mesg"));
|
||||
file = mrb_attr_get(mrb, exc, mrb_intern(mrb, "file"));
|
||||
line = mrb_attr_get(mrb, exc, mrb_intern(mrb, "line"));
|
||||
|
||||
|
||||
if (!mrb_nil_p(file) && !mrb_nil_p(line)) {
|
||||
str = file;
|
||||
mrb_str_cat2(mrb, str, ":");
|
||||
@@ -190,7 +190,7 @@ exc_debug_info(mrb_state *mrb, struct RObject *exc)
|
||||
ci--;
|
||||
while (ci >= mrb->cibase) {
|
||||
if (ci->proc && !MRB_PROC_CFUNC_P(ci->proc)) {
|
||||
mrb_irep *irep = ci->proc->body.irep;
|
||||
mrb_irep *irep = ci->proc->body.irep;
|
||||
|
||||
if (irep->filename && irep->lines && irep->iseq <= pc && pc < irep->iseq + irep->ilen) {
|
||||
mrb_obj_iv_set(mrb, exc, mrb_intern(mrb, "file"), mrb_str_new_cstr(mrb, irep->filename));
|
||||
|
||||
+3
-3
@@ -191,7 +191,7 @@ mrb_f_send(mrb_state *mrb, mrb_value self)
|
||||
mrb_sym name;
|
||||
mrb_value block, *argv;
|
||||
int argc;
|
||||
|
||||
|
||||
mrb_get_args(mrb, "n*&", &name, &argv, &argc, &block);
|
||||
return mrb_funcall_with_block(mrb,self, name, argc, argv, block);
|
||||
}
|
||||
@@ -483,7 +483,7 @@ mrb_value mrb_yield_internal(mrb_state *mrb, mrb_value b, int argc, mrb_value *a
|
||||
* call-seq:
|
||||
* obj.instance_eval {| | block } -> obj
|
||||
*
|
||||
* Evaluates the given block,within the context of the receiver (_obj_).
|
||||
* Evaluates the given block,within the context of the receiver (_obj_).
|
||||
* In order to set the context, the variable +self+ is set to _obj_ while
|
||||
* the code is executing, giving the code access to _obj_'s
|
||||
* instance variables. In the version of <code>instance_eval</code>
|
||||
@@ -913,7 +913,7 @@ mrb_f_raise(mrb_state *mrb, mrb_value self)
|
||||
{
|
||||
mrb_value a[2], exc;
|
||||
int argc;
|
||||
|
||||
|
||||
|
||||
argc = mrb_get_args(mrb, "|oo", &a[0], &a[1]);
|
||||
switch (argc) {
|
||||
|
||||
+1
-1
@@ -536,7 +536,7 @@ mrb_read_irep(mrb_state *mrb, const char *bin)
|
||||
nirep = read_rite_header(mrb, src, &bin_header);
|
||||
if (nirep < 0)
|
||||
return nirep;
|
||||
|
||||
|
||||
src += sizeof(bin_header) + MRB_DUMP_SIZE_OF_SHORT; //header + crc
|
||||
|
||||
//Read Binary Data Section
|
||||
|
||||
+4
-4
@@ -306,7 +306,7 @@ static mrb_value
|
||||
num_eql(mrb_state *mrb, mrb_value x)
|
||||
{
|
||||
mrb_value y;
|
||||
|
||||
|
||||
mrb_get_args(mrb, "o", &y);
|
||||
if (mrb_type(x) != mrb_type(y)) return mrb_false_value();
|
||||
if (mrb_equal(mrb, x, y)) {
|
||||
@@ -699,7 +699,7 @@ mrb_value
|
||||
mrb_fixnum_mul(mrb_state *mrb, mrb_value x, mrb_value y)
|
||||
{
|
||||
mrb_int a;
|
||||
|
||||
|
||||
a = mrb_fixnum(x);
|
||||
if (a == 0) return x;
|
||||
if (mrb_fixnum_p(y)) {
|
||||
@@ -1126,7 +1126,7 @@ mrb_value
|
||||
mrb_fixnum_plus(mrb_state *mrb, mrb_value x, mrb_value y)
|
||||
{
|
||||
mrb_int a;
|
||||
|
||||
|
||||
a = mrb_fixnum(x);
|
||||
if (a == 0) return y;
|
||||
if (mrb_fixnum_p(y)) {
|
||||
@@ -1165,7 +1165,7 @@ mrb_value
|
||||
mrb_fixnum_minus(mrb_state *mrb, mrb_value x, mrb_value y)
|
||||
{
|
||||
mrb_int a;
|
||||
|
||||
|
||||
a = mrb_fixnum(x);
|
||||
if (mrb_fixnum_p(y)) {
|
||||
mrb_int b, c;
|
||||
|
||||
+2
-2
@@ -623,7 +623,7 @@ retry:
|
||||
p++;
|
||||
goto retry;
|
||||
}
|
||||
|
||||
|
||||
case '*':
|
||||
CHECK_FOR_WIDTH(flags);
|
||||
flags |= FWIDTH;
|
||||
@@ -658,7 +658,7 @@ retry:
|
||||
case '\n':
|
||||
case '\0':
|
||||
p--;
|
||||
|
||||
|
||||
case '%':
|
||||
if (flags != FNONE) {
|
||||
mrb_raise(mrb, E_ARGUMENT_ERROR, "invalid format character - %");
|
||||
|
||||
+1
-1
@@ -753,7 +753,7 @@ mrb_vm_cv_get(mrb_state *mrb, mrb_sym sym)
|
||||
struct RClass *c = mrb->ci->proc->target_class;
|
||||
|
||||
if (!c) c = mrb->ci->target_class;
|
||||
|
||||
|
||||
return mrb_mod_cv_get(mrb, c, sym);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user