Compare commits

..

6831 Commits

Author SHA1 Message Date
Hiroshi Mimaki 4c91adc4b2 Update version to 2.1.0. (mruby 2.1.0 RC) 2019-10-18 14:59:27 +09:00
Hiroshi Mimaki b654683545 Merge master. 2019-10-18 14:46:03 +09:00
Yukihiro "Matz" Matsumoto 20d01f118d Merge pull request #4778 from shuujii/move-methods-of-Kernel-to-kernel.rb-from-io.rb-in-mruby-io-gem
Move methods of `Kernel` to `kernel.rb` from `io.rb` in `mruby-io` gem
2019-10-18 12:23:28 +09:00
KOBAYASHI Shuji e5d767b149 Move methods of Kernel to kernel.rb from io.rb in mruby-io gem 2019-10-18 10:50:23 +09:00
Yukihiro "Matz" Matsumoto e5f7b1d262 Merge pull request #4777 from yurie/pr
Remove constant export declaration for MRBC output compiled as C
2019-10-18 06:58:08 +09:00
yuri d29178a9cd delete extern in C 2019-10-17 23:49:58 +09:00
Yukihiro "Matz" Matsumoto bc4799361e Merge pull request #4776 from shuujii/make-IO-each-family-without-block-to-return-Enumerator
Make `IO#each` family without block to return `Enumerator`
2019-10-17 20:50:22 +09:00
KOBAYASHI Shuji 14870a290d Make IO#each family without block to return Enumerator 2019-10-17 20:14:02 +09:00
Yukihiro "Matz" Matsumoto 84db8edade Merge pull request #4775 from shuujii/use-mrb_sym_name_len-instead-of-mrb_sym_name-in-assign_class_name
Use `mrb_sym_name_len` instead of `mrb_sym_name` in `assign_class_name`
2019-10-16 20:22:00 +09:00
KOBAYASHI Shuji 3827c4deb2 Use mrb_sym_name_len instead of mrb_sym_name in assign_class_name 2019-10-16 18:18:58 +09:00
Yukihiro "Matz" Matsumoto b7af9c47b3 Merge pull request #4774 from shuujii/adjust-buf-size-in-str_escape
Adjust `buf` size in `str_escape`
2019-10-16 07:36:33 +09:00
KOBAYASHI Shuji b0507e7678 Adjust buf size in str_escape 2019-10-15 19:23:30 +09:00
Yukihiro "Matz" Matsumoto dc474b625b Merge pull request #4773 from shuujii/fix-the-example-of-Array-intersection-in-the-document
Fix the example of `Array#intersection` in the document [ci skip]
2019-10-14 18:56:12 +09:00
KOBAYASHI Shuji ac29638a8a Fix the example of Array#intersection in the document [ci skip] 2019-10-14 18:22:00 +09:00
Yukihiro "Matz" Matsumoto bdacdfaea9 Add Array#intersection which is new in Ruby2.7. 2019-10-14 17:04:19 +09:00
Yukihiro "Matz" Matsumoto 682406a384 Move Array#difference just after Array#-. 2019-10-14 17:04:19 +09:00
Yukihiro "Matz" Matsumoto 67ea80b2bd Fixed a bug in Array#difference. 2019-10-14 17:04:19 +09:00
Yukihiro "Matz" Matsumoto 265034134a Merge pull request #4772 from shuujii/refactor-mrb_class_name_class
Refactor `mrb_class_name_class`
2019-10-13 17:20:46 +09:00
KOBAYASHI Shuji 6377c9bce5 Refactor mrb_class_name_class
- Use `mrb_sym_name_len` instead of `mrb_sym_name` (class name should not
  be escaped).
- Avoid `mrb_str_dup` (it is unnecessary to be shared string because it is
  changed).
2019-10-13 17:03:39 +09:00
Yukihiro "Matz" Matsumoto d128e2d09e Merge pull request #4770 from shuujii/sHARED-string-is-not-required-when-sharing-POOL-string
SHARED string is not required when sharing POOL string
2019-10-12 23:35:43 +09:00
Yukihiro "Matz" Matsumoto 9f3b6ebbde Merge pull request #4769 from shuujii/rename-str_make_shared-to-str_share
Rename `str_make_shared()` to `str_share()` in `src/string.c`
2019-10-12 23:33:20 +09:00
KOBAYASHI Shuji 7594983671 SHARED string is not required when sharing POOL string
The heap string buffer of POOL string always exists, does not need to be
released, and read only, so it can be shared as NOFREE string.
2019-10-12 21:32:56 +09:00
KOBAYASHI Shuji cdd36c979d Rename str_make_shared() to str_share() in src/string.c
Because it may not create `struct mrb_shared_string`.
2019-10-12 12:49:51 +09:00
Yukihiro "Matz" Matsumoto c310c8dc24 Move exception raising to scope_new.
Besides that fix bugs that mistakenly calls `raise_error` that emits
code to raise runtime error instead of `codegen_error` that terminates
code generation immediately.
2019-10-11 20:31:29 +09:00
Yukihiro "Matz" Matsumoto 20ceee794b Merge pull request #4767 from shuujii/remove-unused-exception-classes-in-mruby-io-gem
Remove unused exception classes in `mruby-io` gem
2019-10-11 19:54:44 +09:00
KOBAYASHI Shuji a7ae0d5b9e Remove unused exception classes in mruby-io gem 2019-10-11 11:32:14 +09:00
Yukihiro "Matz" Matsumoto 529a336966 Fixed a bug in mruby-time with NO_GETTIMEOFDAT. 2019-10-10 20:46:12 +09:00
Yukihiro "Matz" Matsumoto 78e54904b5 Silence double free warnings by mrb_local_free().
The warnings were detected by cppcheck.
2019-10-10 20:46:12 +09:00
Yukihiro "Matz" Matsumoto 8fe6a1904c Merge pull request #4764 from shuujii/integrate-mrb_str_inspect-and-mrb_str_dump
Integrate `mrb_str_inspect` and `mrb_str_dump`
2019-10-10 20:45:59 +09:00
KOBAYASHI Shuji 7ce5d33947 Integrate mrb_str_inspect and mrb_str_dump 2019-10-10 19:50:48 +09:00
Yukihiro "Matz" Matsumoto 20aab8a10b Merge pull request #4763 from shuujii/mrdb-Fix-that-print-command-raises-FrozenError
Fix that `print` command raises `FrozenError` in `mrdb`; ref 1f5a7f2f
2019-10-09 22:47:12 +09:00
KOBAYASHI Shuji 7f6e8e8ddc Fix that print command raises FrozenError in mrdb; ref 1f5a7f2f
#### Before this patch:

  ```
  $ echo 'p true' | bin/mrdb /dev/null
  (/dev/null:1) mruby application exited.
  FrozenError: can't modify frozen String
  (-:0)
  ```

#### After this patch:

  ```
  $ echo 'p true' | bin/mrdb /dev/null
  (/dev/null:1) $1 = true
  (/dev/null:1)
  ```
2019-10-09 20:00:17 +09:00
Yukihiro "Matz" Matsumoto 7624e23426 Revert part of #4758 to reduce number of tests.
More tests, more time.
2019-10-09 10:29:04 +09:00
Yukihiro "Matz" Matsumoto 3e9b501ff8 Merge pull request #4761 from take-cheeze/fix_4759
Add mrbgem version field to lock file
2019-10-09 08:01:52 +09:00
take-cheeze f7616c4287 Add mrbgem version field to lock file 2019-10-09 02:22:33 +09:00
Yukihiro "Matz" Matsumoto b68818a8a0 Merge pull request #4758 from shuujii/implement-Ruby2.7-frozen-strings-from-Module-name
Implement Ruby2.7's frozen strings from `Module#name`
2019-10-08 22:25:43 +09:00
Yukihiro "Matz" Matsumoto e348326fa7 Merge pull request #4760 from shuujii/use-mrb_str_concat-instead-of-mrb_str_to_str-plus-mrb_str_cat_str
Use `mrb_str_concat` instead of `mrb_str_to_str` + `mrb_str_cat_str`
2019-10-08 22:23:59 +09:00
KOBAYASHI Shuji 97c62408fb Use mrb_str_concat instead of mrb_str_to_str + mrb_str_cat_str 2019-10-08 18:55:45 +09:00
KOBAYASHI Shuji fb103c1319 Implement Ruby2.7's frozen strings from Module#name 2019-10-08 17:34:13 +09:00
Yukihiro "Matz" Matsumoto b7a8d538c1 Remove unnecessary function: mrb_str_freeze. 2019-10-06 22:18:11 +09:00
Yukihiro "Matz" Matsumoto ff1ac49a72 Merge pull request #4754 from dearblue/get-keyword-args
Get keyword arguments with `mrb_get_args()`
2019-10-06 22:08:15 +09:00
dearblue 5f929d6940 Get keyword arguments with mrb_get_args()
Keyword arguments can now be retrieved with the `:` specifier and
`mrb_kwargs` data.

For the interface, I referred to CRuby's `rb_get_kwargs()`.
For implementation, I referred to `OP_KARG` or etc.
2019-10-06 21:23:55 +09:00
Yukihiro "Matz" Matsumoto ffaa2968ed Merge pull request #4757 from shuujii/refine-the-usage-message-of-mirb-command
Refine the usage message of `mirb` command
2019-10-06 20:23:30 +09:00
Yukihiro "Matz" Matsumoto 028ab5a143 Merge pull request #4755 from shuujii/refine-the-usage-message-of-mruby-command
Refine the usage message of `mruby` command
2019-10-06 20:23:04 +09:00
KOBAYASHI Shuji ea14df2e3a Refine the usage message of mirb command 2019-10-06 20:12:28 +09:00
KOBAYASHI Shuji 0cdc984b1c Refine the usage message of mruby command 2019-10-06 19:35:41 +09:00
Yukihiro "Matz" Matsumoto c613813364 Merge pull request #4752 from shuujii/drop-initialization-dependency-from-mruby-print-to-mruby-sprintf
Drop initialization dependency from `mruby-print` to `mruby-sprintf`
2019-10-05 17:18:12 +09:00
KOBAYASHI Shuji 1d8456fe7d Drop initialization dependency from mruby-print to mruby-sprintf
In the old implementation, `Kernel#printf` raise error if `mruby-sprintf`
gem isn't specified before `mruby-print` gem. The new implementation
eliminates this ordering issue. This way is the same as `Kernel#printf` and
`IO#printf` in `mruby-io` gem.
2019-10-05 15:22:43 +09:00
Yukihiro "Matz" Matsumoto 1f5a7f2f49 Freeze strings from nil.to_s, true.to_s, false.to_s.
This is an experimental changes in Ruby 2.7.
2019-10-04 16:02:50 +09:00
Yukihiro "Matz" Matsumoto 08eafe21d3 Implement Ruby2.7's frozen strings from Symbol#to_s. 2019-10-04 14:42:01 +09:00
Yukihiro "Matz" Matsumoto 264239f78f Refactor local variables addition in optional/keyword arguments. 2019-10-04 14:39:53 +09:00
Yukihiro "Matz" Matsumoto d4e9de84c5 Merge pull request #4751 from shuujii/remove-unused-code-to-old-Visual-Studio
Remove unused code to old Visual Studio in `tasks/toolchains/visualcpp.rake`
2019-10-04 10:11:30 +09:00
KOBAYASHI Shuji edd412966e Remove unused code to old Visual Studio in tasks/toolchains/visualcpp.rake 2019-10-04 09:31:54 +09:00
Yukihiro "Matz" Matsumoto 4695542f37 Merge pull request #4750 from dearblue/c++-abi
Remove duplicates header files in `src/pool.c`
2019-10-04 08:03:38 +09:00
dearblue fab062f7b5 Remove duplicates header files in src/pool.c
These are included in `mruby.h`.

As a background, if `enable_cxx_abi` is specified, the macro that
defines the maximum value in `stdint.h` is undefined depending on the
environment.

- Confirmed with gcc on FreeBSD 12.0 and mingw32-gcc available on
  FreeBSD.
- `INTPTR_MAX`, `INT64_MAX` and `UINT64_MAX` are defined by `cstdint`
  added in C++11. But `toolchains :gcc` adds `-std=c++03`, so the macros
  are not defined.
- To have these defined in `C++03`, `__STDC_CONSTANT_MACROS` must be
  defined in advance. This is already done by `mruby.h`.
2019-10-03 23:32:24 +09:00
Yukihiro "Matz" Matsumoto de176d37e0 Merge pull request #4749 from shuujii/add-tests-for-4746
Add tests for #4746
2019-10-03 21:30:23 +09:00
KOBAYASHI Shuji 882bc80dd0 Add tests for #4746 2019-10-03 16:59:18 +09:00
Yukihiro "Matz" Matsumoto 3d2781311e Merge pull request #4748 from HirohitoHigashi/master
Fix opcode semantics comment miss.
2019-10-03 15:18:06 +09:00
Hirohito Higashi 63496a6730 Fix opcode semantics comment miss. (op_jmpnil) 2019-10-03 15:06:06 +09:00
Hirohito Higashi b4bf7a2282 Fix opcode semantics comment miss. 2019-10-03 14:44:47 +09:00
Yukihiro "Matz" Matsumoto ec6c8b2a3c Add local variable reordering to kwargs; ref #4746 2019-10-03 09:17:37 +09:00
Yukihiro "Matz" Matsumoto 47cdda370e Need to reorder local variables defined in opt; fix #4746
For example, local variables in the following def:
```ruby
def foo(a = (not_set = true), &block)
  ...
end
```
should be `a, block, not_set`, but were `a, not_set, block`.
2019-10-03 07:52:31 +09:00
Yukihiro "Matz" Matsumoto 306f02117b Refactor append_gen function. 2019-10-03 07:52:03 +09:00
Yukihiro "Matz" Matsumoto a406a35cf8 Merge pull request #4747 from shuujii/avoid-symhash-call-for-inline-symbol-in-sym_intern
Avoid `symhash()` call for inline symbol in `sym_intern()`
2019-10-02 23:36:32 +09:00
KOBAYASHI Shuji 855d996847 Avoid symhash() call for inline symbol in sym_intern() 2019-10-02 16:56:22 +09:00
Yukihiro "Matz" Matsumoto c33100c4f0 Merge pull request #4736 from dearblue/ast-strdump
Escape the AST string
2019-10-02 07:07:20 +09:00
Yukihiro "Matz" Matsumoto 97433c0263 Merge pull request #4745 from shuujii/dump-more-node-types
Dump more node types in `mrb_parser_dump`
2019-10-01 19:35:11 +09:00
KOBAYASHI Shuji 8df2763b56 Support NODE_LITERAL_DELIM in mrb_parser_dump
#### Before this patch:

  ```terminal
  $ bin/mruby -v -e '%w[1 2]'
  mruby 2.0.1 (2019-04-04)
  00001 NODE_SCOPE:
  00001   NODE_BEGIN:
  00001     NODE_WORDS:
  00001       NODE_STR "1" len 1
  00001       node type: 85 (0x55)
  00001       NODE_STR "2" len 1
  (snip)
  ```

#### After this patch:

  ```terminal
  $ bin/mruby -v -e '%w[1 2]'
  mruby 2.0.1 (2019-04-04)
  00001 NODE_SCOPE:
  00001   NODE_BEGIN:
  00001     NODE_WORDS:
  00001       NODE_STR "1" len 1
  00001       NODE_LITERAL_DELIM
  00001       NODE_STR "2" len 1
  (snip)
  ```
2019-10-01 17:20:39 +09:00
KOBAYASHI Shuji 42c7f2d6b0 Support NODE_SYMBOLS in mrb_parser_dump
#### Before this patch:

  ```terminal
  $ bin/mruby -v -e '%i[1]; %I[#{2}]'
  mruby 2.0.1 (2019-04-04)
  00001 NODE_SCOPE:
  00001   NODE_BEGIN:
  00001     node type: 87 (0x57)
  00001     node type: 87 (0x57)
  (snip)
  ```

#### After this patch:

  ```terminal
  $ bin/mruby -v -e '%i[1]; %I[#{2}]'
  mruby 2.0.1 (2019-04-04)
  00001 NODE_SCOPE:
  00001   NODE_BEGIN:
  00001     NODE_SYMBOLS:
  00001       NODE_STR "1" len 1
  00001     NODE_SYMBOLS:
  00001       NODE_STR "" len 0
  00001       NODE_BEGIN:
  00001         NODE_INT 2 base 10
  00001       NODE_STR "" len 0
  (snip)
  ```
2019-10-01 17:10:34 +09:00
KOBAYASHI Shuji 732ef6b10e Support NODE_WORDS in mrb_parser_dump
#### Before this patch:

  ```terminal
  $ bin/mruby -v -e '%w[1]; %W[#{2}]'
  mruby 2.0.1 (2019-04-04)
  00001 NODE_SCOPE:
  00001   NODE_BEGIN:
  00001     node type: 86 (0x56)
  00001     node type: 86 (0x56)
  (snip)
  ```

#### After this patch:

  ```terminal
  $ bin/mruby -v -e '%w[1]; %W[#{2}]'
  mruby 2.0.1 (2019-04-04)
  00001 NODE_SCOPE:
  00001   NODE_BEGIN:
  00001     NODE_WORDS:
  00001       NODE_STR "1" len 1
  00001     NODE_WORDS:
  00001       NODE_STR "" len 0
  00001       NODE_BEGIN:
  00001         NODE_INT 2 base 10
  00001       NODE_STR "" len 0
  (snip)
  ```
2019-10-01 17:07:30 +09:00
Yukihiro "Matz" Matsumoto cdb35a12fc Merge pull request #4744 from shuujii/remove-a-trailing-space-in-MRUBY_DESCRIPTION
Remove a trailing space in `MRUBY_DESCRIPTION`
2019-10-01 12:16:27 +09:00
KOBAYASHI Shuji 482d0626b8 Remove a trailing space in MRUBY_DESCRIPTION 2019-09-30 21:39:13 +09:00
KOBAYASHI Shuji 16745261e3 Support NODE_DSYM in mrb_parser_dump
#### Before this patch:

  ```terminal
  $ bin/mruby -v -e ':"#{1}"; ["#{2}": 0]'
  mruby 2.0.1 (2019-04-04)
  00001 NODE_SCOPE:
  00001   NODE_BEGIN:
  00001     node type: 83 (0x53)
  00001     NODE_ARRAY:
  00001       NODE_KW_HASH:
  00001         key:
  00001           node type: 83 (0x53)
  00001         value:
  00001           NODE_INT 0 base 10
  (snip)
  ```

#### After this patch:

  ```terminal
  $ bin/mruby -v -e ':"#{1}"; ["#{2}": 0]'
  mruby 2.0.1 (2019-04-04)
  00001 NODE_SCOPE:
  00001   NODE_BEGIN:
  00001     NODE_DSYM:
  00001       NODE_DSTR:
  00001         NODE_STR "" len 0
  00001         NODE_BEGIN:
  00001           NODE_INT 1 base 10
  00001         NODE_STR "" len 0
  00001     NODE_ARRAY:
  00001       NODE_KW_HASH:
  00001         key:
  00001           NODE_DSYM:
  00001             NODE_DSTR:
  00001               NODE_STR "" len 0
  00001               NODE_BEGIN:
  00001                 NODE_INT 2 base 10
  00001               NODE_STR "" len 0
  00001         value:
  00001           NODE_INT 0 base 10
  (snip)
  ```
2019-09-30 11:54:51 +09:00
Yukihiro "Matz" Matsumoto 9ddde3be39 Merge pull request #4742 from dearblue/mrb_hash_value
Remove unnecessary type `mrb_hash_value`
2019-09-30 03:06:56 +09:00
dearblue 40e8a90e89 Remove unnecessary type mrb_hash_value
The type `mrb_hash_value` is no longer used by the segmented list
implementation (ref e8dcfe1 and e65d426).
2019-09-29 23:55:38 +09:00
Yukihiro "Matz" Matsumoto 4621907fca Merge pull request #4741 from shuujii/print-missing-colon-before-newline-in-mrb_parser_dump
Print missing `:` before newline in `mrb_parser_dump`
2019-09-29 22:05:41 +09:00
KOBAYASHI Shuji a5d140ae42 Print missing : before newline in mrb_parser_dump 2019-09-29 17:14:52 +09:00
Yukihiro "Matz" Matsumoto e55f881bc2 Merge pull request #4740 from dearblue/rethrow-break
Allow rethrowing `MRB_TT_BREAK`
2019-09-29 15:38:16 +09:00
dearblue d8f1099419 Allow rethrowing MRB_TT_BREAK 2019-09-29 15:11:36 +09:00
Yukihiro "Matz" Matsumoto ccf7a8248f Merge pull request #4739 from dearblue/restore-arena
Restore GC arena frequently
2019-09-29 14:40:29 +09:00
Yukihiro "Matz" Matsumoto a1886942eb Further refactoring over #4738 2019-09-29 14:30:41 +09:00
Yukihiro "Matz" Matsumoto c5d500d51e Merge pull request #4738 from dearblue/unneed-assign
Remove unnecessary assignments
2019-09-29 14:29:07 +09:00
dearblue 39855a3304 Restore GC arena frequently 2019-09-29 13:57:22 +09:00
Yukihiro "Matz" Matsumoto 704c40bfa2 Merge pull request #4737 from dearblue/hash-delete
Add an annotation about the return value
2019-09-29 13:56:31 +09:00
Yukihiro "Matz" Matsumoto bbfd64d01b Add an annotation of the return value from mrb_delete_key; #4737
The return value from `mrb_delete_key` needs to be protected from GC in
some cases.
2019-09-29 13:53:45 +09:00
dearblue e48207cdb3 Remove unnecessary assignments 2019-09-29 13:45:16 +09:00
Yukihiro "Matz" Matsumoto acbea6affe Merge pull request #4735 from shuujii/remove-unused-node-type-in-codegen
Remove unused node type in `codegen()`
2019-09-29 12:47:16 +09:00
dearblue f6d3d675ab Add an annotation about the return value 2019-09-29 11:49:15 +09:00
dearblue e2f54ff594 Escape the AST string 2019-09-29 10:39:55 +09:00
KOBAYASHI Shuji ae530d89c4 Remove unused node type in codegen() 2019-09-28 15:15:31 +09:00
Yukihiro "Matz" Matsumoto 19e4f56c67 Merge pull request #4734 from shuujii/simplify-arguments-check-in-String-rindex
Simplify arguments check in `String#rindex`
2019-09-28 00:20:01 +09:00
Yukihiro "Matz" Matsumoto 2de757eef0 Replace mrb_sym_name with mrb_sym_dump; ref #4684 2019-09-28 00:06:01 +09:00
KOBAYASHI Shuji 198683e914 Simplify arguments check in String#rindex
Also fix document about type of the first argument.
2019-09-27 17:13:57 +09:00
Yukihiro "Matz" Matsumoto 5cd6ed4511 Merge pull request #4733 from shuujii/use-type-predicate-macros-instead-of-mrb_type-if-possible
Use type predicate macros instead of `mrb_type` if possible
2019-09-27 00:00:03 +09:00
Yukihiro "Matz" Matsumoto d4be545d54 Fixed codedump for human readable symbol format; ref #4684 2019-09-26 23:56:40 +09:00
KOBAYASHI Shuji feaf80d899 Use type predicate macros instead of mrb_type if possible
For efficiency with `MRB_WORD_BOXING` (implement type predicate macros for
all `enum mrb_vtype`).
2019-09-26 22:23:27 +09:00
Yukihiro "Matz" Matsumoto 60cc46a92c Use proper type specifier for mrb_raisef(); ref #4731
The following two may be different:
* `%d` for `int`
* `%i` for `mrb_int`
2019-09-26 09:48:01 +09:00
Yukihiro "Matz" Matsumoto 184aeb0694 Merge pull request #4732 from dearblue/inttypes
Use inttypes for `snprintf()`
2019-09-26 06:31:07 +09:00
Yukihiro "Matz" Matsumoto 0d661bcca6 Merge pull request #4731 from dearblue/consistent-type
Keep the type of `posarg` consistent
2019-09-26 06:30:55 +09:00
Yukihiro "Matz" Matsumoto 9bf193b49a Merge pull request #4728 from shuujii/remove-MRB_TT_HAS_BASIC-macro
Remove `MRB_TT_HAS_BASIC` macro
2019-09-25 23:55:55 +09:00
Yukihiro "Matz" Matsumoto 5c381032b0 Merge pull request #4729 from dearblue/fix-4598
Fix `MRB_WITHOUT_FLOAT` reversal; fix #4598
2019-09-25 23:55:36 +09:00
Yukihiro "Matz" Matsumoto b5fa2dadfc Merge pull request #4730 from dearblue/fall-through
Add "fall through"
2019-09-25 23:53:34 +09:00
Yukihiro "Matz" Matsumoto a365f9a67d Rename symbol-to-string functions; close #4684
* mrb_sym2name -> mrb_sym_name
* mrb_sym2name_len -> mrb_sym_name_len
* mrb_sym2str -> mrb_sym_str
2019-09-25 23:52:00 +09:00
dearblue 84d9296c05 Use inttypes for snprintf() 2019-09-25 23:28:05 +09:00
dearblue 9f6ba4bfa1 Keep the type of posarg consistent
Match the type with the caller and related functions.
2019-09-25 23:17:06 +09:00
dearblue 5ce1bec1bc Add "fall through" 2019-09-25 23:07:05 +09:00
dearblue eb2f34719d Fix MRB_WITHOUT_FLOAT reversal; fix #4598 2019-09-25 22:55:41 +09:00
KOBAYASHI Shuji 27e8ea4ea2 Remove MRB_TT_HAS_BASIC macro
The value of `MRB_TT_HAS_BASIC` is meaningless because `MRB_TT_HAS_BASIC` is
no longer used with `MRB_WORD_BOXING` at b2c3d88f.
2019-09-25 18:17:01 +09:00
Yukihiro "Matz" Matsumoto 3c1a2612e7 Merge pull request #4727 from shuujii/exception-initialize-should-not-allow-two-or-more-arguments
`Exception#initialize` should not allow two or more arguments
2019-09-24 23:01:13 +09:00
KOBAYASHI Shuji 07856a7e8f Exception#initialize should not allow two or more arguments 2019-09-24 21:43:46 +09:00
Yukihiro "Matz" Matsumoto 4f0f712b51 Merge pull request #4726 from shuujii/fix-Fixnum-overflow-test-in-Integer-lshift-test
Fix `Fixnum` overflow test in `Integer#<<` test
2019-09-23 23:27:15 +09:00
KOBAYASHI Shuji 549317a36b Fix Fixnum overflow test in Integer#<< test
- Skip when `MRB_WITHOUT_FLOAT` is defined.
- Make `Fixnum` overflow even when `MRB_INT64` is defined.
2019-09-23 21:59:35 +09:00
Yukihiro "Matz" Matsumoto a4f2e1276c Merge pull request #4725 from shuujii/implement-all-type-predicate-macros-for-MRB_WORD_BOXING
Implement all type predicate macros for `MRB_WORD_BOXING`
2019-09-23 03:30:24 +09:00
KOBAYASHI Shuji 5dda4f5da3 Implement all type predicate macros for MRB_WORD_BOXING
The default implementations of type predicate macros use `mrb_type`.
But `mrb_type` with `MRB_WORD_BOXING` isn't very efficient, so the new
implementations avoid `mrb_type`.
2019-09-22 22:36:12 +09:00
Yukihiro "Matz" Matsumoto 046b116c18 Merge pull request #4716 from MaskRay/rodata
Rename MRB_USE_ETEXT_EDATA to MRB_USE_LINK_TIME_RO_DATA_P and support lld linked programs
2019-09-22 17:00:49 +09:00
Fangrui Song 7f044341f9 Rename MRB_USE_ETEXT_EDATA to MRB_USE_LINK_TIME_RO_DATA_P and support lld linked programs
In lld linked programs, .rodata comes before .text, thus mrb_ro_data_p
will return false for strings in .rodata. Change the lower bound from
_etext to __ehdr_start to catch these cases. This works for ld.bfd, gold
and lld, and it does not have false positives even if .init_array does
not exist.

Remove the branch that uses _edata: strings in .data can be modified so
this is semantically incorrect. Delete the __APPLE__ branch (its
manpages say get_etext() and get_edata() are strongly discouraged).
.init_array has been adopted by most ELF platforms to supersede .ctors.

Neither _etext nor _edata is used, so rename MRB_USE_ETEXT_EDATA to
MRB_USE_EHDR_START.
2019-09-21 17:55:14 -07:00
Yukihiro "Matz" Matsumoto 8db7dfb5c4 Merge pull request #4724 from shuujii/use-mrb_define_method-instead-of-mrb_define_alias
Use `mrb_define_method` instead of `mrb_define_alias`
2019-09-21 17:50:21 +09:00
KOBAYASHI Shuji f252ab0770 Use mrb_define_method instead of mrb_define_alias 2019-09-21 16:51:10 +09:00
Yukihiro "Matz" Matsumoto 15701a32f5 Fix compatibility issue of class variables.
Singleton class definition do not introduce its own class variable scope
in CRuby/JRuby. So should mruby.

```
module Mod1
  class << Object.new

    C = 1
    @@cv = 1

    p Module.nesting,        # => [#<Class:#<Object:0x55cb16e60a50>>, Mod1]
      constants,             # => [:C]
      class_variables,       # => []
      Mod1.class_variables   # => [:@@cv]
  end
end
```
2019-09-20 13:07:58 +09:00
Yukihiro "Matz" Matsumoto 683baec4f0 Add optional argument to Module#class_variables. 2019-09-20 13:07:58 +09:00
Yukihiro "Matz" Matsumoto 01ce5824f0 Merge pull request #4723 from shuujii/fix-typo-in-Array-difference-document
Fix typo in `Array#difference` document [ci skip]
2019-09-20 09:46:19 +09:00
KOBAYASHI Shuji 1fb4e73981 Fix typo in Array#difference document [ci skip] 2019-09-20 09:28:56 +09:00
Yukihiro "Matz" Matsumoto 21c0c78d2e Merge pull request #4722 from shuujii/simplify-arguments-check-in-String-index
Simplify arguments check in `String#index`
2019-09-20 08:02:14 +09:00
KOBAYASHI Shuji e61095426b Simplify arguments check in String#index
Also fix document about type of the first argument.
2019-09-19 20:19:38 +09:00
Yukihiro "Matz" Matsumoto 77f00d5006 Merge pull request #4720 from shuujii/fix-Enumerable-filter_map-without-block
Fix `Enumerable#filter_map` without block; ref d380c7d2
2019-09-18 21:52:28 +09:00
KOBAYASHI Shuji c7c344dbc2 Fix Enumerable#filter_map without block; ref d380c7d2 2019-09-18 19:33:15 +09:00
Yukihiro "Matz" Matsumoto c20dda4f4c Merge pull request #4719 from shuujii/remove-unneeded-mrb_get_args
Remove `mrb_get_args(mrb, "")`; ref 30f37872
2019-09-18 17:14:00 +09:00
KOBAYASHI Shuji 0bedd900b9 Remove mrb_get_args(mrb, ""); ref 30f37872 2019-09-18 16:07:21 +09:00
Yukihiro "Matz" Matsumoto ca2d47c20f Fix super from aliased methods to work correctly; fix #4718
We needed to preserve the original method name somewhere. We kept it in
the `env` structure pointed from aliased methods. #1457 and #1531 tried
to address this issue. But this patch is more memory efficient.

Limitation: this fix does not support `super` from methods defined by
`define_method`. This limitation may be addressed in the future, but
it's low priority.
2019-09-18 10:31:28 +09:00
Yukihiro "Matz" Matsumoto 47add060cc Merge pull request #4717 from shuujii/fix-Fixnum-to_s-inspect-argument-specs
Fix `Fixnum#(to_s|inspect)` argument specs
2019-09-17 13:39:51 +09:00
KOBAYASHI Shuji 2f7175442f Fix Fixnum#(to_s|inspect) argument specs
Before this patch:

  $ bin/mruby -e 'p 3.to_s(2)'
  trace (most recent call last):
    [0] -e:1
  -e:1: 'to_s': wrong number of arguments (1 for 0) (ArgumentError)

After this patch:

  $ bin/mruby -e 'p 3.to_s(2)'
  "11"
2019-09-17 09:28:51 +09:00
Yukihiro "Matz" Matsumoto 88cd1d6593 Merge pull request #4714 from dearblue/shrink-mrb_get_args
Shrink `mrb_get_args()`
2019-09-17 08:41:51 +09:00
Yukihiro "Matz" Matsumoto cc636f334f Merge pull request #4715 from dearblue/need-block
Entrust "no block given" error to `mrb_get_args()`
2019-09-17 08:40:03 +09:00
Yukihiro "Matz" Matsumoto d45c94fe1c Merge pull request #4713 from shuujii/fix-argument-specs-to-Enumerable
Fix argument specs to `Enumerable`
2019-09-17 08:31:18 +09:00
dearblue 099a4f3969 Entrust "no block given" error to mrb_get_args()
Some error messages will be changed.
2019-09-16 20:29:58 +09:00
dearblue 62499c6250 Shrink mrb_get_args()
As a side effect, all specifiers now accept the `!` modifier.
2019-09-16 18:14:00 +09:00
dearblue f312638ecd Cache argv first in each specifiers for mrb_get_args(); ref #3090
In terms of specifiers, argv is never referenced after a method call as
shown in #3090.

Reduction of object code can be expected.

If you need to refer to argv after a method call in the same loop,
update argv after the method call.
2019-09-16 18:14:00 +09:00
Yukihiro "Matz" Matsumoto 2f9b1fdb0c Merge pull request #4255 from shuujii/enumerator-size-is-not-supported
`Enumerator#size` is not supported [ci skip]
2019-09-16 15:37:58 +09:00
KOBAYASHI Shuji b3b55132a9 Fix argument specs to Enumerable 2019-09-16 11:58:35 +09:00
Yukihiro "Matz" Matsumoto 2256bb07b0 Remove MRB_METHOD_TABLE_INLINE.
`MRB_METHOD_TABLE_INLINE` was fragile. It requires `-falign-functions=n`.
On platform that uses higher bits of function pointers, you can use new
`MRB_METHOD_T_STRUCT` configuration macro.
2019-09-16 11:14:13 +09:00
Yukihiro "Matz" Matsumoto 30f3787248 Raise ArgumentError by aspec check; ref #4688
This is partial `aspec` check that only checks `MRB_ARGS_NONE()`.
2019-09-16 10:50:31 +09:00
Yukihiro "Matz" Matsumoto 2764fdf9f0 Share common definition of MRB_METHOD_FUNC_FL. 2019-09-16 10:10:09 +09:00
Yukihiro "Matz" Matsumoto 0eb9355acd Use bit shifting to pack function pointers to mrb_method_t.
So you don't need `-falign-functions=2` anymore. Instead your platform
must not use higher bits of the pointer (true for most platforms).
If not, you have to use `struct mrb_method_t` version.
2019-09-16 10:10:09 +09:00
Yukihiro "Matz" Matsumoto 743d480fba Refactor mrb_method_t. 2019-09-16 10:10:09 +09:00
Yukihiro "Matz" Matsumoto a57b6f8ed0 Implement Enumerable tally from Ruby2.7. 2019-09-16 10:10:09 +09:00
Yukihiro "Matz" Matsumoto d380c7d26f Implement filter_map from Ruby2.6. 2019-09-16 10:10:09 +09:00
Yukihiro "Matz" Matsumoto 57a0132b41 Add filter aliases for Enumerable and Hash. 2019-09-16 10:10:09 +09:00
Yukihiro "Matz" Matsumoto f4117d81d2 Add Array#difference method from Ruby2.6. 2019-09-16 10:10:09 +09:00
Yukihiro "Matz" Matsumoto 3daa53ce63 Implement bind_call method from Ruby2.7. 2019-09-16 10:10:09 +09:00
Yukihiro "Matz" Matsumoto a016d1d0ff Merge branch 'dearblue-mruby-io' 2019-09-16 07:45:42 +09:00
Yukihiro "Matz" Matsumoto 6de1c64a9c Add small fix over #4712 2019-09-16 07:44:51 +09:00
dearblue 992ba476a9 Fix broken UTF-8 characters by IO#getc
Character (multi-byte UTF-8) is destroyed when character spanning
`IO::BUF_SIZE` (4096 bytes) exist.

- Prepare file:

  ```ruby
  File.open("sample", "wb") { |f| f << "●" * 1370 }
  ```

- Before patched:

  ```ruby
  File.open("sample") { |f| a = []; while ch = f.getc; a << ch; end; p a }
  # => ["●", "●", ..., "●", "\xe2", "\x97", "\x8f", "●", "●", "●", "●"]

- After patched:

  ```ruby
  File.open("sample") { |f| a = []; while ch = f.getc; a << ch; end; p a }
  # => ["●", "●", ..., "●", "●", "●", "●", "●", "●"]
2019-09-16 00:26:41 +09:00
dearblue 7cc8c7d2ff Small improvement for mruby-io 2019-09-16 00:11:43 +09:00
dearblue 52a0ad4108 Fix IO#pos 2019-09-16 00:11:43 +09:00
dearblue 77368ce762 Revert part of 8c90b5fc6
`IO#readline` and `IO#readchar` process in character units.
2019-09-16 00:11:43 +09:00
Yukihiro "Matz" Matsumoto 0734d9f314 Merge pull request #4512 from lopopolo/patch-1
Support parsing a Regexp literal with 'o' option
2019-09-15 18:19:59 +09:00
Yukihiro "Matz" Matsumoto e790fb5128 Merge pull request #4710 from shuujii/refactor-mrb_type-in-include-mruby-boxing_word.h
Refactor `mrb_type` in `include/mruby/boxing_word.h`
2019-09-15 18:19:27 +09:00
KOBAYASHI Shuji 7fcda585bc Refactor mrb_type in include/mruby/boxing_word.h 2019-09-15 18:11:16 +09:00
Yukihiro "Matz" Matsumoto 76355dee68 Add unavailability of declaration form of visibility methods; #4708 2019-09-14 23:21:44 +09:00
Yukihiro "Matz" Matsumoto 28bbd3e7d9 Add argument names to C function prototypes. 2019-09-14 23:21:44 +09:00
Yukihiro "Matz" Matsumoto 57d7fe94a9 Add a macro mrb_frozen_p that points to MRB_FROZEN_P. 2019-09-14 23:21:44 +09:00
Yukihiro "Matz" Matsumoto 6f1c08f7d8 Replace String#byteslice by custom IO._bufread.
`byteslice` creates 2 string objects. `_bufread` creates one, and
modifies the original buffer string, that is more efficient.
2019-09-14 23:21:44 +09:00
Yukihiro "Matz" Matsumoto dcc2d44d93 Merge pull request #4707 from shuujii/use-%C-to-mrb_name_error-in-mrb_method_search
Use `%C` to `mrb_name_error` in `mrb_method_search`; ref 5890c7d5
2019-09-14 14:35:36 +09:00
KOBAYASHI Shuji 2f74a97d04 Use %C to mrb_name_error in mrb_method_search; ref 5890c7d5 2019-09-14 11:28:02 +09:00
Yukihiro "Matz" Matsumoto 6620b1cdcb Revert "Update %pure-parser to %define api.pure for newer bison; fix #4706"
The `bison` on MacOS does not support `%define api.pure`.
This reverts commit f7c9f1f796.
2019-09-14 10:28:07 +09:00
Yukihiro "Matz" Matsumoto f7c9f1f796 Update %pure-parser to %define api.pure for newer bison; fix #4706 2019-09-14 09:05:32 +09:00
Yukihiro "Matz" Matsumoto 76f1aa7de5 Remove mrb_funcall from <=> operations. 2019-09-14 09:05:32 +09:00
Yukihiro "Matz" Matsumoto fcd3f8450d Raise an error from String#<=> with a non string operand. 2019-09-14 09:05:32 +09:00
Yukihiro "Matz" Matsumoto 34cdff5ee4 Use mrb_equal instead of mrb_funcall.
In the typical case, `mrb_funcall` invocation would be skipped.
2019-09-14 09:05:32 +09:00
Yukihiro "Matz" Matsumoto 5890c7d516 Remove mrb_funcall from mrb_method_search. 2019-09-14 09:05:32 +09:00
Yukihiro "Matz" Matsumoto 2fa4a55e80 Replace loop method with while true loop to gain performance. 2019-09-14 09:05:32 +09:00
Yukihiro "Matz" Matsumoto 5489fae8f2 Merge pull request #4705 from shuujii/revert-part-of-Refine-tasks-toolchains-gcc-clang.rake
Revert part of "Refine `tasks/toolchains/(gcc|clang).rake`" (07c6b7f0)
2019-09-13 22:55:50 +09:00
KOBAYASHI Shuji 895ab2342e Revert part of "Refine tasks/toolchains/(gcc|clang).rake" (07c6b7f0)
`-Wzero-length-array` is not a mandatory option, so the original is better.
2019-09-13 21:28:23 +09:00
Yukihiro "Matz" Matsumoto 1e82b1958b Merge pull request #4704 from shuujii/fix-warnings-for-invalid-C++-option-with-enable_cxx_abi
Fix warnings for invalid C++ option with `enable_cxx_abi`; ref #3618, #4703
2019-09-13 19:59:40 +09:00
KOBAYASHI Shuji be76cec342 Fix warnings for invalid C++ option with enable_cxx_abi; ref #3618, #4703 2019-09-13 17:14:37 +09:00
Yukihiro "Matz" Matsumoto ad4bdda074 Update assert_take for zero size take. 2019-09-13 02:28:56 +09:00
Yukihiro "Matz" Matsumoto f5542b9927 Add Enumerator.produce from Ruby2.7 2019-09-13 02:28:56 +09:00
Yukihiro "Matz" Matsumoto d4af765651 Remove -std=gnu99 when enable_cxx_abi; ref #4703
To stop warnings since C++ do not accept `-std=gnu99` option.
2019-09-13 02:23:16 +09:00
Yukihiro "Matz" Matsumoto 5a0204bb45 Remove unnecessary files from mruby-{io,pack,socket}. 2019-09-13 02:23:16 +09:00
Yukihiro "Matz" Matsumoto 915bb4e206 Merge pull request #4703 from shuujii/refine-tasks-toolchains-gcc-clang.rake
Refine `tasks/toolchains/(gcc|clang).rake`
2019-09-12 22:53:47 +09:00
KOBAYASHI Shuji 07c6b7f0ab Refine tasks/toolchains/(gcc|clang).rake
- Make sure to specify `-std=gnu99` for C compiler flag.
- Make sure to specify `-Wzero-length-array` for C/C++ compiler flag (Clang).
- Extract similar codes.
2019-09-12 21:45:47 +09:00
Yukihiro "Matz" Matsumoto 231a1d68b0 Remove $/ from mruby implementation.
1. `$/` and other Perl-ish global variables are not defined in ISO.
2. The current Ruby policy do not encourage those variables.
3. Those variables has global effect and can cause troubles.
2019-09-12 21:22:59 +09:00
Yukihiro "Matz" Matsumoto 6bbdb97e75 Merge pull request #4527 from lopopolo/string-each-line-paragraph-mode
Add paragraph mode to String#each_line in mrblib
2019-09-12 21:19:42 +09:00
Yukihiro "Matz" Matsumoto b98bf36a15 Use mrb_str_inspect instead of mrb_str_dup; fix #4678 2019-09-12 17:15:55 +09:00
Yukihiro "Matz" Matsumoto 9383e9d469 Removed unnecessary files from mruby-sleep; #4702 2019-09-12 06:54:09 +09:00
Yukihiro "Matz" Matsumoto 13c3802073 Remove Rakefile from mruby-sleep gem; fix #4702
The `Rakefile` was a leftover from the time it was an independent gem.
2019-09-11 20:28:52 +09:00
Yukihiro "Matz" Matsumoto 04b098d000 Move tests related to getbyte, setbyte, byteslice` to core. 2019-09-11 18:49:08 +09:00
Yukihiro "Matz" Matsumoto 8c90b5fc6a Fixed length for IO should be in bytes, not in characters; #4696
E.g. `io.read(5)` should read 5 byte string, not 5 characters.
2019-09-11 18:47:39 +09:00
Yukihiro "Matz" Matsumoto ec3aeede20 Move String#{getbyte,setbyte,byteslice} to the core; #4696
Unlike CRuby, there's no way to process strings byte-wise by core
methods because there's no per string encoding in mruby, so that
we moved 3 byte-wise operation methods from `mruby-string-ext` gem.
2019-09-11 18:47:39 +09:00
Yukihiro "Matz" Matsumoto 08d4e7c0c4 Merge pull request #4701 from shuujii/drop-test-dependency-from-mruby-string-ext-to-mruby-enumerator
Drop test dependency from `mruby-string-ext` to `mruby-enumerator`
2019-09-11 18:47:27 +09:00
KOBAYASHI Shuji fab781cf8b Drop test dependency from mruby-string-ext to mruby-enumerator 2019-09-11 10:35:52 +09:00
Yukihiro "Matz" Matsumoto 896f3fe703 Merge pull request #4700 from shuujii/refine-documentation-for-C99-compliance
Refine documentation for C99 compliance; ref #4685 [ci skip]
2019-09-10 17:00:29 +09:00
KOBAYASHI Shuji 1c1ebb1833 Refine documentation for C99 compliance; ref #4685 [ci skip]
The refinement was based on comment from @matz.
2019-09-10 16:49:14 +09:00
Yukihiro "Matz" Matsumoto 080f7baeaf Merge pull request #4699 from takkaw/mirb_lv_under_score
add special local variable _ in mirb
2019-09-10 09:24:27 +09:00
takkaw 3f70e3a81f change _ variable in mirb to be enable by default 2019-09-09 23:40:51 +09:00
Yukihiro "Matz" Matsumoto 9d9cb0ab6a Fix mod.constants not to have duplicate constant names; #4698
The fix was based on PR from @dearblue
2019-09-09 23:14:07 +09:00
Yukihiro "Matz" Matsumoto a1a838d966 Remove duplication of BasicObject constant; fix #4698 2019-09-09 23:14:07 +09:00
Yukihiro "Matz" Matsumoto 6b157397ba Merge pull request #4697 from shuujii/fix-Class.new-argument-specs
Fix `Class.new` argument specs
2019-09-09 22:51:15 +09:00
takkaw e28451585d add special local variable _ in mirb 2019-09-09 22:32:10 +09:00
KOBAYASHI Shuji b156aa2cf6 Fix Class.new argument specs 2019-09-09 21:37:35 +09:00
Yukihiro "Matz" Matsumoto 715afd6fdb Merge pull request #4695 from dearblue/promote-to-int
Fix `mrb_vformat()` crashes with `MRB_INT16`
2019-09-08 22:46:25 +09:00
Yukihiro "Matz" Matsumoto 801343b56b Merge pull request #4694 from shuujii/optimize-mrb_bool-with-MRB_WORD_BOXING
Optimize `mrb_bool()` with `MRB_WORD_BOXING`
2019-09-08 22:44:07 +09:00
dearblue 311d867deb Fix mrb_vformat() crashes with MRB_INT16
If `MRB_INT16` is specified, the variable length argument `mrb_int` is
converted to `int`.
2019-09-08 20:31:35 +09:00
KOBAYASHI Shuji d47bd0a2cd Optimize mrb_bool() with MRB_WORD_BOXING 2019-09-08 12:17:25 +09:00
Yukihiro "Matz" Matsumoto 9d08025b8b Revert part of #4225
Since in mruby, Integer and Float interchange frequently (mostly on
overflow), so adding explicit `.0` can cause problems sometimes.

For example:
https://github.com/mattn/mruby-json/pull/40
https://github.com/pepabo/mruby-msd/pull/13
https://github.com/mattn/mruby-json/pull/42
2019-09-07 22:27:30 +09:00
Yukihiro "Matz" Matsumoto 8f04d6561f Merge pull request #4693 from shuujii/increase-symbol-bit-size-on-32-bit-mode-with-MRB_WORD_BOXING
Increase symbol bit size on 32-bit mode with `MRB_WORD_BOXING`
2019-09-07 22:16:54 +09:00
KOBAYASHI Shuji 17c53040ab Increase symbol bit size on 32-bit mode with MRB_WORD_BOXING
This change increases the max length of lower inline symbols to 5 bytes.
2019-09-07 21:38:11 +09:00
Yukihiro "Matz" Matsumoto bb7eccc9c4 Merge pull request #4692 from shuujii/avoid-bit-fields-in-mrb_value
Avoid bit fields in `mrb_value`; ref b2c3d88f
2019-09-06 22:23:16 +09:00
KOBAYASHI Shuji 19e2cc187b Avoid bit fields in mrb_value; ref b2c3d88f
The changes at b2c3d88f were inappropriate because the memory layout of bit
fields are implementation defined. Therefor, I fixed it not to use bit
fields.
2019-09-06 13:24:35 +09:00
Yukihiro "Matz" Matsumoto c3b16c26a6 Merge pull request #4691 from shuujii/fix-Range-max-test-TypeError-is-raised-on-32-bit-mode-with-word-boxing
Fix `Range#max` test (`TypeError` is raised) on 32-bit mode with word boxing
2019-09-05 23:02:53 +09:00
Yukihiro "Matz" Matsumoto 968547d79b Merge pull request #4690 from takumakume/add_assert_not_nil
Add `assert_not_nil` method
2019-09-05 22:59:34 +09:00
takumakume 6c4278144a add assert_not_nil method 2019-09-05 19:51:54 +09:00
KOBAYASHI Shuji 6cfcff6f10 Fix Range#max test (TypeError is raised) on 32-bit mode with word boxing 2019-09-05 19:51:32 +09:00
Yukihiro "Matz" Matsumoto be8bb2be61 Merge pull request #4687 from shuujii/fix-argument-specs-to-BasicObject
Fix argument specs to `BasicObject`
2019-09-05 11:15:34 +09:00
KOBAYASHI Shuji 489f655d18 Fix argument specs to BasicObject 2019-09-04 22:49:57 +09:00
Yukihiro "Matz" Matsumoto 2df419e324 Merge pull request #4686 from shuujii/add-to-doc-limitations.md-about-nil-redefinition
Add to `doc/limitations.md` about `nil?` redefinition; ref 4996709 [ci skip]
2019-09-04 01:25:00 +09:00
KOBAYASHI Shuji 74e7c4aa0b Add to doc/limitations.md about nil? redefinition; ref 4996709 [ci skip] 2019-09-03 21:51:15 +09:00
Yukihiro "Matz" Matsumoto 148fffa21a Merge pull request #4683 from shuujii/enumeratorChain-rewind-shouldnt-rewind-elements-arent-iterated
`Enumerator::Chain#rewind` shouldn't rewind elements aren't iterated
2019-09-02 16:50:47 +09:00
KOBAYASHI Shuji 66211394e1 Enumerator::Chain#rewind shouldn't rewind elements aren't iterated
### Example:

  ```ruby
  # example.rb
  e = [1]
  def e.rewind; p :r end
  c = e.chain(e)
  c.each{break c}.rewind
  ```

#### Before this patch:

  ```terminal
  $ bin/mruby example.rb
  :r
  :r
  ```

#### After this patch (same as Ruby):

  ```terminal
  $ bin/mruby example.rb
  :r
  ```
2019-09-02 08:58:33 +09:00
Yukihiro "Matz" Matsumoto aea5880c10 Small refactoring in fiber.c. 2019-09-02 08:41:44 +09:00
Yukihiro "Matz" Matsumoto 5cd52d2d69 Fix an error in refactoring; fix #4682 2019-09-02 08:41:44 +09:00
Yukihiro "Matz" Matsumoto e8de7c6819 Merge pull request #4681 from shuujii/array-permutation-with-a-negative-argument-should-not-yield
`Array#permutation` with a negative argument should not yield
2019-09-01 13:01:59 +09:00
KOBAYASHI Shuji fe6cf851bf Array#permutation with a negative argument should not yield
Before this patch:

  $ bin/mruby -e '[1].permutation(-1){|v| p v}'  #=> [1]

After this patch (same as Ruby):

  $ bin/mruby -e '[1].permutation(-1){|v| p v}'  #=> no output
2019-09-01 09:28:11 +09:00
Yukihiro "Matz" Matsumoto 1a4ea94bc7 Fix mrb_immediate_p(MRB_TT_FREE) to return false; ref #4679 2019-08-31 23:19:08 +09:00
Yukihiro "Matz" Matsumoto d48a2190bf Refactor #4662 with different names. 2019-08-31 22:14:25 +09:00
Yukihiro "Matz" Matsumoto 49967097ed Skip nil? method call in if conditionals.
Compile `if expr.nil?` to use `OP_JMPNIL` instead of calls.
2019-08-31 22:14:25 +09:00
Yukihiro "Matz" Matsumoto 49896abe2b Merge pull request #4679 from shuujii/implement-mrb_immediate_p-macro-for-MRB_WORD_BOXING
Implement `mrb_immediate_p` macro for `MRB_WORD_BOXING`
2019-08-31 22:14:14 +09:00
KOBAYASHI Shuji b2c3d88fbf Implement mrb_immediate_p macro for MRB_WORD_BOXING
The default implementation of `mrb_immediate_p` uses `mrb_type`. However,
in `MRB_WORD_BOXING`, `mrb_type` has many branches and is inefficient, so
provide an implementation that does not use `mrb_type`.
2019-08-31 16:55:57 +09:00
Yukihiro "Matz" Matsumoto 55ef4e4bdd Merge pull request #4677 from shuujii/array-permutation-combination-without-block-should-return-self
`Array#(permutation|combination)` without block should return `self`
2019-08-30 22:38:15 +09:00
KOBAYASHI Shuji 28d1f6cdc4 Array#(permutation|combination) without block should return self 2019-08-30 17:04:25 +09:00
Yukihiro "Matz" Matsumoto 0ce1878aba Merge pull request #4674 from shuujii/remove-unneeded--src-y.tab.c-in-.gitignore
Remove unneeded `/src/y.tab.c` in `.gitignore`
2019-08-29 16:24:48 +09:00
KOBAYASHI Shuji d9614549bb Remove unneeded /src/y.tab.c in .gitignore
Currently, `y.tab.c` is generated to under the `build/` directory.
2019-08-29 14:05:53 +09:00
Yukihiro "Matz" Matsumoto aa97b8a4fe Merge pull request #4672 from shuujii/fix-build-of-mruby-random-on-32-bit-mode
Fix build of `mruby-random` on 32-bit mode
2019-08-27 15:03:47 +09:00
KOBAYASHI Shuji 7993b87235 Fix build of mruby-random on 32-bit mode 2019-08-27 10:48:25 +09:00
Yukihiro "Matz" Matsumoto c1cd2007b8 Merge pull request #4671 from shuujii/fix-Array-sample-with-MRB_INT32
Fix `Array#sample` with `MRB_INT32`
2019-08-26 22:18:36 +09:00
KOBAYASHI Shuji 7178a5e7d3 Fix Array#sample with MRB_INT32
Array index became potentially negative because `uint32_t` is cast to
`mrb_int`.
2019-08-26 20:23:46 +09:00
Yukihiro "Matz" Matsumoto 4aabf91ee2 Merge pull request #4635 from shuujii/fix-wrong-argument-for-fprintf-in-mruby-bin-mrbc
Fix wrong argument for `fprintf` in `mruby-bin-mrbc`
2019-08-26 19:18:49 +09:00
Yukihiro "Matz" Matsumoto cd96998372 Merge pull request #4670 from shuujii/remove-unused-random.h
Remove unused `random.h`
2019-08-26 19:17:38 +09:00
KOBAYASHI Shuji b9350f908f Remove unused random.h 2019-08-26 18:08:32 +09:00
Yukihiro "Matz" Matsumoto 2d09fd2135 Merge pull request #4669 from davidsiaw/doxygen
Fixes for Doxygen docs
2019-08-26 07:46:57 +09:00
David Siaw 6375639917 fix lots of warnings and make logo not so big 2019-08-26 02:08:33 +09:00
David Siaw e1e96c0cf4 change doc directory and reduce warnings 2019-08-26 00:23:28 +09:00
Yukihiro "Matz" Matsumoto a4870a579f Merge pull request #4668 from shuujii/defer-several-build-libraries-loading-until-needed
Defer several build libraries loading until needed
2019-08-25 17:56:03 +09:00
KOBAYASHI Shuji 3110d84ed8 Defer several build libraries loading until needed 2019-08-25 09:48:07 +09:00
Yukihiro "Matz" Matsumoto e3f7429173 Merge pull request #4667 from shuujii/fix-Range-max-test-TypeError-is-raised-on-32-bit-mode
Fix `Range#max` test (`TypeError` is raised) on 32-bit mode
2019-08-25 01:30:45 +09:00
Yukihiro "Matz" Matsumoto ee0806ad4b Merge pull request #4666 from dearblue/warn-str_new_capa
Suppress warning by gcc with `-Wmaybe-uninitialized`
2019-08-25 01:29:49 +09:00
Yukihiro "Matz" Matsumoto 17623fd0d3 Merge pull request #4665 from dearblue/fix-4642
Create a symbolic link in the temporary directory; fix #4642
2019-08-25 01:28:14 +09:00
Yukihiro "Matz" Matsumoto ce89974679 Merge pull request #4664 from shuujii/remove-unused-constant-in-Rakefile
Remove unused constant in `Rakefile`; ref e312842a
2019-08-25 01:25:32 +09:00
KOBAYASHI Shuji 13f58f9bc2 Fix Range#max test (TypeError is raised) on 32-bit mode 2019-08-24 14:22:10 +09:00
dearblue c9c27e9d69 Suppress warning by gcc with -Wmaybe-uninitialized 2019-08-24 11:44:51 +09:00
KOBAYASHI Shuji e7b49e3f09 Remove unused constant in Rakefile; ref e312842a 2019-08-24 11:30:03 +09:00
dearblue 6ad2442fb9 Create a symbolic link in the temporary directory; fix #4642
Because the linker gives a warning on FreeBSD 12.0.

```
warning: mktemp() possibly used unsafely; consider using mkstemp()
```
2019-08-24 11:11:00 +09:00
Yukihiro "Matz" Matsumoto 71242c0f2e Merge pull request #4662 from shuujii/fix-RBreak-exceeding-6-words-on-32-bit-mode-w-o-boxing-and-MRB_USE_FLOAT
Fix `RBreak` exceeding 6 words on 32-bit mode w/o boxing and `MRB_USE_FLOAT`
2019-08-23 22:35:28 +09:00
KOBAYASHI Shuji be78b5d8f7 Fix RBreak exceeding 6 words on 32-bit mode w/o boxing and MRB_USE_FLOAT
ref: https://github.com/mruby/mruby/pull/4483#issuecomment-498001736

In this configuration, `tt` of `RBreak::val` is set into `RBreak::flags`.
2019-08-23 22:15:42 +09:00
Yukihiro "Matz" Matsumoto 14d5a86b29 Merge pull request #4656 from shuujii/refine-processing-for-gem-lock-file
Refine processing for gem lock file
2019-08-23 05:46:20 +09:00
KOBAYASHI Shuji e312842a18 Refine processing for gem lock file
- Defer YAML library and lock file loading until needed.
- Don't write empty parts into lock file.
- Extract code to read/write lock file to `MRuby::Lockfile`.
- `MRuby::Lockfile.disable` disables the use of lock file.
2019-08-22 21:40:01 +09:00
Yukihiro "Matz" Matsumoto 246179518d Merge pull request #4655 from yamori813/master
make clean error workaround
2019-08-22 13:50:28 +09:00
yamori813 07b2d33347 workaround error 2019-08-22 10:59:46 +09:00
Yukihiro "Matz" Matsumoto 3ad58f4dae Add lock files to .gitignore; #4180 2019-08-22 08:16:51 +09:00
Yukihiro "Matz" Matsumoto ef46fb4840 Merge pull request #4654 from take-cheeze/mruby_version_lock
Take commit hash of mruby too
2019-08-22 08:07:30 +09:00
Yukihiro "Matz" Matsumoto 2aa22206be Merge pull request #4653 from take-cheeze/sep_repo_build
Separate repos directory and build directory
2019-08-22 08:06:47 +09:00
take-cheeze 8e7a3a4df1 Take commit hash of mruby too 2019-08-22 03:03:24 +09:00
take-cheeze a86f8f26a2 Separate repos directory and build directory
closes #4652
2019-08-22 02:43:00 +09:00
Yukihiro "Matz" Matsumoto 90bffaa2a6 Merge pull request #4180 from take-cheeze/lock_file
Support lock file for git.
2019-08-21 17:17:30 +09:00
Yukihiro "Matz" Matsumoto 4c8e6daab7 Merge pull request #4651 from shuujii/prioritize-embedded-string-over-nofree-or-normal-string
Prioritize embedded string over nofree (or normal) string
2019-08-21 12:39:59 +09:00
KOBAYASHI Shuji a84ab12735 Prioritize embedded string over nofree (or normal) string
Prioritize embedded string in the following functions:

- `str_new_static`
- `str_new`
- `mrb_str_new_capa`
- `mrb_str_pool`

The reasons are as follows:

- Consistency with `mrb_str_byte_subseq` and `str_replace`.
- Memory locality increases and may be slightly faster.
- No conversion cost to embedded string when modifying the string.
2019-08-21 12:06:03 +09:00
Yukihiro "Matz" Matsumoto def7925873 Merge pull request #4650 from take-cheeze/patch-5
Remove deprecated iij stuffs
2019-08-21 07:10:08 +09:00
Yukihiro "Matz" Matsumoto 55ac140c25 Merge pull request #4649 from take-cheeze/patch-4
Fix link of mruby-io
2019-08-21 07:09:32 +09:00
Yukihiro "Matz" Matsumoto 392f8f840d Merge pull request #4648 from take-cheeze/patch-3
Use mruby-onig-regexp instead in example
2019-08-21 07:08:56 +09:00
Yukihiro "Matz" Matsumoto f563cc227b Merge pull request #4647 from take-cheeze/patch-2
Add note about checksum_hash in mrbgem doc
2019-08-21 07:08:08 +09:00
Takeshi Watanabe fd4db7e6dd Remove deprecated iij stuffs 2019-08-20 23:56:10 +09:00
Takeshi Watanabe 2e172fd932 Fix link of mruby-io 2019-08-20 23:54:36 +09:00
Takeshi Watanabe c138b9ea30 Use mruby-onig-regexp instead in example 2019-08-20 23:52:21 +09:00
Takeshi Watanabe 3256fae147 Add note about checksum_hash in mrbgem doc 2019-08-20 23:50:16 +09:00
Yukihiro "Matz" Matsumoto 4c001673b6 Avoid C++ strict aliasing warning.
Based on code proposed by @dearblue to avoid the warning:
`dereferencing type-punned pointer will break strict-aliasing rules`.
2019-08-20 22:50:21 +09:00
Yukihiro "Matz" Matsumoto 183fb961b3 Fixed a bug in the OP_JMPNOT optimization (13eaff4); fix #4644 2019-08-20 22:01:50 +09:00
Yukihiro "Matz" Matsumoto 942c076938 Merge pull request #4646 from shuujii/use-RBasic-padding-for-embedded-string-on-64-bit-CPU
Use `RBasic` padding for embedded string on 64-bit CPU
2019-08-20 22:00:54 +09:00
KOBAYASHI Shuji 8157672a29 Use RBasic padding for embedded string on 64-bit CPU
On 64-bit CPU, there is padding in `RBasic`, so reorder the fields and use
it as buffer of embedded string. This change allows 4 more bytes to be
embedded on 64-bit CPU.

However, an incompatibility will occur if `RString::as::ary` is accessed
directly because `RString` structure has changed.
2019-08-20 18:49:55 +09:00
Yukihiro "Matz" Matsumoto b836fd05dd Merge pull request #4645 from shuujii/move-mrb_str_pool-to-src-string.c-to-use-str_init-family
Move `mrb_str_pool` to `src/string.c` to use `str_init` family
2019-08-19 21:29:38 +09:00
KOBAYASHI Shuji 507dbf984e Move mrb_str_pool to src/string.c to use str_init family 2019-08-19 19:18:52 +09:00
Yukihiro "Matz" Matsumoto 1961059330 Merge pull request #4643 from lopopolo/externally-define-MRB_API
Allow external definition of MRB_API macro
2019-08-19 13:18:41 +09:00
Ryan Lopopolo b5662c87c8 Allow external definition of MRB_API macro
When building WebAssembly targets with clang (e.g. wasm32-unknown-unknown), all
symbols are hidden by default. To export a symbol, it must be marked with

    __attribute__((visibility(default)))

Rather than detecting this exotic target in mruby, allow MRB_API to be defined
externally.
2019-08-18 19:40:12 -07:00
Yukihiro "Matz" Matsumoto 3fbd5f0029 Merge pull request #4639 from dearblue/suppress-Wstringop-truncation
Suppress warnings for `strncat()`
2019-08-19 07:31:26 +09:00
Yukihiro "Matz" Matsumoto f263088b0d Merge pull request #4638 from dearblue/simplify-get-args
Simplify get arguments
2019-08-19 07:30:48 +09:00
Yukihiro "Matz" Matsumoto b5e2d208b9 Merge pull request #4636 from davidsiaw/doxygen
Generate doxygen docs for mruby
2019-08-19 07:29:46 +09:00
Yukihiro "Matz" Matsumoto fe8428b33b Merge pull request #4642 from dearblue/unique-symlink
Make symbolic link names unique for test
2019-08-19 07:25:07 +09:00
Yukihiro "Matz" Matsumoto 1b9801a04b Merge pull request #4641 from shuujii/rename-mrb_shared_string-len-to-mrb_shared_string-capa
Rename `mrb_shared_string::len` to `mrb_shared_string::capa`
2019-08-19 07:24:06 +09:00
Yukihiro "Matz" Matsumoto feecb3321a Merge pull request #4640 from shuujii/also-use-str_init_shared-for-orig-in-str_make_shared
Also use `str_init_shared` for `orig` in `str_make_shared()`
2019-08-19 07:23:23 +09:00
Yukihiro "Matz" Matsumoto 6f61b35bcf Merge pull request #4637 from dearblue/immutable-iseq
Prohibit changes to iseq in principle
2019-08-18 23:25:40 +09:00
dearblue 734a7f52a7 Make symbolic link names unique for test 2019-08-18 22:10:41 +09:00
David Siaw b5299b1c58 fix up documentation for values 2019-08-18 20:12:44 +09:00
KOBAYASHI Shuji d2d201cc82 Rename mrb_shared_string::len to mrb_shared_string::capa
Because this field is used as capacity of string buffer.
2019-08-18 20:08:04 +09:00
KOBAYASHI Shuji aaa509dd07 Also use str_init_shared for orig in str_make_shared() 2019-08-18 19:44:00 +09:00
dearblue 74395d7577 Suppress warnings for strncat()
`strncat()` also needs `'\0'`.
2019-08-18 15:46:17 +09:00
dearblue 05a873c25c Simplify get arguments
- `mrb_str_index_m()` and `mrb_str_rindex()`
  Make `mrb_get_args()` called only once from called twice.
- `mrb_str_byteslice()`
  Replace `goto` with `if ~ else`.
2019-08-18 15:38:25 +09:00
dearblue 279c21b816 Prohibit changes to iseq in principle 2019-08-18 15:00:32 +09:00
David Siaw 2c86895468 fix up markdown display in doxygen 2019-08-18 13:59:29 +09:00
David Siaw 8d70a9b1b5 first bit of doc generation 2019-08-18 13:07:24 +09:00
Yukihiro "Matz" Matsumoto 83dab1ee0d Merge pull request #4634 from shuujii/refactor-set-unset-string-type-flags
Refactor set/unset string type flags
2019-08-17 23:41:52 +09:00
KOBAYASHI Shuji 5345731b1d Fix wrong argument for fprintf in mruby-bin-mrbc 2019-08-17 21:46:45 +09:00
KOBAYASHI Shuji caba5fef27 Refactor set/unset string type flags
Introduce `RSTR_SET_TYPE_FLAG` macro to set the specified string type flag and
clear the others.
2019-08-17 21:24:08 +09:00
Yukihiro "Matz" Matsumoto 277c91e94c Merge pull request #4625 from dearblue/rindex-broken-utf8
Fix `String#rindex` with invalid UTF-8 string
2019-08-17 15:52:34 +09:00
Yukihiro "Matz" Matsumoto b55e72b2d6 Resolve conflict between #4582 and C++ warning. 2019-08-17 15:47:14 +09:00
Yukihiro "Matz" Matsumoto 5b1f25a4e0 Implement Array#each using inline mruby bytecode. 2019-08-17 14:46:32 +09:00
Yukihiro "Matz" Matsumoto 13eaff4f9f Remove unnecessary OP_JMPNOT for unless statement. 2019-08-17 12:29:04 +09:00
dearblue bc27273087 Fix String#rindex with invalid UTF-8 string
Previously `String#rindex` returned the wrong index when given an
invalid UTF-8 string.

```terminal
% ruby26 -e 'str = "\xf0☀\xf1☁\xf2☂\xf3☃\xf0☀\xf1☁\xf2☂\xf3☃"; p str.rindex("☁")'
11
% ./mruby-head -e 'str = "\xf0☀\xf1☁\xf2☂\xf3☃\xf0☀\xf1☁\xf2☂\xf3☃"; p str.rindex("☁")'
nil
% ./mruby-patched -e 'str = "\xf0☀\xf1☁\xf2☂\xf3☃\xf0☀\xf1☁\xf2☂\xf3☃"; p str.rindex("☁")'
11
```
2019-08-17 12:05:03 +09:00
Yukihiro "Matz" Matsumoto e76c5aad36 Stop using mrb_to_str as a converter (it is not). 2019-08-17 11:49:00 +09:00
dearblue 414ab682f3 Add String#rindex test for invalid UTF-8 string 2019-08-17 11:44:27 +09:00
dearblue cf5f290fa0 Fix String#rindex test for UTF-8 string 2019-08-17 11:44:27 +09:00
Yukihiro "Matz" Matsumoto 0286a7f709 Avoid mrb_funcall from Class#new when no overloading. 2019-08-17 09:02:47 +09:00
Yukihiro "Matz" Matsumoto 99715a2e62 Merge pull request #4633 from shuujii/shared-fshared-string-is-not-required-when-sharing-nofree-string
SHARED/FSHARED string is not required when sharing NOFREE string
2019-08-16 23:20:44 +09:00
Yukihiro "Matz" Matsumoto c1a0a99309 Update struct RArray union to silence C++ warning. 2019-08-16 22:51:07 +09:00
Yukihiro "Matz" Matsumoto 0923ff6313 Optimize bytecode for Class#new. 2019-08-16 22:37:30 +09:00
Yukihiro "Matz" Matsumoto 61763129db Implement Class#new using inline mruby bytecode. 2019-08-16 22:30:03 +09:00
KOBAYASHI Shuji 9832e91304 SHARED/FSHARED string is not required when sharing NOFREE string
I think the string buffer of NOFREE string always exists and does not need
to be released, so it can be shared as another NOFREE string.

Also changed the `mrb_shared_string` field order so that eliminate padding if
`int` and `mrb_int` sizes are less than pointer size.
2019-08-16 22:05:58 +09:00
Yukihiro "Matz" Matsumoto 06c7ff0666 Avoid creating unnecessary empty arrays on splat.
But this changes requires `OP_ARYCAT` and `OP_ARYPUSH` to accept `nil`
as their first operand. Alternative VMs (e.g. `mruby/c`) that understand
mruby bytecode need to be updated.
2019-08-16 16:42:40 +09:00
Yukihiro "Matz" Matsumoto fa8515bc2c Stop raising exceptions from undef C API.
Some `undef' functions may be called before initialization, thus causes
infinite error recursion.
2019-08-16 16:42:40 +09:00
Yukihiro "Matz" Matsumoto 8fa9a7b965 Merge pull request #4632 from shuujii/remove-unneeded--include-in-src-string.c
Remove unneeded `#include` in `src/string.c`
2019-08-15 18:41:30 +09:00
KOBAYASHI Shuji 59844ddde0 Remove unneeded #include in src/string.c 2019-08-15 12:18:33 +09:00
Yukihiro "Matz" Matsumoto 0c5ebd75a3 Merge pull request #4631 from shuujii/extract-initialization-code-of-shared-and-fshared-string-to-function
Extract initialization code of shared and fshared string to function
2019-08-14 23:29:07 +09:00
KOBAYASHI Shuji af6724c2f6 Extract initialization code of shared and fshared string to function 2019-08-14 22:20:34 +09:00
Yukihiro "Matz" Matsumoto d986b9ff7b Avoid array copying in mrb_instance_new. 2019-08-14 15:08:48 +09:00
Yukihiro "Matz" Matsumoto 603005ba65 Integrate kazuho/mruby-class-new-fiber-safe in the master.
Avoid calling `initialize` via `mrb_funcall`, which cause `cross C
boundary` error from Fibers started in the method.
2019-08-14 14:09:56 +09:00
Yukihiro "Matz" Matsumoto 8ed15fd92e Small refactoring on #4630 2019-08-14 12:20:40 +09:00
Yukihiro "Matz" Matsumoto 9f6328d499 Remove MRB_API from functions only called from vm.c.
* `mrb_vm_define_class`
* `mrb_vm_define_module`

Only functions called from user code requires `MRB_API`.
2019-08-14 09:33:23 +09:00
Yukihiro "Matz" Matsumoto e2ab8cca82 Merge pull request #4630 from shuujii/extract-struct-RString-initialization-code-to-function
Extract `struct RString` initialization code to function
2019-08-14 08:16:45 +09:00
KOBAYASHI Shuji 7af0ee099d Extract struct RString initialization code to function 2019-08-13 22:40:30 +09:00
Yukihiro "Matz" Matsumoto 8a3457c330 Merge pull request #4629 from shuujii/mrb_str_pool-can-embed-one-more-byte
`mrb_str_pool` can embed one more byte; ref #4626
2019-08-12 22:41:51 +09:00
KOBAYASHI Shuji dfb297e3c4 mrb_str_pool can embed one more byte; ref #4626 2019-08-12 21:42:31 +09:00
Yukihiro "Matz" Matsumoto f113fa2a4f Remove unnecessary prototypes from 'keywords`; fix #4628 2019-08-12 18:22:31 +09:00
Yukihiro "Matz" Matsumoto ad0b546088 Merge pull request #4626 from shuujii/mrb_str_modify_keep_ascii-can-embed-one-more-byte
`mrb_str_modify_keep_ascii` can embed one more byte
2019-08-12 17:09:21 +09:00
Yukihiro "Matz" Matsumoto 285ce9d8aa Replacing region may overwrap with the target region; fix #4627 2019-08-12 16:51:01 +09:00
Yukihiro "Matz" Matsumoto 472dba19ea Revert "Should have cleared mrb->globals in mrb_gc_free_gv; fix #4618"
This reverts commit 3dc8d9d7b3.
2019-08-11 22:14:56 +09:00
Yukihiro "Matz" Matsumoto 0376383354 Reorder finalization to avoid potential crash; ref #4618
`mrb_gc_destroy` may call other mruby API functions from the finalizers.
So call that function first.
2019-08-11 22:14:56 +09:00
Yukihiro "Matz" Matsumoto 70b53f91c2 Add NUL always to short strings; ref 98fc887 2019-08-11 22:14:56 +09:00
KOBAYASHI Shuji 450684ab33 mrb_str_modify_keep_ascii can embed one more byte
The condition to make an embedded string was incorrect. Because there were
several similar codes, extracted into `RSTR_EMBEDDABLE_P` macro.
2019-08-11 20:48:37 +09:00
Yukihiro "Matz" Matsumoto ce7fd7e1a3 Merge pull request #4621 from shuujii/remove-monkey-patches-for-Ruby-1.9-or-earlier
Remove monkey patches for Ruby 1.9 or earlier
2019-08-11 03:23:51 +09:00
Yukihiro "Matz" Matsumoto 469dbeb42e Merge pull request #4624 from shuujii/enumerable-reject-etc.-should-return-Enumerable-without-block
`Enumerable#reject`, etc. should return `Enumerable` without block
2019-08-11 03:22:35 +09:00
KOBAYASHI Shuji 9f18aced9f Enumerable#reject, etc. should return Enumerable without block 2019-08-10 22:18:54 +09:00
Yukihiro "Matz" Matsumoto 496a2c3264 Merge pull request #4623 from chasonr/complex-fixes
Avoid premature overflow in Complex#abs and Complex#/
2019-08-09 21:47:00 +09:00
Ray Chason 1cd0ff0d42 Avoid overflow and underflow in Complex#/ 2019-08-09 00:08:36 -04:00
Ray Chason c181d1e7fa Implement Complex#abs in terms of Math.hypot
Math.hypot avoids premature overflow and underflow
2019-08-08 23:59:25 -04:00
KOBAYASHI Shuji 1868fd453d Remove monkey patches for Ruby 1.9 or earlier 2019-08-08 22:12:25 +09:00
Yukihiro "Matz" Matsumoto 438638b42e Merge pull request #4620 from shuujii/improve-MiniRake-rule-enhancement-for-Rake-compatibility
Improve MiniRake rule enhancement for Rake compatibility
2019-08-07 23:55:51 +09:00
KOBAYASHI Shuji 7e42b6ad3f Improve MiniRake rule enhancement for Rake compatibility
Support pathmap notation, recursive dependencies search, and so on.
2019-08-07 21:50:22 +09:00
Yukihiro "Matz" Matsumoto b377b7d580 Update mrb_to_str and related functions.
Contrary to the name, `mrb_to_str` just checks type, no conversion.
2019-08-07 16:20:40 +09:00
Yukihiro "Matz" Matsumoto 98fc887cb3 Reorganize mrb_string_value_cstr and related functions.
`mrb_string_value_cstr` and `mrb_string_value_len`: obsolete
`mrb_string_cstr`: new function to retrieve NULL terminated C string
`RSTRING_CSTR`: wrapper macro of `mrb_string_cstr`
2019-08-07 15:52:10 +09:00
Yukihiro "Matz" Matsumoto b8a87bd111 Update required Ruby version to 2.0 or later. 2019-08-07 15:03:16 +09:00
Yukihiro "Matz" Matsumoto 2e73fe5ea1 Replace i.e. (means "that is") with e.g. (means "for example"). 2019-08-07 15:02:38 +09:00
Yukihiro "Matz" Matsumoto eceaa80de7 RUBY_PLATFORM may not contain mswin or mingw; Add msys 2019-08-07 08:54:40 +09:00
Yukihiro "Matz" Matsumoto 97672b22e6 Merge pull request #4619 from shuujii/add-mrb_noreturn-to-cmperr-in-src-numeric.c
Add `mrb_noreturn` to `cmperr()` in `src/numeric.c`
2019-08-07 08:54:25 +09:00
KOBAYASHI Shuji 6e2edd8ed2 Add mrb_noreturn to cmperr() in src/numeric.c 2019-08-06 23:04:40 +09:00
Yukihiro "Matz" Matsumoto 2ba8399ac8 Removed an unused local variable; ref #4615 2019-08-06 20:50:26 +09:00
Yukihiro "Matz" Matsumoto 3dc8d9d7b3 Should have cleared mrb->globals in mrb_gc_free_gv; fix #4618 2019-08-06 20:47:35 +09:00
Yukihiro "Matz" Matsumoto 151d0c14ed Merge pull request #4615 from shuujii/use-new-specifiers-modifiers-of-mrb_vfromat
Use new specifiers/modifiers of `mrb_vfromat()`
2019-08-05 13:33:46 +09:00
KOBAYASHI Shuji 334afb167c Use new specifiers/modifiers of mrb_vfromat()
The binary sizes (gems are only `mruby-bin-mruby`) are reduced slightly in
my environment than before the introduction of new specifiers/modifiers
(5116789a) with this change.

  ------------+-------------------+-------------------+--------
   BINARY     | BEFORE (5116789a) |   AFTER (This PR) |  RATIO
  ------------+-------------------+-------------------+--------
   mruby      |      593416 bytes |      593208 bytes | -0.04%
   libmruby.a |      769048 bytes |      767264 bytes | -0.23%
  ------------+-------------------+-------------------+--------

BTW, I accidentally changed `tasks/toolchains/visualcpp.rake` at #4613,
so I put it back.
2019-08-05 13:18:50 +09:00
Yukihiro "Matz" Matsumoto 96ce4563bd Merge pull request #4614 from shuujii/use-mrb_int-instead-of-to_int-in-mruby-numeric-ext
Use `mrb_int()` instead of `to_int()` in `mruby-numeric-ext`
2019-08-05 12:33:59 +09:00
Yukihiro "Matz" Matsumoto 0e2e8b79d3 Merge pull request #4612 from dearblue/float-consts
Add constants for floating point number
2019-08-05 07:29:25 +09:00
Yukihiro "Matz" Matsumoto dc11e7f027 Merge pull request #4613 from shuujii/change-second-argument-to-%l-of-mrb_vformat-to-size_t-from-mrb_int
Change second argument to `%l` of `mrb_vformat()` to `size_t` from `mrb_int`
2019-08-05 07:26:20 +09:00
KOBAYASHI Shuji d599e35aa4 Use mrb_int() instead of to_int() in mruby-numeric-ext 2019-08-04 22:02:39 +09:00
dearblue eb86340139 Add constants for floating point number 2019-08-04 18:34:46 +09:00
KOBAYASHI Shuji 1e9cb74cc6 Change second argument to %l of mrb_vformat() to size_t from mrb_int
- `size_t` is more commonly used.
- `len` argument of `mrb_str_new()` is `size_t`.

NOTE:

The test for `%l` is temporarily disabled because adding a new type to
`mrbgems/mruby-test/vformat.c` causes an error (memory error?) on Visual
Studio 2017 in AppVeyor.
2019-08-03 19:42:22 +09:00
Yukihiro "Matz" Matsumoto f6c41c1862 Merge pull request #4611 from shuujii/fix-mrb_vformat%f-with-MRB_USE_FLOAT
Fix `mrb_vformat("%f")` with `MRB_USE_FLOAT`
2019-08-03 15:33:35 +09:00
Yukihiro "Matz" Matsumoto d5695a84df Merge pull request #4610 from dearblue/time-warnings
Suppress compiler warnings for mruby-time; fix #4600
2019-08-03 15:31:36 +09:00
KOBAYASHI Shuji a4243360a2 Fix mrb_vformat("%f") with MRB_USE_FLOAT
It potentially not work when `mrb_float` is `float` because `float` variable
in variable length arguments is promoted to `double`.

Also I fixed build with `MRB_WITHOUT_FLOAT`.
2019-08-03 11:54:45 +09:00
dearblue 07308a2fc9 Suppress compiler warnings for mruby-time; fix #4600
Warnings:

- If `MRB_TIME_T_UINT` is defined, the compiler issues a warning with an
  integer comparison of different signs.
- It is mentioned that the `usec` variable passed to the
  `mrb_to_time_t()` function may not be initialized
2019-08-03 10:35:39 +09:00
Yukihiro "Matz" Matsumoto c883f4e332 Merge pull request #4609 from shuujii/change-the-mrb_vformat-specifier-%d-for-int
Change the `mrb_vformat` specifier `%d` for `int`
2019-08-02 20:38:41 +09:00
KOBAYASHI Shuji d1817e7791 Change the mrb_vformat specifier %d for int
It potentially breaks, for example, in the case of `mrb_int` is 64-bit
and more smaller type is passed by `%d`. In fact, the problem could
become apparent when I used `%d` to `backtrace_location::lineno` in
`src/backtrace.c:mrb_unpack_backtrace()` on AppVeyor.

Therefore, change `%d` for `int` (not `mrb_int`) so that it can be
used mostly without casting.
2019-08-02 19:22:08 +09:00
Yukihiro "Matz" Matsumoto 3bacc302a3 Merge pull request #4608 from shuujii/add-new-specifiers-modifiers-to-format-string-of-mrb_vfromat
Add new specifiers/modifiers to format string of `mrb_vfromat()`
2019-08-01 22:10:53 +09:00
KOBAYASHI Shuji eea42e06af Add new specifiers/modifiers to format string of mrb_vfromat()
Format sequence syntax:

  %[modifier]specifier

Modifiers:

  ----------+------------------------------------------------------------
  Modifier  | Meaning
  ----------+------------------------------------------------------------
      !     | Convert to string by corresponding `inspect` instead of
            | corresponding `to_s`.
  ----------+------------------------------------------------------------

Specifiers:

  ----------+----------------+--------------------------------------------
  Specifier | Argument Type  | Note
  ----------+----------------+--------------------------------------------
      c     | char           |
     d,i    | mrb_int        |
      f     | mrb_float      |
      l     | char*, mrb_int | Arguments are string and length.
      n     | mrb_sym        |
      s     | char*          | Argument is NUL terminated string.
      t     | mrb_value      | Convert to type (class) of object.
     v,S    | mrb_value      |
      C     | struct RClass* |
      T     | mrb_value      | Convert to real type (class) of object.
      Y     | mrb_value      | Same as `!v` if argument is `true`, `false`
            |                | or `nil`, otherwise same as `T`.
      %     | -              | Convert to percent sign itself (no argument
            |                | taken).
  ----------+----------------+--------------------------------------------

This change will increase the binary size, but replacing all format strings
with new specifiers/modifiers will decrease the size because it reduces
inline expansion of `mrb_obj_value()`, etc. at the caller.
2019-08-01 13:24:52 +09:00
Yukihiro "Matz" Matsumoto 3d3a6da2ca Merge pull request #4607 from shuujii/fix-UTC-offset-representation-in-Time-to_s-on-some-environments
Fix UTC offset representation in `Time#to_s` on some environments; ref #4604
2019-07-31 22:07:31 +09:00
KOBAYASHI Shuji 5116789aa0 Fix UTC offset representation in Time#to_s on some environments; ref #4604
Use own implementation to calculate UTC offset on Visual Studio 2015 or
earlier or MinGW because `strftime("%z")` on these environments does not
conform C99.
2019-07-31 20:34:27 +09:00
Yukihiro "Matz" Matsumoto 96ac49b75b Avoid MRB_INT_MIN to apply fixdivmod.
`MRB_INT_MIN` is the only integer value that has no corresponding
positive integer value (i.e. `-MRB_INT_MIN` = `MRB_INT_MIN`).
2019-07-31 00:58:12 +09:00
Yukihiro "Matz" Matsumoto c31e1ea798 Normalize floating point negative zero to positive zero in `flodivmod'. 2019-07-31 00:57:00 +09:00
Yukihiro "Matz" Matsumoto 28405d26b0 Should return +/- infinity for float division by zero. 2019-07-31 00:55:31 +09:00
Yukihiro "Matz" Matsumoto 8175d92b4b Use NULL instead of 0 for null pointers. 2019-07-31 00:54:39 +09:00
Yukihiro "Matz" Matsumoto 5900b29fb4 Fixed integer overflow in lshift. 2019-07-30 23:16:34 +09:00
Yukihiro "Matz" Matsumoto 7dae0ec74c Merge pull request #4606 from shuujii/refine-message-to-skip-in-nested-assert
Refine message to `skip` in nested `assert`
2019-07-30 14:41:09 +09:00
KOBAYASHI Shuji 44381f0a0c Refine message to skip in nested assert
- I think "Info" is used only to `skip`, so change to "Skip".
- Changed the default value of `assert` and specify the argument explicitly
  at the caller of `assert` because it is unnatural "Assertion failed" is
  output even though the assertion doesn't fail.

== Example:

  def assert_foo(exp, act)
    assert do
      assert_equal exp[0], act[0]
      assert_equal exp[1], act[1]
    end
  end

  def assert_bar(exp, act)
    assert do
      skip
    end
  end

  def assert_baz(exp, act)
    assert do
      assert_equal exp, act
      assert_bar exp, act
    end
  end

  assert 'test#skip_in_nested_assert' do
    assert_baz 1, 1
  end

  === Before this patch:

    ?..
    Info: test#skip_in_nested_assert (core)
     - Assertion[1]
        Info: Assertion failed (core)
         - Assertion[1-2]
            Skip: Assertion failed (core)
      Total: 3
         OK: 2
         KO: 0
      Crash: 0
    Warning: 0
       Skip: 1

  === After this patch:

    ???
    Skip: test#skip_in_nested_assert (core)
     - Assertion[1]
        Skip: assert (core)
         - Assertion[1-2]
            Skip: assert (core)
      Total: 3
         OK: 0
         KO: 0
      Crash: 0
    Warning: 0
       Skip: 3
2019-07-30 13:05:01 +09:00
Yukihiro "Matz" Matsumoto 428e34abba Merge pull request #4605 from shuujii/fix-Warn-if-assertion-is-missing-inside-assert
Fix "Warn if assertion is missing inside `assert`"; ref ff43b2b9
2019-07-29 22:37:13 +09:00
KOBAYASHI Shuji 5091d047c0 Fix "Warn if assertion is missing inside assert"; ref ff43b2b9 2019-07-29 21:40:58 +09:00
Yukihiro "Matz" Matsumoto a8001d693a Merge pull request #4604 from kou/time-to-s-utf8
Fix Time#to_s encoding on Windows
2019-07-29 18:43:16 +09:00
Sutou Kouhei effae4ae55 Fix Time#to_s encoding on Windows
strftime() on Windows returns locale encoding time zone for "%z" even
if MSDN says "%z" is "The offset from UTC in ISO 8601 format; no
characters if time zone is unknown" in MSDN:

https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/strftime-wcsftime-strftime-l-wcsftime-l?view=vs-2019

So we need to convert encoding of string from strftime().
2019-07-29 18:16:21 +09:00
Yukihiro "Matz" Matsumoto ff43b2b97c Fixed a conflict between #4407 and #4540 2019-07-29 01:25:58 +09:00
Yukihiro "Matz" Matsumoto 2ebc6d5b6f Merge pull request #4407 from shuujii/add-assert_raise_with_message-and-assert_raise_with_message_pattern
Add `assert_raise_with_message` and `assert_raise_with_message_pattern`
2019-07-29 01:05:26 +09:00
Yukihiro "Matz" Matsumoto cd8fc9bcb8 Resolved conflicts in #4320 2019-07-29 01:02:03 +09:00
Yukihiro "Matz" Matsumoto 3ac98009d3 Merge pull request #4602 from shuujii/remove-EnumeratorChain-initialize_copy
Remove `Enumerator::Chain#initialize_copy`
2019-07-28 23:44:11 +09:00
Yukihiro "Matz" Matsumoto 34741d513f Merge pull request #4603 from shuujii/define-plus-to-Enumerator-and-Enumerator-Chain-instead-of-Enumerable
Define `#+` to `Enumerator` and `Enumerator#Chain` instead of `Enumerable`
2019-07-28 23:43:31 +09:00
KOBAYASHI Shuji 7f80a5f73c Define #+ to Enumerator and Enumerator#Chain instead of Enumerable 2019-07-28 22:52:24 +09:00
KOBAYASHI Shuji 27e3d92a30 Remove Enumerator::Chain#initialize_copy
I think `Enumerator::Chain#initialize_copy` is unnecessary because CRuby
doesn't clone elements.
2019-07-28 22:12:02 +09:00
Yukihiro "Matz" Matsumoto 04a422e499 Merge pull request #4601 from shuujii/drop-dependency-from-mruby-enumerator-to-mruby-enum-ext
Drop dependency from `mruby-enumerator` to `mruby-enum-ext`
2019-07-28 14:48:15 +09:00
KOBAYASHI Shuji a70107d725 Drop dependency from mruby-enumerator to mruby-enum-ext 2019-07-28 13:08:11 +09:00
Yukihiro "Matz" Matsumoto fa798f17ff Merge pull request #4600 from dearblue/time-precision
Fix the lack of precision for `Time`; ref d74355061
2019-07-28 10:38:07 +09:00
Yukihiro "Matz" Matsumoto 8c6cd2da76 Merge pull request #4599 from shuujii/drop-dependency-from-mruby-enum-chain-to-mruby-enum-ext
Drop dependency from `mruby-enum-chain` to `mruby-enum-ext`
2019-07-27 21:38:20 +09:00
dearblue fda5c0c073 Fix the lack of precision for Time; ref d74355061
- `Time.local` and `Time.utc` are able to use with `MRB_INT16 + MRB_WITHOUT_FLOAT`.

  - `time_t` is converted directly from the Ruby object.

  - `time + sec` and` time - sec` are not affected by the precision of `mrb_float`.

    Similarly, calculations are possible with `MRB_INT16 + MRB_WITHOUT_FLOAT`.
2019-07-27 21:25:18 +09:00
KOBAYASHI Shuji fe9a58c193 Drop dependency from mruby-enum-chain to mruby-enum-ext 2019-07-27 20:45:14 +09:00
Yukihiro "Matz" Matsumoto 2f0a95768b Merge pull request #4598 from dearblue/time-without-float
Fix mruby-time with `MRB_WITHOUT_FLOAT`; ref d74355061
2019-07-27 15:05:16 +09:00
Yukihiro "Matz" Matsumoto b58f769c96 Fix line number bug; fix #4513
Also fix the misfeature introduced in 23783a4, that ignores newlines
between method chains.
2019-07-27 15:00:46 +09:00
dearblue 1467c14adc Fix mruby-time with MRB_WITHOUT_FLOAT; ref d74355061 2019-07-27 14:42:37 +09:00
Yukihiro "Matz" Matsumoto 42fb251d0a Merge pull request #4597 from shuujii/drop-dependency-from-mruby-array-ext-to-mruby-enum-ext
Drop dependency from `mruby-array-ext` to `mruby-enum-ext`
2019-07-27 14:01:37 +09:00
Yukihiro "Matz" Matsumoto 3103da8570 Merge pull request #4594 from shuujii/move-NilClass-to_h-to-mruby-object-ext-from-mruby-enum-ext
Move `NilClass#to_h` to `mruby-object-ext` from `mruby-enum-ext`
2019-07-27 13:09:34 +09:00
KOBAYASHI Shuji 778310260c Drop dependency from mruby-array-ext to mruby-enum-ext 2019-07-26 11:48:53 +09:00
Yukihiro "Matz" Matsumoto 381a6ddddb Merge pull request #4595 from shuujii/refine-Array-permutation-combination-test
Refine `Array#(permutation|combination) test`
2019-07-26 00:04:52 +09:00
KOBAYASHI Shuji 87cc58ba3d Refine Array#(permutation|combination) test
- No guarantees about the order in which the permutations/combinations
  are yielded.

- Drop dependency on `Enumerator`.
2019-07-25 22:31:54 +09:00
KOBAYASHI Shuji 2d520eaf6f Move NilClass#to_h to mruby-object-ext from mruby-enum-ext 2019-07-24 20:13:26 +09:00
Yukihiro "Matz" Matsumoto 5779464ec3 Add return to silence a warning; ref #4593 2019-07-24 10:50:22 +09:00
Yukihiro "Matz" Matsumoto 866a9e6481 Use MRB_TT_ISTRUCT for Random to reduce memory.
When the size of Xorshift128 seed (`sizeof(uint32)*4`) is bigger than
ISTRUCT_DATA_SIZE, `Random` uses Xorshift96 instead.
2019-07-24 10:48:00 +09:00
Yukihiro "Matz" Matsumoto a57a9bce79 Call MRB_SET_INSTANCE_TT for Complex and Rational. 2019-07-24 10:48:00 +09:00
Yukihiro "Matz" Matsumoto e968bdf629 Merge pull request #4593 from shuujii/add-encoding-argument-to-Integral-chr
Add encoding argument to `Integral#chr`
2019-07-23 23:36:50 +09:00
KOBAYASHI Shuji e86aa61f20 Add encoding argument to Integral#chr
Currently, `Integral#chr` in mruby changes behavior by `MRB_UTF8_STRING`
setting.

before this patch:

  $ bin/mruby -e 'p 171.chr'  #=> "\xab"  (`MRB_UTF8_STRING` is disabled)
  $ bin/mruby -e 'p 171.chr'  #=> "«"     (`MRB_UTF8_STRING` is enabled)

This behavior is incompatible with Ruby, and a little inconvenient because
it can't be interpreted as ASCII-8BIT with `MRB_UTF8_STRING`, I think.

So add encoding argument according to Ruby.

after this patch:

  $ bin/mruby -e 'p 171.chr'                #=> "\xab"
  $ bin/mruby -e 'p 171.chr("ASCII-8BIT")'  #=> "\xab"
  $ bin/mruby -e 'p 171.chr("UTF-8")'       #=> "«"

Allow only `String` for encoding because mruby doesn't have `Encoding`
class, and `"ASCII-8BIT"` (`"BINARY"`) and `"UTF-8"` (only with
`MRB_UTF8_STRING`) are valid value (default is `"ASCII-8BIT"`).
2019-07-23 20:16:46 +09:00
Yukihiro "Matz" Matsumoto 5166e316ef Merge pull request #4591 from shuujii/integrate-Integral-chr-Fixnum-chr-to-mruby-string-ext
Integrate `Integral#chr` (`Fixnum#chr`) to `mruby-string-ext`
2019-07-22 21:40:02 +09:00
Yukihiro "Matz" Matsumoto d2dd2d0e48 Merge pull request #4590 from shuujii/fix-Module-dup-to-frozen-module
Fix `Module#dup` to frozen module
2019-07-22 21:38:56 +09:00
Yukihiro "Matz" Matsumoto 477be45244 Merge pull request #4592 from shuujii/set-MRB_STR_ASCII-flag-in-String-inspect
Set `MRB_STR_ASCII` flag in `String#inspect`
2019-07-22 21:38:08 +09:00
Yukihiro "Matz" Matsumoto d74355061b Fix mruby-time to work with MRB_WITHOUT_FLOAT; ref #4576
As a side effect, `mrb_time_at()` now takes `mrb_int` instead of
`double` as time arguments.
2019-07-22 21:34:37 +09:00
Yukihiro "Matz" Matsumoto 87d1b2a910 Improve conflict error message of Time and Math; ref #4576 2019-07-22 20:21:30 +09:00
Yukihiro "Matz" Matsumoto 949f6f5324 Check conflicts with Complex and MRB_WITHOUT_FLOAT; ref #4576
The Complex class needs `mrb_float` so that it does not work with
`MRB_WITHOUT_FLOAT` anyway.
2019-07-22 20:19:01 +09:00
KOBAYASHI Shuji fe8b463c4e Set MRB_STR_ASCII flag in String#inspect
`String#inspect` can set `MRB_STR_ASCII` flag to receiver and return value
because it checks character byte length.
2019-07-22 19:39:25 +09:00
Yukihiro "Matz" Matsumoto f99e9963b2 Switch random generator from Mersenne Twister to Xorshit128.
Now `rand` can be used with `MRB_WITHOUT_FLOAT`; ref #4576
2019-07-22 15:49:59 +09:00
Yukihiro "Matz" Matsumoto 277be410f3 No rounding needed if 'ndigits is bigger than DBL_DIG+2`; fix #4566 2019-07-22 13:23:53 +09:00
Yukihiro "Matz" Matsumoto 6f67fddb87 Fix FIXABLE_FLOAT() on MRB_INT64; ref #4566
Normal `TYPED_FIXABLE(f,mrb_float)` does not work on 64bit int from
casting problems. The new approach works well, but assumes two's
complement and IEEE-754 floating point numbers.
2019-07-22 13:23:53 +09:00
KOBAYASHI Shuji c980fe2792 Integrate Integral#chr (Fixnum#chr) to mruby-string-ext
Because they're defined in both `mruby-string-ext` and `mruby-numeric-ext`
(they seem more natural to define in N, but `mruby-string-ext` depends on
`Integral#chr`).
2019-07-21 22:59:41 +09:00
KOBAYASHI Shuji 7675fcb5d3 Fix Module#dup to frozen module
Before this patch:

  $ bin/mruby -e 'p Module.new.freeze.dup.frozen?'  #=> true

After this patch (same as Ruby):

  $ bin/mruby -e 'p Module.new.freeze.dup.frozen?'  #=> false
2019-07-20 22:41:57 +09:00
Yukihiro "Matz" Matsumoto cf4cddf7a1 Merge pull request #4589 from shuujii/refine-String-chr-test
Refine `String#chr` test and separate `Fixnum#chr` test
2019-07-20 08:15:02 +09:00
KOBAYASHI Shuji 8ab846b5b9 Refine String#chr test and separate Fixnum#chr test 2019-07-19 21:48:06 +09:00
Yukihiro "Matz" Matsumoto 7e229c470a Merge pull request #4575 from dearblue/attr-use-stack
Use stack memory for small name of attr accessors
2019-07-18 18:37:08 +09:00
Yukihiro "Matz" Matsumoto 317fba47a6 Merge pull request #4588 from shuujii/fix-String-times-test-with-MRB_WITHOUT_FLOAT
Fix `String#*` test with `MRB_WITHOUT_FLOAT`
2019-07-18 18:36:32 +09:00
KOBAYASHI Shuji 9873d5e0b9 Fix String#* test with MRB_WITHOUT_FLOAT 2019-07-18 17:51:02 +09:00
Yukihiro "Matz" Matsumoto 94a1f488a6 Clear env before top-level execution; fix #4581 2019-07-18 00:35:21 +09:00
Yukihiro "Matz" Matsumoto 2a410c0e1b Avoid making top-level env in initialization code; ref #4581 2019-07-18 00:34:08 +09:00
Yukihiro "Matz" Matsumoto 0b5e155016 Merge pull request #4587 from shuujii/fix-String-aref-test
Fix `String#[]` test
2019-07-17 22:35:16 +09:00
Yukihiro "Matz" Matsumoto 626c21466f Merge pull request #4585 from shuujii/fix-range-min-with-mruby-range-ext
Fix `(fixnum_value ... float_value).min` with `mruby-range-ext`
2019-07-17 22:34:29 +09:00
Yukihiro "Matz" Matsumoto cdf5e3963d Merge branch 'master' into fix-range-min-with-mruby-range-ext 2019-07-17 22:33:55 +09:00
Yukihiro "Matz" Matsumoto 7172231b8f Merge pull request #4586 from shuujii/revert-4300
Revert #4300
2019-07-17 22:29:35 +09:00
Yukihiro "Matz" Matsumoto 47ac318920 Merge pull request #4584 from shuujii/allow-mruby-range-ext-to-work-with-MRB_WITHOUT_FLOAT
Allow `mruby-range-ext` to work with `MRB_WITHOUT_FLOAT`; ref 2add8641
2019-07-17 20:42:25 +09:00
KOBAYASHI Shuji 9d2272ec2c Fix String#[] test 2019-07-17 20:09:37 +09:00
KOBAYASHI Shuji e38ba3d58c Revert #4300
Originally, it was not necessary to change. I made mistake.
2019-07-17 19:49:58 +09:00
KOBAYASHI Shuji 1b7516a4ae Fix (fixnum_value ... float_value).min with mruby-range-ext
Before this patch:

  $ bin/mruby -e 'p (2...4.0).min'  #=> TypeError

After this patch (same as CRuby and without `mruby-range-ext`):

  $ bin/mruby -e 'p (2...4.0).min'  #=> 2
2019-07-17 19:18:23 +09:00
KOBAYASHI Shuji 8cb37804c1 Allow mruby-range-ext to work with MRB_WITHOUT_FLOAT; ref 2add8641 2019-07-17 18:58:21 +09:00
Yukihiro "Matz" Matsumoto d5939879cc Fixed a bug in #4034 2019-07-17 10:39:17 +09:00
Yukihiro "Matz" Matsumoto b22bde6596 Avoid MRB_INLINE for mrb_str_modify(); ref #4579
Functions that are called infrequently need not to be inline.
2019-07-17 10:36:10 +09:00
Yukihiro "Matz" Matsumoto 2add864164 Allow mruby-range-ext to work with MRB_WITHOUT_FLOAT; ref #4576 2019-07-17 10:36:10 +09:00
Yukihiro "Matz" Matsumoto 5eef75b678 Merge pull request #4034 from i110/i110/inspect-recursion
Let inspect recursion do the right thing
2019-07-17 10:35:59 +09:00
Yukihiro "Matz" Matsumoto d605b72c1d Merge branch 'master' into i110/inspect-recursion 2019-07-17 10:35:41 +09:00
Yukihiro "Matz" Matsumoto 9af3b7c625 Merge pull request #4583 from shuujii/set-MRB_STR_ASCII-flag-in-some-methods-of-String
Copy receiver's `MRB_STR_ASCII` flag in some methods of `String`
2019-07-16 22:51:55 +09:00
KOBAYASHI Shuji 31492a177c Copy receiver's MRB_STR_ASCII flag in some methods of String 2019-07-16 21:56:58 +09:00
Yukihiro "Matz" Matsumoto d9a656756b Merge pull request #4576 from dearblue/error-configuration
Error needed/conflicts configuration
2019-07-16 12:12:58 +09:00
Yukihiro "Matz" Matsumoto 8e10a026e6 Merge pull request #4580 from shuujii/unify-type-of-line-number-to-uint16_t
Unify type of line number to `uint16_t`
2019-07-16 06:36:47 +09:00
Yukihiro "Matz" Matsumoto d7f9d71ea5 Merge pull request #4579 from shuujii/keep-MRB_STR_ASCII-flag-in-some-methods-of-String
Keep `MRB_STR_ASCII` flag in some methods of `String`
2019-07-16 06:35:12 +09:00
KOBAYASHI Shuji acad9567c1 Unify type of line number to uint16_t 2019-07-15 23:03:41 +09:00
KOBAYASHI Shuji 9093f3403f Add MRB_API to mrb_str_modify_keep_ascii() 2019-07-15 07:43:46 +09:00
Yukihiro "Matz" Matsumoto df293c7be1 Merge pull request #4578 from dearblue/improve-utf8len
Improve `utf8len()` performance with UTF-8
2019-07-15 05:34:12 +09:00
KOBAYASHI Shuji 380805ece2 Keep MRB_STR_ASCII flag in some methods of String 2019-07-14 19:13:19 +09:00
Yukihiro "Matz" Matsumoto 38624074e9 Merge pull request #4577 from dearblue/pack-unpack
Fix pack/unpack for base64; ref #4556
2019-07-14 18:59:41 +09:00
dearblue 7b260d9c2d Improve utf8len() performance with UTF-8 2019-07-14 18:55:38 +09:00
dearblue fd89948164 Fix empty array refers; ref #4556
For example, `"".unpack("")` evaluates to `[]`.
2019-07-14 12:03:44 +09:00
dearblue 4861be1171 Fix pack/unpack for base64; ref #4556
The pack/unpack "m" directive should be treated as a length rather than
an element count.
2019-07-14 12:03:00 +09:00
dearblue 109d926e9c Add pack/unpack test for base64 2019-07-15 10:41:32 +09:00
dearblue c96b517ea2 Error needed/conflicts configuration
The purpose is to clarify the error if there is a needed/conflicts
configuration at compile time.
2019-07-14 00:29:17 +09:00
dearblue c417c16788 Use stack memory for small name of attr accessors
Also integrated the common parts of `mrb_mod_attr_reader()` and
`mrb_mod_attr_writer()` functions.
2019-07-13 23:04:12 +09:00
Yukihiro "Matz" Matsumoto a7be9f1cab Merge pull request #4574 from shuujii/add-mruby-method-gem-to-default.gembox
Add `mruby-method` gem to `default.gembox` [ci skip]
2019-07-13 21:11:45 +09:00
KOBAYASHI Shuji e8a84d663f Add mruby-method gem to default.gembox [ci skip] 2019-07-13 20:42:32 +09:00
Yukihiro "Matz" Matsumoto b4cdced22f Enumerable#detect {and #find} should call ifnone; fix #4484
It's an error in ISO specification; 15.3.2.2.4 and 15.3.2.2.7
2019-07-13 18:05:01 +09:00
Yukihiro "Matz" Matsumoto a9fd2e6464 Resolve ambiguous argument warning. 2019-07-13 13:16:30 +09:00
Yukihiro "Matz" Matsumoto 9741df100b Change type of a variable for signedness mismatch; ref #4573 2019-07-13 13:13:21 +09:00
Yukihiro "Matz" Matsumoto 6b1cc6e2fe Avoid mrb_funcall() if possible using mrb_Float(); ref #4555 2019-07-13 12:54:02 +09:00
Yukihiro "Matz" Matsumoto c902e30494 Merge pull request #4571 from shuujii/consider--MP-flag-specified-when-parsing-.d-file
Consider `-MP` flag specified when parsing `.d` file
2019-07-12 21:46:35 +09:00
Yukihiro "Matz" Matsumoto 1556371370 Merge pull request #4573 from dearblue/fix-4569
Fix heap buffer overflow; fix #4569
2019-07-12 21:46:02 +09:00
dearblue bde2f35a9f Fix heap buffer overflow; fix #4569 2019-07-12 21:23:55 +09:00
Yukihiro "Matz" Matsumoto 54712c0624 Merge pull request #4572 from shuujii/lazy-load-tasks-toolchains
Lazy load `tasks/toolchains/*.rake`
2019-07-12 19:01:58 +09:00
KOBAYASHI Shuji 16e4657acd Lazy load tasks/toolchains/*.rake 2019-07-12 18:35:20 +09:00
KOBAYASHI Shuji 66909dfe86 Consider -MP flag specified when parsing .d file
`-MP` flag is used in `tasks/toolchains/android.rake`.
2019-07-12 14:23:35 +09:00
Yukihiro "Matz" Matsumoto c5f0a0256b Merge pull request #4569 from dearblue/improve-string-index
Improve performance `String#index` with UTF-8
2019-07-12 01:47:50 +09:00
dearblue e4249b1b9e Add UTF-8 test for String#index 2019-07-11 22:09:16 +09:00
dearblue 8c0d9ba1a3 Improve performance String#index with UTF-8
Based on Boyer-Moore-Horspool algorithm (Quick Search algorithm).

As a side effect, the correct position is returned even if an invalid UTF-8
string is given.

```console
% ./mruby@master -e 'p ("\xd1" * 100 + "#").index("#")'
50
% ./mruby@improve-index -e 'p ("\xd1" * 100 + "#").index("#")'
100
```

The other behavior should be the same as the current implementation.
2019-07-11 22:09:15 +09:00
Yukihiro "Matz" Matsumoto 5420895bcb Merge pull request #4568 from shuujii/remove-an-unused-argument-of-str_with_class
Remove an unused argument of `str_with_class()`
2019-07-10 22:33:38 +09:00
KOBAYASHI Shuji 80f78ca196 Remove an unused argument of str_with_class() 2019-07-10 21:53:17 +09:00
Yukihiro "Matz" Matsumoto bc7c5d376a Merge pull request #4562 from shuujii/set-MRB_STR_ASCII-flag-when-an-inline-symbol-is-stringized
Set `MRB_STR_ASCII` flag when an inline symbol is stringized
2019-07-09 21:22:15 +09:00
KOBAYASHI Shuji 23fc3339ee Set MRB_STR_ASCII flag when an inline symbol is stringized 2019-07-09 18:59:00 +09:00
Yukihiro "Matz" Matsumoto 59a76d48f8 Merge pull request #4560 from lopopolo/range-max-min-hang
Specialize Enumerable#max and Enumerable#min for Range
2019-07-09 18:44:53 +09:00
Ryan Lopopolo 3b77b5fd39 Revert Float dependency in Range#each 2019-07-09 02:08:14 -07:00
Ryan Lopopolo 56929362f5 Fix Range#min fast path with exclusive range 2019-07-09 01:48:15 -07:00
Ryan Lopopolo 0ad5ba7a0f Add a fast path for Float and Fixnum ranges for Range#max and Range#min
If no block is given and the Range has Fixnum or Float endpoints, do not iterate with
each and instead compare the endpoints directly. This implementation passes all of
the applicable specs from Ruby Spec.
2019-07-09 01:42:40 -07:00
Ryan Lopopolo eab07daf92 Add Range#max and Range#min tests from Ruby Spec 2019-07-09 01:41:10 -07:00
Ryan Lopopolo d9c5303793 Remove attempt at spec-compliant Range#max and Range#min from core 2019-07-09 01:40:44 -07:00
Yukihiro "Matz" Matsumoto 9add4a66c0 Merge pull request #4561 from shuujii/fix-the-order-of-expected-and-actual-in-test-t-range.rb
Fix the order of "expected" and "actual" in `test/t/range.rb`
2019-07-09 16:41:32 +09:00
Ryan Lopopolo 4085709ae1 Specialize Enumerable#max and Enumerable#min for Range
This patch prevents a hang for pathalogical (large) Ranges when
computing max and min.

Range inherits its implementation of max and min from Enumerable.
Enumerable implements max and min by calling each. For Range objects,
this is unnecessary since we know the max and the min by the end and
begin attributes.

It is also very slow. This code hangs unnecessarily:

    (0..2**32).max
    # ... hang
    (0..2**32).min
    # ... hang

This patch overrides max and min after including enumerable to yield
based on the begin and end methods.
2019-07-08 22:36:24 -07:00
Ryan Lopopolo 469c6261c6 Add tests for String Ranges
Range#each depends on String#upto which is implemented in mruby-string-ext
which is why these tests live there.
2019-07-08 22:36:24 -07:00
Ryan Lopopolo f7d59dfe23 Add tests for Range#max and Range#min 2019-07-08 22:36:24 -07:00
KOBAYASHI Shuji c8a7d0ab95 Fix the order of "expected" and "actual" in test/t/range.rb 2019-07-09 13:13:13 +09:00
Yukihiro "Matz" Matsumoto 0484bf133b Merge pull request #4559 from shuujii/add-macros-for-inline-symbol-for-readability
Add macros for inline symbol for readability
2019-07-09 09:25:54 +09:00
KOBAYASHI Shuji 0a79486380 Add macros for inline symbol for readability 2019-07-08 22:14:23 +09:00
Yukihiro "Matz" Matsumoto fd4e37404b Merge pull request #4557 from shuujii/fix-Numeric-step-to-infinity
Fix `Numeric#step` to infinity; ref. #4555
2019-07-08 18:50:28 +09:00
KOBAYASHI Shuji 32c2aa10c7 Fix Numeric#step to infinity; ref. #4555 2019-07-07 22:10:32 +09:00
Yukihiro "Matz" Matsumoto 519f396365 Merge pull request #4554 from shuujii/fix-missing--ifndef-MRB_ENABLE_ALL_SYMBOLS
Fix missing `#ifndef MRB_ENABLE_ALL_SYMBOLS`
2019-07-06 21:09:13 +09:00
KOBAYASHI Shuji df1f1002d9 Fix missing #ifndef MRB_ENABLE_ALL_SYMBOLS 2019-07-06 19:55:37 +09:00
Yukihiro "Matz" Matsumoto 280a83f029 Merge pull request #4553 from shuujii/read-write-MRB_STR_ASCII-flag-only-when-MRB_UTF8_STRING-is-defined
Read/write `MRB_STR_ASCII` flag only when `MRB_UTF8_STRING` is defined
2019-07-06 07:30:06 +09:00
KOBAYASHI Shuji f9bf2d9d8e Read/write MRB_STR_ASCII flag only when MRB_UTF8_STRING is defined 2019-07-05 22:19:31 +09:00
Yukihiro "Matz" Matsumoto 8294ce9fd4 It was too early to check key for undef; ref #4534 2019-07-04 23:11:57 +09:00
Yukihiro "Matz" Matsumoto 991bdd4ed7 Rename MRB_STR_NO_UTF to 'MRB_STR_ASCII`; close #4550
In #4550, @shuuji proposed the name name `MRB_STR_NO_MULTI_BYTE` for
more precise description. Although I agree that the name name is
correct, but the flag means the string does not contain multi byte UTF-8
characters, i.e. all characters fit in the range of ASCII.
2019-07-04 23:07:18 +09:00
Yukihiro "Matz" Matsumoto f4f3ced955 Merge pull request #4551 from dearblue/fix-4549
Fix heap buffer overflow; ref #4549
2019-07-04 22:50:06 +09:00
dearblue 2bb30481b6 Fix heap buffer overflow; ref #4549
This patch is showed in #4549.
2019-07-04 21:49:07 +09:00
Yukihiro "Matz" Matsumoto 93b3b83cc4 Merge pull request #4548 from shuujii/refine-document-to-mrb_get_args
Refine document to mrb_get_args()` [ci skip]
2019-07-04 01:49:00 +09:00
KOBAYASHI Shuji d915261590 Refine document to mrb_get_args()` [ci skip] 2019-07-03 20:41:30 +09:00
Yukihiro "Matz" Matsumoto 8c29b5998f Merge pull request #4546 from shuujii/fix-and-refine-error-message-in-mrb_obj_to_sym
Fix and refine error message in `mrb_obj_to_sym()`
2019-07-02 19:55:42 +09:00
KOBAYASHI Shuji 0d54dbb264 Fix and refine error message in mrb_obj_to_sym()
Before this patch:

  $ bin/mruby -e '1.respond_to?(2)'  #=> nil is not a symbol

After this patch (same as Ruby):

  $ bin/mruby -e '1.respond_to?(2)'  #=> 2 is not a symbol nor a string
2019-07-02 19:41:40 +09:00
Yukihiro "Matz" Matsumoto 38a10e8a98 Merge pull request #4545 from shuujii/remove-unused-C-header-file-from-src-etc.c
Remove unused C header file from `src/etc.c`
2019-07-02 00:20:37 +09:00
KOBAYASHI Shuji 7e3a8b7a75 Remove unused C header file from src/etc.c 2019-07-01 12:29:02 +09:00
Yukihiro "Matz" Matsumoto 8f19d516f9 Merge pull request #4544 from shuujii/fix-include-prepend-and-extend-to-frozen-object
Fix `include`, `prepend` and `extend` to frozen object
2019-06-30 16:29:55 +09:00
KOBAYASHI Shuji 97c9e6b000 Fix include, prepend and extend to frozen object 2019-06-30 15:06:39 +09:00
Yukihiro "Matz" Matsumoto cf69724083 Merge pull request #4540 from dearblue/assert-nesting
Nested `assert` for mrbtest
2019-06-29 21:38:32 +09:00
Yukihiro "Matz" Matsumoto ff5ec824fd Merge pull request #4541 from dearblue/replace-string-aset
Replace `String#[]=` method by C implements
2019-06-29 21:36:48 +09:00
dearblue 0ad1cacff3 Simplify mrb_str_aref_m() and mrb_str_aref()
It is integration with part of argument parsing used in `mrb_str_aset_m()`.
2019-06-29 14:41:43 +09:00
dearblue 0d452073f4 Replace String#[]= method by C implements
The purpose is to eliminate string objects that are temporarily created during processing.
2019-06-29 14:41:43 +09:00
dearblue 40030a5dbc Add test for String#[]= 2019-06-29 14:41:43 +09:00
dearblue a215292b6a Use nested assert 2019-06-29 11:54:17 +09:00
dearblue 1b9f949f36 Use a normal method instead of a lambda
Ref commit 35319bed01
2019-06-29 11:54:17 +09:00
dearblue 5f9034e428 Nested assert for mrbtest
When nesting `assert` used in test, it is indented and displayed.
Assertion numbers are concatenated by `"-"` at this time.

The purpose is to match the apparent numbers when failing with `assert_mruby`
which is defined by `mrbgems/mruby-bin-mruby/bintest/mruby.rb` for example.

Child assertions "skip" and "info" are reported as parent assertions "info"
and `$ok_test += 1`. The child assertions "ko" and "crash" are reported as the
parent assertion "ko" and `$ko_test += 1`.

When child assertions are mixed, "ko" takes precedence.

Incompatibility:

- `$mrbtest_assert_idx` takes `nil` or an integer array object.
  So far it was `nil` or an integer.
- `$asserts` points to the top of the internal stack in the `assert`.
- `$mrbtest_assert` points to the top of the internal stack in `assert`.
2019-06-29 11:54:10 +09:00
Yukihiro "Matz" Matsumoto 4f4e240024 Merge pull request #4538 from shuujii/use-__ENCODING__-in-tests
Use `__ENCODING__` in tests
2019-06-28 20:08:52 +09:00
Yukihiro "Matz" Matsumoto cf7a2292f3 Merge pull request #4539 from shuujii/remove-unnecessary-backticks-in-src-range.c
Remove unnecessary backticks in `src/range.c`; ref #2858
2019-06-28 20:07:34 +09:00
KOBAYASHI Shuji c9a3867ff2 Remove unnecessary backticks in src/range.c; ref #2858 2019-06-28 19:27:58 +09:00
KOBAYASHI Shuji bc3176da63 Use __ENCODING__ in tests
It cannot be used for `String#size` test if judging whether or not `MRB_UTF8_STRING` is defined by result of `String#size`.
2019-06-28 19:26:29 +09:00
Yukihiro "Matz" Matsumoto dc03bea854 Merge pull request #4535 from shuujii/add-modification-tests-for-immediate-value
Add modification tests for immediate value
2019-06-28 08:32:23 +09:00
Yukihiro "Matz" Matsumoto 051cb9ca37 Merge pull request #4536 from komainu8/fix_broken_links
Fix broken links for mruby.org
2019-06-28 08:23:50 +09:00
Yasuhiro Horimoto 5727d3a30c Fix broken links for mruby.org
A part of a fix for issue mruby/mruby.github.io#50
2019-06-27 22:31:25 +09:00
KOBAYASHI Shuji ad8473bd66 Add modification tests for immediate value 2019-06-27 18:47:48 +09:00
Yukihiro "Matz" Matsumoto 23783a4430 Skip copying delete keys in a hash; fix #4534 2019-06-27 09:35:58 +09:00
Yukihiro "Matz" Matsumoto 9bc7edd673 Merge pull request #4533 from shuujii/silence-unused-label-warnings
Silence unused label warnings from gcc; ref #4524
2019-06-26 15:57:44 +09:00
KOBAYASHI Shuji 28c510cf41 Silence unused label warnings from gcc; ref #4524
mruby/mruby/src/string.c:1722:4: warning: label 'bytes' defined but not used [-Wunused-label]
      bytes:
      ^~~~~
2019-06-26 15:38:20 +09:00
Yukihiro "Matz" Matsumoto 014f928229 Merge pull request #4524 from dearblue/reverse-utf8
Change to UTF-8 string reversing with in place
2019-06-26 13:22:42 +09:00
Yukihiro "Matz" Matsumoto 84779f0170 Merge pull request #4532 from shuujii/fix-String-byteslice-with-MRB_UTF8_STRING-and-some-edge-cases
Fix `String#byteslice` with `MRB_UTF8_STRING` and some edge cases
2019-06-26 12:41:56 +09:00
Yukihiro "Matz" Matsumoto a5b005b57c Merge pull request #4493 from dearblue/fix-rational-new
Fix rational new on 32 bits mode
2019-06-26 08:06:06 +09:00
Yukihiro "Matz" Matsumoto 45c99155d8 Merge pull request #4492 from dearblue/fix-complex-new
Fix complex new on 32 bits mode
2019-06-26 07:40:38 +09:00
KOBAYASHI Shuji 75df13a973 Fix String#byteslice with MRB_UTF8_STRING and some edge cases
Example:

  $ bin/mruby -e '
    p "あa".byteslice(1)
    p "bar".byteslice(3)
    p "bar".byteslice(4..0)
  '

  Before this patch:

    "a"
    ""
    RangeError (4..0 out of range)

  After this patch (same as Ruby):

    "\x81"
    nil
    nil
2019-06-25 23:09:23 +09:00
Yukihiro "Matz" Matsumoto f268ecaf0d Merge pull request #4516 from shuujii/fix-struct-RRange-overflow-on-32-bit-CPU-with-MRB_NAN_BOXING
Fix `struct RRange` overflow on 32-bit CPU with `MRB_NAN_BOXING`
2019-06-25 22:44:31 +09:00
Yukihiro "Matz" Matsumoto a4124a3113 Merge pull request #4517 from shuujii/remove-unneeded-statement-in-SET_OBJ_VALUE-with-boxing_word.h
Remove unneeded statement in `SET_OBJ_VALUE` with `boxing_word.h`
2019-06-25 20:32:39 +09:00
Yukihiro "Matz" Matsumoto e59a80c787 Merge pull request #4528 from shuujii/fix-argument-specs-to-Array
Fix argument specs to `Array`
2019-06-25 20:27:26 +09:00
Yukihiro "Matz" Matsumoto d4c9eff67b Merge pull request #4530 from shuujii/compare-obj-pointer-directly-instead-of-using-mrb_obj_eq-in-mrb_gc_unregister
Compare obj pointer directly instead of using mrb_obj_eq in mrb_gc_unregister
2019-06-25 18:50:46 +09:00
Yukihiro "Matz" Matsumoto 63d8b5e1e3 Fixed mrb_iv_remove with immediate objects; fix #4519
The #4520 tried to address the issue, but it changes the type of
`mrb_check_frozen` argument; close #4520
2019-06-25 18:41:17 +09:00
Yukihiro "Matz" Matsumoto 6724416d5c Fixed a bug caused by to_s that returns nil; fix 4504 2019-06-25 18:07:48 +09:00
Yukihiro "Matz" Matsumoto dc21024ec7 Fix mrb_str_to_str() to handle symbols. 2019-06-25 18:07:48 +09:00
Yukihiro "Matz" Matsumoto ace0c76a69 Renamed stacked to onstack; ref #4523 2019-06-25 18:07:48 +09:00
Ryan Lopopolo 46c972f746 Unify loops to minimize bytecode size 2019-06-25 00:01:51 +02:00
KOBAYASHI Shuji f71270df77 Compare obj pointer directly instead of using mrb_obj_eq in mrb_gc_unregister
Because immediate values are not registered.
2019-06-24 18:55:05 +09:00
KOBAYASHI Shuji 1fd08aee15 Fix argument specs to Array 2019-06-23 20:01:33 +09:00
Ryan Lopopolo 6b92acf361 Use explicit block parameter 2019-06-23 03:40:39 +01:00
Ryan Lopopolo 8ea45b862a Optimize String#each_line 2019-06-23 03:29:47 +01:00
Yukihiro "Matz" Matsumoto cb3ee2d050 Merge pull request #4526 from shuujii/refine-Hash-rehash-example
Refine `Hash#rehash` example [ci skip]
2019-06-23 10:56:41 +09:00
Yukihiro "Matz" Matsumoto af9637e545 Merge pull request #4523 from dearblue/use-stack
Use stack memory for small name of Struct members
2019-06-23 10:51:34 +09:00
Yukihiro "Matz" Matsumoto 36f1c26d9d Merge pull request #4525 from dearblue/utf8len-overflow
Fix potential overflow in `utf8len()`
2019-06-23 10:50:19 +09:00
dearblue 11e09dc5db Fix the unnecessary mrb_str_modify() call
Now to be calls `mrb_str_modify()` only once when 2 or more characters.
2019-06-22 23:09:36 +09:00
dearblue ec03e3f54a Delete the unnecessary block brace in mrb_str_reverse_bang 2019-06-22 23:02:29 +09:00
dearblue 567075aab9 Fix string brakes for one UTF-8 charactor 2019-06-22 22:58:18 +09:00
dearblue 5af8a9777b Add test for one UTF-8 charactor 2019-06-22 22:58:08 +09:00
dearblue bd2c93c2df Change to UTF-8 string reversing with in place
Reverses UTF-8 strings without allocated heap for working memory.

 1. String before reversing:
    ```
    "!yburmの界世"
    # byte unit
    [33, 121, 98, 117, 114, 109, 227, 129, 174, 231, 149, 140, 228, 184, 150]
    ```
 2. Reverse the byte order of each character:
    ```
    [33, 121, 98, 117, 114, 109, 174, 129, 227, 140, 149, 231, 150, 184, 228]
    ```
 3. Reverse the whole byte order and complete:
    ```
    [228, 184, 150, 231, 149, 140, 227, 129, 174, 109, 114, 117, 98, 121, 33]
    # string
    "世界のmruby!"
    ```
2019-06-22 22:36:58 +09:00
dearblue 7c6d6effae Replacement to function for string reversing 2019-06-22 22:36:58 +09:00
Ryan Lopopolo a932b8c96a Speed up base case by 2x
Make non-paragraph mode twice as fast. Performance is within a factor of 2
of the original implementation.
2019-06-22 12:55:02 +01:00
Ryan Lopopolo 0f516bbe1d Add paragraph mode to String#each_line in mrblib
mruby/mruby#4511 demonstrated an infinite loop in `String#each_line` when
given an empty string separator. In MRI, an empty separator places
String#each_line in paragraph mode, where the String is separated on
successive runs of newlines. In paragraph mode, the String
`"abc\n\n\ndef\nxyz"` is split into `["abc\n\n\n", "def\nxyz"]`.

This commit makes the String#each_line implementation as close to
ruby/spec compliant as possible given the limitations of mruby core.
With this patch, the following specs fail for `String#each_line`:

- uses `$/` as the separator when none is given (can be fixed by
  aliasing and redefining the method to use $/ as the default value
  of separator in mruby-io)
- when no block is given returned Enumerator size should return nil
  (`Enumerator#size` is not supported on mruby)
- tries to convert the separator to a string using to_str (`String#to_str`
  is not implemented on mruby)

This patch has similar memory consumption compared to the prior
implementation and is takes 4x the time the prior implementation takes to
execute:

```console
/usr/bin/time -l ./bin/mruby -e '("aaa\n\nbbbbb\n\n\n\n\ncccc" * 100000).each_line("\n") { }';
```
2019-06-22 12:31:01 +01:00
KOBAYASHI Shuji 28de6b0da1 Refine Hash#rehash example [ci skip]
Previous example doesn't work because string key (frozen) can't be modified.
2019-06-22 19:07:01 +09:00
dearblue 7583539029 Fix potential overflow in utf8len()
For example on 32 bit mode, when `p = 0xfffffffd`, `e = 0xfffffffe`
and `len = 4`, the sum of `p` and `len` can be to `1`, and comparison
with `e` will to be false.

As a result, a segmentation fault occurs by referring to address 0.
2019-06-22 18:16:38 +09:00
Yukihiro "Matz" Matsumoto f94551ad40 Merge pull request #4518 from shuujii/add-ISO-section-number-to-Kernel-local_variables
Add ISO section number to `Kernel.#local_variables` [ci skip]
2019-06-22 17:52:32 +09:00
dearblue a76da32567 Use stack memory for small name of Struct members 2019-06-22 17:49:07 +09:00
Yukihiro "Matz" Matsumoto f13c5969eb Merge pull request #4521 from shuujii/move-Kernel-__send__-test-to-core-from-mruby-metaprog
Move `Kernel#__send__` test to core from `mruby-metaprog`
2019-06-22 16:14:44 +09:00
KOBAYASHI Shuji c43ff6fa40 Move Kernel#__send__ test to core from mruby-metaprog 2019-06-21 22:02:29 +09:00
KOBAYASHI Shuji 77996e6adc Add ISO section number to Kernel.#local_variables [ci skip] 2019-06-20 19:59:56 +09:00
KOBAYASHI Shuji 4d9d6faf0d Remove unneeded statement in SET_OBJ_VALUE with boxing_word.h
`(r).value.bp` and `v` have the same value due to assignment of the line
preceding the removed line.
2019-06-19 17:50:20 +09:00
Yukihiro "Matz" Matsumoto c53b7cedcc Merge pull request #4510 from shuujii/remove-unneeded-mrb_str_dup-in-Module-name
Remove unneeded `mrb_str_dup()` in `Module#name`
2019-06-19 08:50:14 +09:00
Yukihiro "Matz" Matsumoto 791391cf5b Merge pull request #4514 from mimaki/fix-error.h
Fix path of `error.h`.
2019-06-19 07:58:57 +09:00
KOBAYASHI Shuji 81828f8b08 Fix struct RRange overflow on 32-bit CPU with MRB_NAN_BOXING 2019-06-18 18:17:03 +09:00
Hiroshi Mimaki b630bf59ef Fix path of error.h. 2019-06-18 13:27:16 +09:00
Ryan Lopopolo eeb7d3a04f Support parsing a Regexp literal with 'o' option
CRuby supports a 'o' `Regexp` option for `Regexp` literals, e.g. `/foo/o` that disables multiple interpolation passes.

This commit adds support for parsing such literals. Nothing is done with the option, it is consumed and ignored by the parser.
2019-06-17 21:42:19 +01:00
KOBAYASHI Shuji faec8331b7 Remove unneeded mrb_str_dup() in Module#name
`mrb_class_path()` always returns a new string or `nil`.
2019-06-17 21:46:30 +09:00
Yukihiro "Matz" Matsumoto 1685c459dd Merge pull request #4508 from shuujii/fix-cvar-ivar-const-and-method-can-be-removed-to-frozen-object
Fix cvar, ivar, const and method can be removed to frozen object
2019-06-17 12:22:33 +09:00
Yukihiro "Matz" Matsumoto e514264b53 Merge pull request #4507 from shuujii/fix-index-in-error-message-of-Struct-aref
Fix index in error message of `Struct#[]`
2019-06-17 12:21:48 +09:00
Yukihiro "Matz" Matsumoto 0fba500826 Fixed indentation in parse.y 2019-06-17 12:18:57 +09:00
Yukihiro "Matz" Matsumoto 4296c77e29 Allow newlines and comments between method calls. 2019-06-17 12:18:57 +09:00
Yukihiro "Matz" Matsumoto 4124047cce Support &. at the beginning of the line. 2019-06-17 12:18:57 +09:00
Yukihiro "Matz" Matsumoto d895c5fe5a Fixed wrong behavior on .. at the beginning of the line. 2019-06-17 12:18:57 +09:00
Yukihiro "Matz" Matsumoto c1901539a8 Merge pull request #4502 from shuujii/adjust-allocation-size-in-mrb_id_attrset-mruby-struct
Adjust allocation size in `mrb_id_attrset()` (`mruby-struct`)
2019-06-17 12:18:48 +09:00
KOBAYASHI Shuji 030dd6655e Fix cvar, ivar, const and method can be removed to frozen object 2019-06-16 20:43:23 +09:00
KOBAYASHI Shuji 9e378b451f Fix index in error message of Struct#[]
Before this patch:

  $ bin/mruby -e 'Struct.new(:a,:b).new[-3]'
  #=> offset -1 too small for struct(size:2) (IndexError)

After this patch (same as Ruby):

  $ bin/mruby -e 'Struct.new(:a,:b).new[-3]'
  #=> offset -3 too small for struct(size:2) (IndexError)
2019-06-15 19:41:04 +09:00
Yukihiro "Matz" Matsumoto ab5ffb308b Merge pull request #4506 from shuujii/remove-a-meaningless-branch-condition-in-mruby-struct
Remove a meaningless branch condition in `mruby-struct`
2019-06-14 13:42:58 +09:00
KOBAYASHI Shuji 6084048b28 Remove a meaningless branch condition in mruby-struct
The following branch condition is always true:

  // mrbgems/mruby-struct/src/struct.c:187 in make_struct_define_accessors()
  if (is_local_id(mrb, name) || is_const_id(mrb, name)) {
2019-06-14 10:26:19 +09:00
Yukihiro "Matz" Matsumoto 27109d1ae0 Merge pull request #4505 from shuujii/fix-class-name-validation-in-Struct.new
Fix class name validation in `Struct.new`
2019-06-14 06:22:57 +09:00
KOBAYASHI Shuji 9bd692bc67 Fix class name validation in Struct.new
Before this patch:

  $ bin/mruby -e 'p Struct.new("A-")'
  #=> Struct::"A-"

After this patch:

  $ bin/mruby -e 'p Struct.new("A-")'
  #=> NameError: identifier A- needs to be constant
2019-06-13 21:24:48 +09:00
Yukihiro "Matz" Matsumoto 1a98b94100 Merge pull request #4500 from shuujii/kernel-global_variables-should-not-include-undefined-gvar
`Kernel#global_variables` should not include undefined `$1`-`$9`
2019-06-13 10:24:45 +09:00
Yukihiro "Matz" Matsumoto e2e312dbfc Merge pull request #4503 from shuujii/fix-typo-in-String-setbyte-error-message
Fix typo in `String#setbyte` error message
2019-06-13 10:24:11 +09:00
KOBAYASHI Shuji db3e6f6ac6 Fix typo in String#setbyte error message 2019-06-12 20:45:27 +09:00
KOBAYASHI Shuji ee955b58f7 Adjust allocation size in mrb_id_attrset() (mruby-struct) 2019-06-12 18:52:58 +09:00
Yukihiro "Matz" Matsumoto b8d8f8fdae Merge pull request #4501 from shuujii/remove-redundant-colon-in-Proc-inspect-mruby-proc-ext
Remove redundant colon in `Proc#inspect` (`mruby-proc-ext`)
2019-06-11 20:53:39 +09:00
KOBAYASHI Shuji 3b9b326d3c Remove redundant colon in Proc#inspect (mruby-proc-ext)
Before this patch:

  $ bin/mruby -e 'p proc{}'  #=> #<Proc:0x7fd5eb8206d0@-e::1>

After this patch:

  $ bin/mruby -e 'p proc{}'  #=> #<Proc:0x7fd5eb8206d0@-e:1>
2019-06-11 20:33:07 +09:00
Yukihiro "Matz" Matsumoto 313059d08c Merge pull request #4496 from dearblue/replace-obsolete
Replace obsolete macros
2019-06-11 09:36:15 +09:00
KOBAYASHI Shuji 38f1da6f26 Kernel#global_variables should not include undefined $1-$9
- They are not include in Ruby.
- Appear in duplicate when `$1`-`$9` are defined.
2019-06-10 18:46:57 +09:00
Yukihiro "Matz" Matsumoto 04999e969f Merge pull request #4495 from shuujii/remove-Kernel-global_variables-from-core
Remove `Kernel#global_variables` from core
2019-06-10 15:42:33 +09:00
Yukihiro "Matz" Matsumoto 7cfa4d6011 Merge pull request #4494 from shuujii/clarify-mruby-kernel-object-ext-gem-summary
Clarify `mruby-(kernel|object)-ext` gem summary; ref 8e637bdd [ci skip]
2019-06-10 15:40:41 +09:00
Yukihiro "Matz" Matsumoto a9e94d43b3 Merge pull request #4499 from shuujii/fix-missing-assertions-in-test-t-syntax.rb
Fix missing assertions in `test/t/syntax.rb`
2019-06-10 15:39:56 +09:00
KOBAYASHI Shuji ffb700dea0 Fix missing assertions in test/t/syntax.rb 2019-06-09 18:27:28 +09:00
Yukihiro "Matz" Matsumoto a7ae278d1a Merge pull request #4497 from shuujii/remove-Check-the-usage-of-a-NUL-character-test
Remove "Check the usage of a NUL character" test
2019-06-09 07:57:51 +09:00
KOBAYASHI Shuji 2e160f53db Remove "Check the usage of a NUL character" test
Because there is not assertion in this test and NUL character literal is
used in other tests.
2019-06-08 22:32:19 +09:00
dearblue f8f75fc9c6 Replace obsolete macros 2019-06-07 22:54:03 +09:00
KOBAYASHI Shuji 4b83fe8b04 Remove Kernel#global_variables from core
This method is defined in `mruby-metaprog` gem.
2019-06-07 22:02:43 +09:00
KOBAYASHI Shuji 05493e651d Clarify mruby-(kernel|object)-ext gem summary; ref 8e637bdd [ci skip] 2019-06-06 20:21:40 +09:00
dearblue 64b3d452ec Drop precisions for rational when big numbers 2019-06-05 23:25:28 +09:00
dearblue 5e69760d91 Fix build error if struct mrb_rational is bigger than RIStruct
In that case, to be switched implementation with `RData`.

It is based to "complex".
2019-06-05 23:25:23 +09:00
dearblue 82831c6acd Fix not frozen in Complex method by RData
Object allocation was separated, and initialization was made common.
2019-06-05 23:19:16 +09:00
dearblue 97e999c409 Fix memory leak in Complex method by RData
If `Data_Wrap_Struct()` raises a `NoMemoryError` exception,
it will leak memory if it does `mrb_malloc()` first.
2019-06-05 23:19:16 +09:00
Yukihiro "Matz" Matsumoto 2847692d59 Merge pull request #4491 from shuujii/fix-missing-assertions-in-test-t-module.rb
Fix missing assertions in `test/t/module.rb`
2019-06-05 23:10:36 +09:00
KOBAYASHI Shuji dc1905e1bd Fix missing assertions in test/t/module.rb 2019-06-05 19:13:36 +09:00
Yukihiro "Matz" Matsumoto 913a148ddc Merge pull request #4489 from shuujii/fIx-typo-in-mrblib-range.rb
Fix typo in `mrblib/range.rb` [ci skip]
2019-06-05 01:46:58 +09:00
Yukihiro "Matz" Matsumoto d47d561da3 Merge pull request #4490 from dearblue/explicit-cast
Need explicit cast for C++
2019-06-05 01:45:37 +09:00
dearblue 81ea89f10e Need explicit cast for C++ 2019-06-04 21:41:40 +09:00
KOBAYASHI Shuji c75402a57b Fix typo in mrblib/range.rb [ci skip] 2019-06-04 10:45:13 +09:00
Yukihiro "Matz" Matsumoto 3b061a90fe Merge pull request #4485 from shuujii/fix-missing-assertions-in-mruby-objectspace-test
Fix missing assertions in `mruby-objectspace` test
2019-06-02 22:11:43 +09:00
KOBAYASHI Shuji 92f00d3e58 Fix missing assertions in mruby-objectspace test 2019-06-02 19:15:20 +09:00
Yukihiro "Matz" Matsumoto 366617dbc1 Merge pull request #4482 from shuujii/comment-out-the-empty-Array-bsearch_index-test
Comment out the empty `Array#bsearch_index` test
2019-06-01 11:02:07 +09:00
KOBAYASHI Shuji c1e6f324c2 Comment out the empty Array#bsearch_index test 2019-05-31 20:50:54 +09:00
Yukihiro "Matz" Matsumoto 4677918676 Merge pull request #4481 from shuujii/fix-missing-assertions-in-mruby-fiber-test
Fix missing assertions in `mruby-fiber` test
2019-05-30 22:34:54 +09:00
KOBAYASHI Shuji 05056ddac4 Fix missing assertions in mruby-fiber test 2019-05-30 21:42:01 +09:00
Yukihiro "Matz" Matsumoto 729931a06c Fix inverted compilation condition; fix #4478 2019-05-30 12:34:31 +09:00
Yukihiro "Matz" Matsumoto 53f93158a2 Merge pull request #4477 from shuujii/kernel-itself-should-not-be-a-module-function
`Kernel#itself` should not be a module function
2019-05-29 20:16:56 +09:00
KOBAYASHI Shuji 03fce2e206 Kernel#itself should not be a module function 2019-05-29 15:57:18 +09:00
Yukihiro "Matz" Matsumoto 855f2cdeea Slightly simplify Rational#==; ref #4475 2019-05-29 11:49:21 +09:00
Yukihiro "Matz" Matsumoto 2b81ea7ec1 Add mrb_alloca again; ref #4470
This time, the allocated memory comes from the string object, which is
referenced from GC arena. The memory region will be reclaimed when the C
function called from VM is terminated, or the GC arena is restored.
2019-05-29 11:47:12 +09:00
Yukihiro "Matz" Matsumoto a1e1af44d2 Merge pull request #4475 from shuujii/fix-Rational-eq-Complex
Fix `Rational#==(Complex)`
2019-05-29 11:46:42 +09:00
Yukihiro "Matz" Matsumoto 4b82fdb637 Merge pull request #4476 from shuujii/fix-missing-assertions-in-mruby-pack-test
Fix missing assertions in `mruby-pack` test
2019-05-29 10:35:45 +09:00
KOBAYASHI Shuji ffc915fdee Fix missing assertions in mruby-pack test 2019-05-28 18:26:01 +09:00
Yukihiro "Matz" Matsumoto 1727f0b7ff Merge pull request #4474 from shuujii/use-undefined.equal-obj2-instead-of-obj2-eq-undefined-in-assert.rb
Use `$undefined.equal?(obj2)` instead of `obj2 == $undefined` in `ass…
2019-05-28 10:50:30 +09:00
Yukihiro "Matz" Matsumoto 6c5cb109ee Merge pull request #4473 from shuujii/make-some-functions-static-in-mrbgems-mruby-metaprog-src-metaprog.c
Make some functions static in `mrbgems/mruby-metaprog/src/metaprog.c`
2019-05-27 23:32:55 +09:00
KOBAYASHI Shuji a97a455c03 Use $undefined.equal?(obj2) instead of obj2 == $undefined in assert.rb
In case `obj2.==` is broken.
2019-05-27 21:43:55 +09:00
KOBAYASHI Shuji 902b2ce3c6 Fix Rational#==(Complex)
Consider a Numreic class like `Complex` that does not have `<=>` but `==`
works (`0i == 0r` is `true`).
2019-05-27 21:29:49 +09:00
KOBAYASHI Shuji 534b578da7 Make some functions static in mrbgems/mruby-metaprog/src/metaprog.c 2019-05-27 18:26:54 +09:00
Yukihiro "Matz" Matsumoto 8ad777c702 Merge pull request #4470 from dearblue/remove-mrb_alloca
Remove `mrb_alloca()` function
2019-05-27 14:45:10 +09:00
Yukihiro "Matz" Matsumoto 459c439243 Merge pull request #4472 from shuujii/move-mrb_mod_s_nesting-to-mruby-metaprog-gem-from-the-core
Move `mrb_mod_s_nesting()` to `mruby-metaprog` gem from the core
2019-05-27 08:17:06 +09:00
Yukihiro "Matz" Matsumoto 879f1586ab Merge pull request #4471 from shuujii/add-Complex.rect
Add `Complex.rect`
2019-05-26 23:07:11 +09:00
KOBAYASHI Shuji 779251de64 Move mrb_mod_s_nesting() to mruby-metaprog gem from the core 2019-05-26 20:32:04 +09:00
KOBAYASHI Shuji 0bdb185a6f Add Complex.rect 2019-05-26 20:17:03 +09:00
Yukihiro "Matz" Matsumoto 4261ba9443 Remove some overhead from methods defined in Ruby in Complex. 2019-05-26 09:19:29 +09:00
Yukihiro "Matz" Matsumoto c33ab7c0bb Merge pull request #4469 from dearblue/double-rounds
Fix double rounded by negative index for `String#[]`
2019-05-26 09:17:40 +09:00
dearblue d1e1bb0d5b Remove mrb_alloca() function
When I found this function, I expected it to behave the same as the
`alloca(3)` function, but it is accually the `mrb_alloca()` function
does not free the heap until the `mrb_close()` function is called.

Also, even if it is deleted, it can be replaced with the combination
of the `MRB_TT_DATA` object and the `mrb_gv_set()` function if it is
sure necessary.
2019-05-25 23:59:43 +09:00
dearblue ecfca8def7 Fix double rounded by negative index
- Before patched:
  ```
  $ mruby -e 'p (-12..-1).map { |i| "Hello"[i] }.join'
  "HelloHello"
  ```
- After patched:
  ```
  $ mruby -e 'p (-12..-1).map { |i| "Hello"[i] }.join'
  "Hello"
  ```
2019-05-25 22:43:07 +09:00
Yukihiro "Matz" Matsumoto f455cb6c40 Merge pull request #4467 from dearblue/naming-mrb_range_beg_len
Name the return value of `mrb_range_beg_len()`
2019-05-25 22:25:58 +09:00
dearblue 56e0e1934d Name the return value of mrb_range_beg_len() 2019-05-25 12:12:21 +09:00
Yukihiro "Matz" Matsumoto c6f30e8f17 Merge pull request #4466 from shuujii/fix-the-order-of-expected-and-actual-in-mruby-time-test
Fix the order of "expected" and "actual" in `mruby-time` test
2019-05-25 00:12:53 +09:00
KOBAYASHI Shuji 240bbc39e1 Fix the order of "expected" and "actual" in mruby-time test 2019-05-24 21:02:22 +09:00
Yukihiro "Matz" Matsumoto 43a26aa958 Merge pull request #4463 from shuujii/freeze-Rational-and-Complex-objects
Freeze `Rational` and `Complex` objects
2019-05-23 19:54:45 +09:00
KOBAYASHI Shuji 48903850e9 Freeze Rational and Complex objects 2019-05-23 13:40:49 +09:00
Yukihiro "Matz" Matsumoto 5f4eb87735 Merge pull request #4462 from shuujii/kernel-Rational-requires-numerator
`Kernel#Rational` requires numerator
2019-05-22 20:17:11 +09:00
KOBAYASHI Shuji 8513abd404 Kernel#Rational requires numerator 2019-05-22 19:57:35 +09:00
Yukihiro "Matz" Matsumoto 85a2dfc841 Merge pull request #4403 from dearblue/read-irep-from-buf
Read irep from buffers
2019-05-22 08:58:50 +09:00
Yukihiro "Matz" Matsumoto 38f8edbdd7 Update ISO section number for some Numeric methods. 2019-05-21 21:12:33 +09:00
Yukihiro "Matz" Matsumoto c02e63eb77 Use MRB_TT_ISTRUCT for Complex numbers if possible. 2019-05-21 21:08:26 +09:00
Yukihiro "Matz" Matsumoto fccec8964a Implements part of Complex class in C. 2019-05-21 21:08:26 +09:00
Yukihiro "Matz" Matsumoto e941cf06a3 Export mrb_int_value that converts mrb_float to Fixnum.
Or `Float` if `mrb_float` value is too big (or too small) to fit in
`mrb_int`. The `_int_` in `mrb_int_value` means `Integral` module, which
represents integer-like values in mruby.
2019-05-21 21:08:26 +09:00
Yukihiro "Matz" Matsumoto f6e4145ad9 Remove Complex(string) complex generation.
It should raise an error.
2019-05-21 21:08:26 +09:00
Yukihiro "Matz" Matsumoto b7f85b9df9 Should not refer Float class in case of MRB_WITHOUT_FLOAT.
This commit removes `Float` from `rational.c`.
2019-05-21 21:08:26 +09:00
Yukihiro "Matz" Matsumoto 5d30309e98 Silence the return value warnings from gcc; ref 237a57b 2019-05-21 21:08:26 +09:00
Yukihiro "Matz" Matsumoto eca20a16bd Merge pull request #4461 from shuujii/move-comparision-methods-to-Integral-from-Numeric
Move `**`,`/`,`quo`,`div` and comparison methods to Integral from Numeric
2019-05-21 21:07:39 +09:00
KOBAYASHI Shuji 3b46831da8 Move **,/,quo,div and comparison methods to Integral from Numeric
Having these methods in Numeric can get in the way of creating subclasses of
Numeric because they only support Fixnum and Float.
2019-05-21 20:43:42 +09:00
Yukihiro "Matz" Matsumoto 24525fd1ae Merge pull request #4459 from shuujii/revert-part-of-4457
Revert part of #4457
2019-05-21 09:34:42 +09:00
KOBAYASHI Shuji 5d6c1794ad Revert part of #4457 2019-05-21 09:31:06 +09:00
Yukihiro "Matz" Matsumoto 70e754e6da Merge pull request #4457 from shuujii/change-the-order-of-expected-and-actual-in-mruby-rational-test
Change the order of "expected" and "actual" in `mruby-rational` test
2019-05-21 07:56:21 +09:00
Yukihiro "Matz" Matsumoto a642f73b44 Merge pull request #4458 from shuujii/drop-dependency-from-mruby-rational-to-mruby-object-ext
Drop dependency from `mruby-rational` to `mruby-object-ext`
2019-05-21 06:38:04 +09:00
KOBAYASHI Shuji 3db5d7fe3d Drop dependency from mruby-rational to mruby-object-ext 2019-05-20 18:36:13 +09:00
KOBAYASHI Shuji 97600ded8d Change the order of "expected" and "actual" in mruby-rational test 2019-05-20 18:24:18 +09:00
Yukihiro "Matz" Matsumoto 8b8bf9f3f6 Add new functions for numerical operation; ref 237a57b
New functions:
* mrb_num_plus(mrb, x, y)
* mrb_num_minus(mrb, x, y)
* num_num_mul(mrb, x, y)
2019-05-20 14:59:25 +09:00
Yukihiro "Matz" Matsumoto 05e7544583 Merge pull request #4455 from dearblue/remove-LINE-section
Remove "LINE" section reader
2019-05-19 22:29:25 +09:00
Yukihiro "Matz" Matsumoto e60891e453 Merge pull request #4454 from shuujii/fix-Rational-cmp-Numeric
Fix `Rational#<=>(Numeric)`
2019-05-19 22:24:49 +09:00
Yukihiro "Matz" Matsumoto 3e8b19b00e Merge pull request #4453 from shuujii/move-Kernel-instance_eval-to-BasicObject
Move `Kernel#instance_eval` to `BasicObject`
2019-05-19 22:23:57 +09:00
Yukihiro "Matz" Matsumoto aafaf79fdd Merge pull request #4452 from shuujii/move-Kernel-equal-to-BasicObject
Move `Kernel#equal? to `BasicObject`
2019-05-19 22:23:14 +09:00
Yukihiro "Matz" Matsumoto 8170f6899c Merge pull request #4450 from shuujii/move-Kernel-instance_exec-to-BasicObject
Move `Kernel#instance_exec` to `BasicObject`
2019-05-19 22:21:31 +09:00
Yukihiro "Matz" Matsumoto 8e637bdd83 Should clarify the role of mruby-kernel-ext and mruby-object-ext; close #4449
The former should contain function like methods, and the latter should
contain methods shared by all objects.
2019-05-19 22:17:56 +09:00
KOBAYASHI Shuji a6eb01837b Fix Rational#<=>(Numeric)
Reported by Sergey Ukrainskiy: https://github.com/mruby/mruby/commit/f5fb1307b017fb972c12b4ec4b1866d789b0ca09#r33590698
2019-05-19 13:52:18 +09:00
dearblue 67fc3428cb Remove "LINE" section reader
Because it is not currently output by `mrbc`.
2019-05-19 11:09:25 +09:00
KOBAYASHI Shuji 9c79c28604 Move Kernel#instance_eval to BasicObject 2019-05-18 21:17:47 +09:00
KOBAYASHI Shuji 6fb5979d29 Move Kernel#equal? to BasicObject` 2019-05-18 20:57:54 +09:00
KOBAYASHI Shuji ef5dd5d31d Move Kernel#instance_exec to BasicObject 2019-05-18 19:19:52 +09:00
Yukihiro "Matz" Matsumoto 1cdb3ec93c Merge pull request #4448 from shuujii/move-Object-Rational-Complex-to-Kernel
Move `Object#(Rational|Complex)` to `Kernel`
2019-05-18 18:57:47 +09:00
Yukihiro "Matz" Matsumoto ed70e81264 Merge pull request #4447 from shuujii/move-Numeric-__coerce_step_counter-to-Integral
Move `Numeric#__coerce_step_counter` to `Integral`
2019-05-18 18:56:39 +09:00
KOBAYASHI Shuji 6c9c189e4b Move Object#(Rational|Complex) to Kernel 2019-05-18 18:31:55 +09:00
KOBAYASHI Shuji 4f71e9eebe Move Numeric#__coerce_step_counter to Integral
This method is only used in `Integral#step`
2019-05-18 18:22:56 +09:00
Yukihiro "Matz" Matsumoto 89d2926415 Add ISO section number to Module#===. 2019-05-18 11:48:59 +09:00
Yukihiro "Matz" Matsumoto bd7328f5e6 Implement Rational._new in C. 2019-05-18 11:23:59 +09:00
Yukihiro "Matz" Matsumoto e41f15747e Rename struct RIstruct to struct RIStruct. 2019-05-18 11:10:20 +09:00
Yukihiro "Matz" Matsumoto ace0d3949b Support MRB_WITHOUT_FLOAT.
I assume there's no realistic usage of `Rational` with
`MRB_WITHOUT_FLOAT`. But just for consistency.
2019-05-18 08:38:45 +09:00
Yukihiro "Matz" Matsumoto d2a2af2481 Merge pull request #4446 from dearblue/PoC-tuning-profiles
(Proof of Concept) mruby tuning profiles [ci skip]
2019-05-17 22:45:45 +09:00
Yukihiro "Matz" Matsumoto b7bc03aa18 Stop wrapping the filename by double quotes; ref #4440 2019-05-17 22:39:41 +09:00
Yukihiro "Matz" Matsumoto 8d37a3575b Revert "Add support for CC="gcc --option ..." again"
This reverts commit d5c8868346.
2019-05-17 22:37:45 +09:00
dearblue a14ae80102 (Proof of Concept) mruby tuning profiles [ci skip]
Not only mruby, it is one of the difficult things to adjust the performance vs. memory efficiency of the software.
If the approximate target device is divided and the adjustment value for it is prepared by default, it is a good indicator to do fine adjustment.

This PR divides into four profiles.

***Caution: There is no basis for the definitions in the patch.***

- `MRB_CONSTRAINED_BASELINE_PROFILE` - for microprocessors. Reduce memory consumption.
- `MRB_BASELINE_PROFILE` - Default value of mruby.
- `MRB_MAIN_PROFILE` - For desktop computers. Assume that a huge amount of RAM, 10 MiB or more, is on board.
- `MRB_HIGH_PROFILE` - for servers. Assume that mruby VM has a long life.

As you can see the profile name has been ~~stolen~~ imitated from H.264.
2019-05-17 22:32:01 +09:00
Yukihiro "Matz" Matsumoto a46da9e44d Merge pull request #4445 from bshastry/modifiy-ossfuzz-fork-config
Add/Edit ossfuzz config options
2019-05-17 21:31:09 +09:00
Yukihiro "Matz" Matsumoto 132c04bcc8 Merge pull request #4443 from shuujii/move-Integral-zero-nonzero-positive-negative-to-Numeric
Move `Integral#(zero|nonzero|positive|negative)?` to `Numeric`
2019-05-17 21:30:39 +09:00
Yukihiro "Matz" Matsumoto 4572d42d07 Merge pull request #4444 from bshastry/mruby-proto
proto fuzzer: Add source files necessary to compile proto fuzzer
2019-05-17 21:30:20 +09:00
Bhargava Shastry 1f3ece9631 proto fuzzer: Add source files necessary to compile proto fuzzer 2019-05-17 14:28:20 +02:00
Yukihiro "Matz" Matsumoto eecac4f18b Merge pull request #4442 from shuujii/drop-dependency-from-mruby-rational-to-mruby-numeric-ext
Drop dependency from `mruby-rational` to `mruby-numeric-ext`
2019-05-17 21:27:47 +09:00
Yukihiro "Matz" Matsumoto 6558d51b50 Merge pull request #4441 from shuujii/fix-Numeric-to_r
Fix `Numeric#to_r`
2019-05-17 21:26:48 +09:00
Bhargava Shastry 647569bfe8 Add/Edit ossfuzz config options 2019-05-17 14:26:41 +02:00
Yukihiro "Matz" Matsumoto ed0a5f9e16 Merge pull request #4440 from kou/cc-with-option
Add support for CC="gcc --option ..." again
2019-05-17 21:26:00 +09:00
KOBAYASHI Shuji c5c39f585b Move Integral#(zero|nonzero|positive|negative)? to Numeric
Because these methods work if object is `Comparable`, and `Numeric` is
`Comparable`.
2019-05-17 21:13:31 +09:00
KOBAYASHI Shuji aa41a5c9af Drop dependency from mruby-rational to mruby-numeric-ext 2019-05-17 20:44:48 +09:00
KOBAYASHI Shuji eeb95e058a Fix Numeric#to_r 2019-05-17 19:53:31 +09:00
Kouhei Sutou d5c8868346 Add support for CC="gcc --option ..." again
If $rake_root_fiber is used, sh runs command in another Fiber. If
command is ran in another Fiber, "rescue RuntimEerror" can't rescue
exception for system(...) failure.

How to reproduce:

    $ CC="gcc -std=gnu99" ./minirake
    (in /home/kou/work/ruby/mruby.kou)
    CC    mrbgems/mruby-compiler/core/codegen.c -> build/test/mrbgems/mruby-compiler/core/codegen.o
    sh: 1: gcc -std=gnu99: not found
    rake aborted!
    Command Failed: ["gcc -std=gnu99" -g -std=gnu99 ...]
2019-05-17 17:59:24 +09:00
Yukihiro "Matz" Matsumoto b6e9fab649 Implement part of Rational in C. 2019-05-17 16:37:34 +09:00
Yukihiro "Matz" Matsumoto cec92673ae Avoid direct access to instance variables in rational.rb. 2019-05-17 16:22:23 +09:00
Yukihiro "Matz" Matsumoto 912d23634d Fixed wrong overloading.
`float op rational` should return `float`, since float is an inexact
value.
2019-05-17 16:18:46 +09:00
Yukihiro "Matz" Matsumoto 237a57bbe8 Make unused functions private.
* mrb_fixnum_plus()
* mrb_fixnum_minus()
* mrb_fixnum_mul()
2019-05-17 11:30:38 +09:00
Yukihiro "Matz" Matsumoto 0d61bcd823 Use div (integer divition) instead of / for rational numbers. 2019-05-17 11:27:52 +09:00
Yukihiro "Matz" Matsumoto 0c91da257b Remove unused mrb_num_div() function. 2019-05-17 11:27:21 +09:00
Yukihiro "Matz" Matsumoto 223defd62a Move Numeric#div to the core. 2019-05-17 11:26:16 +09:00
Yukihiro "Matz" Matsumoto 3734c53eb8 Make flo_rount to return Integeral. 2019-05-17 11:13:12 +09:00
Yukihiro "Matz" Matsumoto bc18060149 Change the num.divmod(float) to return [int,num]. 2019-05-17 10:58:17 +09:00
Yukihiro "Matz" Matsumoto 8a9f984eb8 Add a new function mrb_int_value.
This function returns `Fixnum` if the value fits in `mrb_int`,
otherwise it returns `Float` value (mruby behavior of handling integers).
2019-05-17 10:42:16 +09:00
Yukihiro "Matz" Matsumoto 80c789b394 Use int64_t instead of mrb_int in int64_value. 2019-05-17 10:40:19 +09:00
Yukihiro "Matz" Matsumoto 283530b19b Use mrb_float instead of double in FIXABLE_FLOAT. 2019-05-17 10:37:49 +09:00
Yukihiro "Matz" Matsumoto 4bc48d0b76 Refactor time.c regarding memory allocation. 2019-05-16 22:49:27 +09:00
Yukihiro "Matz" Matsumoto 83071843da Merge pull request #4439 from shuujii/fix-Rational-eq
Fix `Rational#==`
2019-05-16 22:49:15 +09:00
KOBAYASHI Shuji f5fb1307b0 Fix Rational#== 2019-05-16 22:09:56 +09:00
Yukihiro "Matz" Matsumoto 9b604abc83 Enable YYSTACK_USE_ALLOCA.
It used heap allocated memory for the parser stack, but there's
possibility of parser termination by exceptions. In that case, the
parser stack memory is leaked.

We were afraid of stack consumption, but parser stack size is only 4KB,
so we don't have to worry about it (at least for the parser).
2019-05-16 11:46:37 +09:00
Yukihiro "Matz" Matsumoto 304b52fabe Set maximum string (and symbol) size to 65534 (UINT16_MAX-1).
The previous value (`UINT16_MAX`) was too long for symbols, so it raises
an exception after the length check.
2019-05-16 11:44:51 +09:00
Yukihiro "Matz" Matsumoto 7aff5507dd Avoid potential type mismatch warnings in pack.c. 2019-05-16 10:15:11 +09:00
Yukihiro "Matz" Matsumoto 2f14254142 Avoid potential integer overflow. 2019-05-16 10:13:52 +09:00
Yukihiro "Matz" Matsumoto 752edf413f Terminate float right shift if shift value is too big. 2019-05-16 09:51:27 +09:00
Yukihiro "Matz" Matsumoto 6af0effda1 Merge pull request #4435 from shuujii/fix-typo-in-mrbgems-mruby-io-src-file_test.c
Fix typo in `mrbgems/mruby-io/src/file_test.c` [ci skip]
2019-05-15 17:00:46 +09:00
Yukihiro "Matz" Matsumoto 936f72fdd2 Do not overwrite conf.cc.defines. 2019-05-15 16:58:35 +09:00
Ukrainskiy Sergey 31bfc55866 Fix 2019-05-15 16:57:21 +09:00
Ukrainskiy Sergey fa45cc4272 Fix dependencies 2019-05-15 16:57:21 +09:00
Ukrainskiy Sergey d67d2ae8e8 Basic implementation of Complex and Rational classes 2019-05-15 16:57:21 +09:00
Ukrainskiy Sergey 79c3335e8d Small refactoring 2019-05-15 16:57:21 +09:00
Ukrainskiy Sergey 8808219e6d Initial suffix support 2019-05-15 16:57:21 +09:00
KOBAYASHI Shuji 5f664fb6f8 Fix typo in mrbgems/mruby-io/src/file_test.c [ci skip] 2019-05-15 16:27:08 +09:00
Yukihiro "Matz" Matsumoto 7f1f499b22 Merge pull request #4400 from shuujii/fix-name-assignment-to-frozen-anonymous-class-module
Fix name assignment to frozen anonymous class/module
2019-05-15 15:47:02 +09:00
Yukihiro "Matz" Matsumoto 780342eddb Add Enumerator support to String#each_byte.
`String#each_byte` is not defined in ISO Ruby but it is implemented in
the core mruby because it's useful.
2019-05-15 14:59:48 +09:00
Yukihiro "Matz" Matsumoto 138845a519 Merge pull request #4434 from shuujii/refine-Time-to_s-inspect
Refine `Time#(to_s|inspect)`
2019-05-15 14:22:47 +09:00
Yukihiro "Matz" Matsumoto fd37bc53de Remove String#=~ and String#match that requires Regexp. 2019-05-15 09:55:21 +09:00
KOBAYASHI Shuji edf4b33c61 Refine Time#(to_s|inspect)
For the following reasons:

- Ruby compatibility.
- Add UTC offset (time zone informations was not included by #4433).
- More readable.

Example:

  Before this patch:

    p Time.gm(2003,4,5,6,7,8,9)        #=> Sat Apr  5 06:07:08 2003
    p Time.local(2013,10,28,16,27,48)  #=> Mon Oct 28 16:27:48 2013

  After this patch:

    p Time.gm(2003,4,5,6,7,8,9)        #=> 2003-04-05 06:07:08 UTC
    p Time.local(2013,10,28,16,27,48)  #=> 2013-10-28 16:27:48 +0900

Implementation:

I use `strftime(3)` because UTC offset can be added and program size become
smaller than the other implementations (using `sprintf(3)`, self conversion
etc) in my environment.
2019-05-14 22:50:36 +09:00
Yukihiro "Matz" Matsumoto d8eff635fd Merge pull request #4433 from shuujii/fix-Time-asctime-ctime-according-to-ISO-Ruby
Fix `Time#(asctime|ctime)` according to ISO Ruby
2019-05-14 18:36:55 +09:00
KOBAYASHI Shuji a2616db4dc Fix Time#(asctime|ctime) according to ISO Ruby
- A leading charactor for day is space.
- Time zone does not included.

Before this patch:

  Time.gm(1982,3,4,5,6,7).asctime  #=> "Thu Mar 04 05:06:07 UTC 1982"

After this patch:

  Time.gm(1982,3,4,5,6,7).asctime  #=> "Thu Mar  4 05:06:07 1982"
2019-05-13 19:46:26 +09:00
Yukihiro "Matz" Matsumoto b145ed9de5 Merge pull request #4432 from shuujii/fix-missing-assertions-in-mruby-time-test
Fix missing assertions in `mruby-time` test
2019-05-13 08:33:55 +09:00
KOBAYASHI Shuji 2c2584138a Fix missing assertions in mruby-time test 2019-05-12 20:25:11 +09:00
Yukihiro "Matz" Matsumoto e28ebed661 Merge pull request #4431 from shuujii/use-mrb_ensure_string_type-in-mrb_to_str
Use `mrb_ensure_string_type` in `mrb_to_str`
2019-05-12 14:33:10 +09:00
KOBAYASHI Shuji fa317fabbd Use mrb_ensure_string_type in mrb_to_str 2019-05-11 18:40:33 +09:00
Yukihiro "Matz" Matsumoto 4cce39cab7 Merge pull request #4430 from bshastry/ossfuzz
Update ossfuzz options
2019-05-11 09:26:19 +09:00
Yukihiro "Matz" Matsumoto 4601ac7f13 Merge pull request #4429 from shuujii/move-mrb_gc_arena_restore-into-loop-in-mrb_file_s_chmod
Move `mrb_gc_arena_restore` to inside the loop in `mrb_file_s_chmod`
2019-05-11 09:24:35 +09:00
Bhargava Shastry 1e2983bd04 Update ossfuzz options 2019-05-10 16:13:05 +02:00
KOBAYASHI Shuji f2719e903a Move mrb_gc_arena_restore to inside the loop in mrb_file_s_chmod 2019-05-10 21:10:44 +09:00
Yukihiro "Matz" Matsumoto 2e99f34fe3 Merge pull request #4428 from shuujii/raise-TypeError-if-the-argument-type-is-unsupported-in-mrb_stat0
Raise `TypeError` if the argument type is unsupported in `mrb_stat0`
2019-05-10 12:25:10 +09:00
KOBAYASHI Shuji 0d94a2e3a9 Raise TypeError if the argument type is unsupported in mrb_stat0 2019-05-10 00:31:30 +09:00
Yukihiro "Matz" Matsumoto 9a4f3029d9 Update README.md; mruby is now Ruby 2.x compatible. 2019-05-08 21:32:25 +09:00
Yukihiro "Matz" Matsumoto ecc6eb81b5 Merge pull request #4426 from shuujii/use-mrb_string_value_cstr-in-mrb_str_to_dbl
Use `mrb_string_value_cstr` in `mrb_str_to_dbl`
2019-05-08 21:32:11 +09:00
KOBAYASHI Shuji 1975dedb21 Use mrb_string_value_cstr in mrb_str_to_dbl 2019-05-08 20:35:03 +09:00
Yukihiro "Matz" Matsumoto f405d35dac Merge pull request #4425 from shuujii/refactor-mrb_str_to_cstr-and-mrb_string_value_cstr
Refactor `mrb_str_to_cstr` and `mrb_string_value_cstr`
2019-05-08 06:23:50 +09:00
KOBAYASHI Shuji 35943e7beb Refactor mrb_str_to_cstr and mrb_string_value_cstr
- Extract null byte check to function.
- Avoid string allocation if null byte is included.
- Use `str_new` instead of `mrb_str_dup` + `mrb_str_modify`
2019-05-07 23:01:13 +09:00
Yukihiro "Matz" Matsumoto c778c234b0 Merge pull request #4424 from shuujii/avoid-using-mrb_str_to_cstr-if-possible
Avoid using `mrb_str_to_cstr` if possible
2019-05-07 06:21:10 +09:00
KOBAYASHI Shuji e2604c1550 Avoid using mrb_str_to_cstr if possible
Because it always allocate new string. Replace with the followings:

- Use `RSRING_PTR` if string is guaranteed to be null-terminated.
- Use `mrb_string_value_cstr` or `mrb_get_args("z")` if return value isn't
  modified.
2019-05-06 23:32:53 +09:00
Yukihiro "Matz" Matsumoto 31cc8573f0 Merge pull request #4423 from shuujii/use-mrb_fixnum_to_str-instead-of-Fixnum-to_s
Use `mrb_fixnum_to_str()` instead of `Fixnum#to_s`
2019-05-05 21:57:35 +09:00
KOBAYASHI Shuji 0ccb058b90 Use mrb_fixnum_to_str() instead of Fixnum#to_s 2019-05-05 20:31:12 +09:00
Yukihiro "Matz" Matsumoto 2b1c4e9acd Merge pull request #4179 from bshastry/ossfuzz
ossfuzz: Add simple mruby compile test harness
2019-05-04 18:32:40 +09:00
Yukihiro "Matz" Matsumoto 82b04f927e Merge pull request #4422 from shuujii/check-whether-object-is-immediate-in-mrb_gc_register-unregister
Check whether object is immediate in `mrb_gc_(register|unregister)`
2019-05-04 18:28:06 +09:00
KOBAYASHI Shuji a5bda13fb7 Check whether object is immediate in mrb_gc_(register|unregister) 2019-05-04 16:38:07 +09:00
Yukihiro "Matz" Matsumoto 181d14668a Merge pull request #4420 from shuujii/simplify-conversion-process-for-i-in-mrb_get_args
Simplify conversion process for `i` in `mrb_get_args()`
2019-05-04 00:19:14 +09:00
Yukihiro "Matz" Matsumoto 187b4c819f Merge pull request #4419 from dearblue/fix-always-static
Fix `FLAG_SRC_STATIC` always set in `mrb_read_irep()` with `MRB_USE_CUSTOM_RO_DATA_P`
2019-05-04 00:17:10 +09:00
Yukihiro "Matz" Matsumoto a277a6e47d Merge pull request #4418 from dearblue/clean-duplicate
Clean duplicate code
2019-05-04 00:15:56 +09:00
KOBAYASHI Shuji 0692f7916c Simplify conversion process for i in mrb_get_args() 2019-05-03 13:39:19 +09:00
dearblue e86e360b36 Fix FLAG_SRC_STATIC always set in mrb_read_irep() with MRB_USE_CUSTOM_RO_DATA_P 2019-05-03 11:42:14 +09:00
dearblue f5d5caaf82 Clean duplicate code
Removed duplicates in the code entered for "Concatenate string literal".
2019-05-03 11:36:31 +09:00
Yukihiro "Matz" Matsumoto 8c8e6e25ad Merge pull request #4417 from shuujii/unify-overflow-error-class-for-conversion-to-integer-to-RangeError
Unify overflow error class for conversion to integer to `RangeError`
2019-05-02 23:05:13 +09:00
Yukihiro "Matz" Matsumoto 35319bed01 Use a normal method instead of a lambda in bintest/mruby; ref #4416 2019-05-02 23:03:38 +09:00
Yukihiro "Matz" Matsumoto f83112cea2 Fixed include specifier format for mruby/common.h. 2019-05-02 22:55:19 +09:00
Yukihiro "Matz" Matsumoto 335602e85c Merge pull request #4416 from shuujii/small-fix-in-mruby-bin-mruby
Small fix in `mruby-bin-mruby`
2019-05-02 22:52:38 +09:00
Yukihiro "Matz" Matsumoto a7871ce77e Merge pull request #4415 from shuujii/remove-unneeded-argc-check-in-mrb_str_aref_m
Remove unneeded `argc` check in `mrb_str_aref_m()`
2019-05-02 22:31:58 +09:00
KOBAYASHI Shuji 95a92d35c8 Unify overflow error class for conversion to integer to RangeError 2019-05-02 20:45:31 +09:00
KOBAYASHI Shuji 2a94bf8fbd Small fix in mruby-bin-mruby
- Modify some error messages for consistency.
- Add test for codegen error.
- Use regular expression for error message matching in test.
2019-05-01 16:49:56 +09:00
KOBAYASHI Shuji 1a8f6e70b5 Remove unneeded argc check in mrb_str_aref_m() 2019-05-01 15:04:08 +09:00
Yukihiro "Matz" Matsumoto eeb78a7259 Merge pull request #4414 from shuujii/refine-error-message-output-for-mruby-command
Refine error message output for `mruby` command
2019-04-30 19:37:00 +09:00
KOBAYASHI Shuji 9bd17226d5 Refine error message output for mruby command
- Write message to stderr instead of stdout.
- Avoid duplicate message output (`SyntaxError`, `ScriptError` etc).
- Refine invalid option message.
- Suppress redundant usage output.
- Fix some incorrect exit code.
2019-04-30 16:58:01 +09:00
Yukihiro "Matz" Matsumoto 0615970877 Merge pull request #4413 from shuujii/fix-missing-assertions-in-mruby-io-test
Fix missing assertions in `mruby-io` test
2019-04-29 11:54:51 +09:00
Yukihiro "Matz" Matsumoto b7ff23d235 Merge pull request #4412 from shuujii/refine-the-default-values-of-flunk
Refine the default values of `flunk`
2019-04-29 11:53:58 +09:00
KOBAYASHI Shuji 4bf6b8c136 Refine the default values of flunk
The default message for the second argument should be set to the first
argument because only one argument is normally specified.
2019-04-29 11:34:41 +09:00
KOBAYASHI Shuji 8cc2ad3348 Fix missing assertions in mruby-io test 2019-04-29 11:09:35 +09:00
Yukihiro "Matz" Matsumoto e4992cdd03 Merge pull request #4411 from shuujii/commented-out-Struct.new-removes-existing-constant-test
Commented out "Struct.new removes existing constant" test
2019-04-28 23:44:37 +09:00
KOBAYASHI Shuji 5969ed1afb Commented out "Struct.new removes existing constant" test
Because this test is always skipped.
2019-04-28 18:42:23 +09:00
Yukihiro "Matz" Matsumoto b15293e709 Merge pull request #4410 from dearblue/update-docs
Update document for `MRB_USE_CUSTOM_RO_DATA_P` and some configurations
2019-04-27 23:18:18 +09:00
dearblue 828a998941 Update document for MRB_USE_CUSTOM_RO_DATA_P 2019-04-27 22:29:20 +09:00
dearblue b57f61ac95 Update document for any configurations
- (Modify) `MRB_INT16`
- (Add)    `MRB_INT32`
- (Modify) `MRB_INT64`
- (Add)    `MRB_USE_ETEXT_EDATA`
- (Add)    `MRB_NO_INIT_ARRAY_START
- (Add)    `MRB_WITHOUT_FLOAT`
- (Add)    `MRB_METHOD_CACHE`
- (Add)    `MRB_METHOD_CACHE_SIZE`
- (Add)    `MRB_METHOD_TABLE_INLINE
- (Add)    `MRB_ENABLE_ALL_SYMBOLS`
2019-04-27 22:28:54 +09:00
Yukihiro "Matz" Matsumoto 6f779ceac2 Merge pull request #4409 from shuujii/remove-duplicated-String-each_char
Remove duplicated `String#each_char`
2019-04-27 14:02:38 +09:00
KOBAYASHI Shuji 270131253f Remove duplicated String#each_char 2019-04-27 12:50:02 +09:00
Yukihiro "Matz" Matsumoto 2b0135e869 Merge pull request #4408 from dearblue/my-ro_data_p
Add customized `mrb_ro_data_p()`
2019-04-26 23:36:50 +09:00
KOBAYASHI Shuji 1fb635ac03 Add assert_raise_with_message and assert_raise_with_message_pattern 2019-04-26 21:48:40 +09:00
dearblue 302ad847a3 Add customized mrb_ro_data_p()
User definable `mrb_ro_data_p()` functions are available
by defining `MRB_USE_CUSTOM_RO_DATA_P`.

(Limitation) It can not be defined as an inline function.
2019-04-26 21:28:57 +09:00
Yukihiro "Matz" Matsumoto c078758644 Merge pull request #4405 from shuujii/singleton-class-of-frozen-object-should-be-frozen
Singleton class of frozen object should be frozen
2019-04-26 01:14:11 +09:00
KOBAYASHI Shuji 8fa3995a1a Singleton class of frozen object should be frozen
Before this patch:

  p (class << Object.new.freeze; self end).frozen?                #=> false
  sc = class << (o=Object.new); self end; o.freeze; p sc.frozen?  #=> false

After this patch / Ruby:

  p (class << Object.new.freeze; self end).frozen?                #=> true
  sc = class << (o=Object.new); self end; o.freeze; p sc.frozen?  #=> true
2019-04-25 19:48:40 +09:00
Yukihiro "Matz" Matsumoto e5799b5d40 Merge pull request #4402 from shuujii/fix-modiying-class-variable-to-frozen-class
Fix modiying class variable to frozen class/module
2019-04-25 07:17:10 +09:00
dearblue 8f6f36f654 Add mruby binary loader functions from buffer memory
Add new functions (with `MRB_API`):
- `mrb_read_irep_buf()`
- `mrb_load_irep_buf()`
- `mrb_load_irep_buf_cxt()`
2019-04-24 22:56:39 +09:00
dearblue 58d525c9fa Check mruby binary size 2019-04-24 22:56:39 +09:00
dearblue 4d85019e4c Check mruby binary version 2019-04-24 22:56:38 +09:00
KOBAYASHI Shuji 4720648137 Fix modiying class variable to frozen class/module 2019-04-24 21:05:44 +09:00
Yukihiro "Matz" Matsumoto 163a6d01e0 Reorganize defines related to MRB_INLINE; ref #4391 2019-04-24 12:09:16 +09:00
Yukihiro "Matz" Matsumoto 0c5f26e0ff Remove unnecessary mrb_regexp_check() and related functions. 2019-04-24 11:43:05 +09:00
Yukihiro "Matz" Matsumoto 9ca9af60f2 Merge pull request #4401 from shuujii/fix-ambiguous-first-argument-warning-in-test-t-float.rb
Fix "ambiguous first argument" warning in `test/t/float.rb`
2019-04-24 00:30:30 +09:00
KOBAYASHI Shuji 9f4147f28e Fix "ambiguous first argument" warning in test/t/float.rb 2019-04-23 21:02:42 +09:00
KOBAYASHI Shuji cc7f9190ba Fix name assignment to frozen anonymous class/module
Fix the following issues:

  A = Class.new.freeze              #=> FrozenError
  Module.new::B = Class.new.freeze  #=> FrozenError
  String::B = Module.new.freeze     #=> FrozenError
2019-04-23 20:45:38 +09:00
Yukihiro "Matz" Matsumoto e9f3902ab5 Fixed the condition in mrb_funcall_with_block; fix #4389 2019-04-23 15:30:10 +09:00
Yukihiro "Matz" Matsumoto 7cf1bc39a7 Merge pull request #4356 from shuujii/add-assert_match-and-assert_not_match
Add `assert_match` and `assert_not_match`
2019-04-22 22:29:15 +09:00
Yukihiro "Matz" Matsumoto 5ab8ca41a5 Merge branch 'shuujii-add-assert_predicate-and-assert_operator' 2019-04-22 22:26:46 +09:00
KOBAYASHI Shuji 0debf154ee Add assert_predicate and assert_operator 2019-04-22 22:26:11 +09:00
Yukihiro "Matz" Matsumoto 49cb149033 Merge pull request #4391 from dearblue/inlines
Change modifier to `MRB_INLINE` from `static inline`
2019-04-22 21:17:27 +09:00
Yukihiro "Matz" Matsumoto 9985d0aaca Merge pull request #4399 from shuujii/use-MRB_ASPEC_XXX-macro-in-codedump
Use `MRB_ASPEC_XXX()` macro in `codedump()`
2019-04-22 21:15:02 +09:00
KOBAYASHI Shuji 0e6a93a9ca Use MRB_ASPEC_XXX() macro in codedump() 2019-04-22 19:09:29 +09:00
Yukihiro "Matz" Matsumoto 0e704d195f Merge pull request #4396 from shuujii/commented-out-String-scan
Commented out `String#scan` because it is not implemented yet
2019-04-22 08:57:55 +09:00
Yukihiro "Matz" Matsumoto a025cd2268 Merge pull request #4395 from shuujii/expand-BOXWORD_SET_VALUE-macro-in-include-mruby-boxing_word.h
Expand `BOXWORD_SET_VALUE()` macro in `include/mruby/boxing_word.h`
2019-04-22 08:56:47 +09:00
KOBAYASHI Shuji cdb458ed4e Commented out String#scan because it is not implemented yet 2019-04-21 20:34:39 +09:00
KOBAYASHI Shuji b212050026 Expand BOXWORD_SET_VALUE() macro in include/mruby/boxing_word.h
In `SET_OBJ_VALUE()`, branch isn't removed because `switch` condition isn't
constant expression.
2019-04-20 21:23:58 +09:00
Yukihiro "Matz" Matsumoto 88c3595db3 Merge pull request #4393 from robfors/twiddle_wakka
Fixes the twiddle wakka comparison algorithm
2019-04-20 07:31:11 +09:00
Yukihiro "Matz" Matsumoto ff765c814d Merge pull request #4390 from shuujii/add-type-check-in-String-aset
Add type check (conversion) in `String#[]=`
2019-04-20 07:30:12 +09:00
Rob 73bb144ef0 Fixes the twiddle wakka comparison algorithm to support passing only a major number 2019-04-19 17:18:30 -04:00
Yukihiro "Matz" Matsumoto 2f9ebc6f32 Merge pull request #4392 from dearblue/true-false-p
Add `mrb_true_p()` and `mrb_false_p()` macro functions
2019-04-20 04:09:34 +09:00
dearblue 125c3bef19 Add mrb_true_p() and mrb_false_p() macro functions 2019-04-19 22:50:05 +09:00
dearblue 6907e97fa1 Change modifier to MRB_INLINE from static inline 2019-04-19 22:24:22 +09:00
KOBAYASHI Shuji 4a8b88f775 Add type check (conversion) in String#[]=
Before this patch:

  'a'[0] = 1        #=> 1
  'a'[:a] = '1'     #=> ArgumentError
  'a'[:a, 0] = '1'  #=> ArgumentError
  'a'[0, :a] = '1'  #=> ArgumentError
  'a'[0, 1] = 1     #=> 1

After this patch / Ruby:

  'a'[0] = 1        #=> TypeError
  'a'[:a] = '1'     #=> TypeError
  'a'[:a, 0] = '1'  #=> TypeError
  'a'[0, :a] = '1'  #=> TypeError
  'a'[0, 1] = 1     #=> TypeError
2019-04-19 20:14:23 +09:00
Yukihiro "Matz" Matsumoto 05f65d2d42 Merge pull request #4388 from shuujii/remove-duplicated-include-Comparable-in-mrblib-string.rb
Remove duplicated `include Comparable` in `mrblib/string.rb`
2019-04-19 10:44:14 +09:00
KOBAYASHI Shuji 916045921e Remove duplicated include Comparable in mrblib/string.rb 2019-04-18 19:58:05 +09:00
Yukihiro "Matz" Matsumoto 2f6baf60e9 Merge pull request #4387 from shuujii/add-Array-sample-test
Add `Array#sample` test
2019-04-18 08:10:45 +09:00
KOBAYASHI Shuji 2ae727ac3a Add Array#sample test
And simplify tests for `Array#shuffle` and `Array#shuffle!`.
2019-04-17 21:04:46 +09:00
Yukihiro "Matz" Matsumoto 8ee516436b Merge pull request #4386 from tomas/stable
Fix compilation on gcc 4.9.x
2019-04-17 08:03:15 +09:00
Tomás Pollak ef3b539125 Prevent 'mixed declarations and code' C90 warning 2019-04-16 18:02:30 -04:00
Tomas Pollak bcb8e297fc Fix compilation on gcc 4.9.x 2019-04-16 12:34:09 -04:00
Yukihiro "Matz" Matsumoto 77c42988c8 Merge pull request #4385 from shuujii/avoid-potential-zero-size-array-declaration
Avoid potential zero size array declaration; fix #4382
2019-04-16 21:53:28 +09:00
KOBAYASHI Shuji 79a7f18150 Avoid potential zero size array declaration; fix #4382 2019-04-16 19:56:11 +09:00
Yukihiro "Matz" Matsumoto 4e45e320b0 Fixed a bug in recursive mrb_top_run calls; fix #4384 2019-04-16 18:47:46 +09:00
Yukihiro "Matz" Matsumoto 3760f58d53 Merge pull request #4383 from Shokuji/fix_mruby-io_test
Fix test in mruby-io
2019-04-16 17:34:50 +09:00
Shokuji cdfeb53887 Merge branch 'master' into fix_mruby-io_test 2019-04-16 09:47:32 +09:00
Yukihiro "Matz" Matsumoto 4e3e4260c3 Merge pull request #4381 from shuujii/fix-missing-assertions-in-mruby-random-test
Fix missing assertions in `mruby-random` test
2019-04-16 08:39:08 +09:00
KOBAYASHI Shuji d53eb8a377 Fix missing assertions in mruby-random test 2019-04-15 19:03:39 +09:00
Shouji Kuboyama 164985881b Fix test, popen and cmd in mruby-io 2019-04-15 17:16:08 +09:00
Yukihiro "Matz" Matsumoto 6b8d3c7070 Fixed wrong function names; fix #4380 2019-04-15 07:15:38 +09:00
Yukihiro "Matz" Matsumoto 7a62efae63 Merge pull request #4379 from shuujii/extract-similar-codes-to-macros-for-math-opcode-in-mrb_vm_exec
Extract similar codes to macros for math opcode in `mrb_vm_exec()`
2019-04-15 07:08:27 +09:00
KOBAYASHI Shuji 30c880bea9 Extract similar codes to macros for math opcode in mrb_vm_exec 2019-04-14 22:40:17 +09:00
Yukihiro "Matz" Matsumoto ea6aab20e8 Merge pull request #4378 from dearblue/memleak-hashtable
Fix memory leak for hash table index if occur out of memory
2019-04-14 20:36:29 +09:00
Yukihiro "Matz" Matsumoto 6ad89d30d2 Merge pull request #4377 from dearblue/wrong-iv-size
Fix wrong size of instance variable if occur out of memory
2019-04-14 20:36:05 +09:00
Yukihiro "Matz" Matsumoto e74a8a7360 Merge pull request #4376 from dearblue/leak-symbols
Fix leaked function symbols
2019-04-14 20:35:19 +09:00
Yukihiro "Matz" Matsumoto 4a1d29cbb8 Merge pull request #4375 from dearblue/forgotten-structs
Include `RFiber` and `RIstruct` as a part of `RVALUE`
2019-04-14 20:34:45 +09:00
Yukihiro "Matz" Matsumoto ec41262e22 Merge pull request #4374 from dearblue/hexdump
Fix hexdigits convertion
2019-04-14 20:34:14 +09:00
KOBAYASHI Shuji 716a99b069 Add assert_match and assert_not_match 2019-04-14 19:06:28 +09:00
dearblue d328808892 Fix memory leak for hash table index if occur out of memory 2019-04-14 17:55:20 +09:00
dearblue d8527d17ea Fix wrong size of instance variable if occur out of memory 2019-04-14 17:42:35 +09:00
dearblue d557f97732 Remove pointer check after mrb_malloc() 2019-04-14 17:39:50 +09:00
dearblue 3f3e4754d9 Fix leaked function symbols
- `free_heap()` in src/gc.c
- `symhash()` in src/symbol.c
- `no_optimize()` in mrbgems/mruby-compiler/core/codegen.c
2019-04-14 17:23:16 +09:00
dearblue dac0f3f5e8 Fix string index for appending
`sizeof(string-literal)` is included `'\0'` character
2019-04-14 16:16:05 +09:00
dearblue c2fa935fee Fix hexdigits convertion 2019-04-14 16:11:21 +09:00
dearblue 0ebbc491a1 Include RFiber and RIstruct as a part of RVALUE 2019-04-14 15:35:51 +09:00
Yukihiro "Matz" Matsumoto 4d8ff2fba4 Merge pull request #4373 from shuujii/fix-broken-NaN-with-MRB_NAN_BOXING
Fix broken NaN with `MRB_NAN_BOXING`
2019-04-14 12:25:54 +09:00
KOBAYASHI Shuji f639da0f1c Fix broken NaN with MRB_NAN_BOXING
Example:

  $ bin/mruby -e '(Float::INFINITY - Float::INFINITY).nan?'
  zsh: segmentation fault

Cause:

  `SET_FLOAT_VALUE` is not used. It is needed for normalizing NaN.

Treatment:

  In my environment, this issue could be reproduced only when
  `infinity - infinity`, however `SET_FLOAT_VALUE` should be used in all
  arithmetic operations (regardless of boxing setting), I think.

  So I fixed all similar codes by extracting to macro.
2019-04-13 19:27:17 +09:00
Yukihiro "Matz" Matsumoto 79fd986bcb Small refactoring in mrb_funcall_with_block. 2019-04-12 23:04:10 +09:00
Yukihiro "Matz" Matsumoto 7f1984a01e Merge pull request #4372 from shuujii/refine-assert_float
Refine `assert_float`
2019-04-12 22:58:57 +09:00
Yukihiro "Matz" Matsumoto befdf59e61 Deallocate s->lines in codegen_error; ref #4370 2019-04-12 22:54:25 +09:00
Yukihiro "Matz" Matsumoto 00545fc51d The number of local variables should be less than 1024; fix #4370
The `env` stores stack length in a 10 bit field.
See `MRB_ENV_STACK_LEN()` macro.
2019-04-12 22:52:26 +09:00
KOBAYASHI Shuji 6626fbc500 Refine assert_float
Avoid arithmetic operations when `exp` and/or `act` are infinity or NaN.
2019-04-12 22:27:07 +09:00
Yukihiro "Matz" Matsumoto 6da10f643a Merge pull request #4369 from shuujii/remove-incorrect-flags-updating-in-mrb_regexp_p
Remove incorrect flags updating in `mrb_regexp_p()`
2019-04-12 21:01:49 +09:00
Yukihiro "Matz" Matsumoto 9b9c41d699 Merge pull request #4371 from clayton-shopify/fix-buffer-overflows
Fix buffer overflows in parser.
2019-04-12 19:56:35 +09:00
Clayton Smith 57e617620a Fix buffer overflows in parser. 2019-04-11 20:07:43 -04:00
KOBAYASHI Shuji 0c9c3f08ee Remove incorrect flags updating in mrb_regexp_p() 2019-04-11 21:42:18 +09:00
Yukihiro "Matz" Matsumoto 9c252410cf Merge pull request #4368 from shuujii/use-mrb_immediate_p-in-mrb_obj_freeze-and-mrb_obj_frozen
Use `mrb_immediate_p()` in `mrb_obj_freeze()` and `mrb_obj_frozen()`
2019-04-10 19:34:58 +09:00
KOBAYASHI Shuji 7b0ebed033 Use mrb_immediate_p() in mrb_obj_freeze() and mrb_obj_frozen() 2019-04-10 19:19:53 +09:00
Yukihiro "Matz" Matsumoto 4776ac50ed Remove too aggressive initialize call in mrb_instance_new. 2019-04-10 19:11:35 +09:00
Yukihiro "Matz" Matsumoto 88ac7549c0 Remove MRB_API from mrb_instance_new. 2019-04-10 19:11:35 +09:00
Yukihiro "Matz" Matsumoto d0b30f4ce2 Merge pull request #4367 from shuujii/extract-frozen-checking-to-function
Extract frozen checking to function
2019-04-10 06:03:32 +09:00
Yukihiro "Matz" Matsumoto b433001a1b Merge pull request #4366 from shuujii/remove-unneeded-function-prototypes
Remove unneeded function prototypes
2019-04-10 06:02:16 +09:00
Yukihiro "Matz" Matsumoto b351bdb8d5 Fixed old style declaration; ref #4365 2019-04-10 06:00:38 +09:00
Yukihiro "Matz" Matsumoto d529501cbf Rename itoa to dump_int to avoid name crash; ref #4173 2019-04-10 05:55:40 +09:00
Yukihiro "Matz" Matsumoto 16f86f8ede Use the old style declaration; ref #4365 2019-04-10 05:42:36 +09:00
KOBAYASHI Shuji e3beef065c Extract frozen checking to function 2019-04-09 18:23:11 +09:00
KOBAYASHI Shuji f89fe04d54 Remove unneeded function prototypes 2019-04-08 22:34:49 +09:00
Yukihiro "Matz" Matsumoto 292bffb32e Avoid infinite loop when no Regexp class is available; fix #4363 2019-04-08 20:27:28 +09:00
Yukihiro "Matz" Matsumoto ec1688807e Avoid using snprintf when MRB_DISABLE_STDIO is set; fix #4173 2019-04-08 19:06:36 +09:00
Yukihiro "Matz" Matsumoto 6cec0c9f62 Fix C99 style inline declaration; fix #4365 2019-04-08 19:06:36 +09:00
Yukihiro "Matz" Matsumoto 2595d5f6c8 Merge pull request #4364 from shuujii/fix-test-for-Array-slice
Fix test for `Array#slice`
2019-04-07 22:12:33 +09:00
KOBAYASHI Shuji f65b35dc9f Fix test for Array#slice 2019-04-07 21:31:12 +09:00
Yukihiro "Matz" Matsumoto 6865826aff Merge pull request #4362 from shuujii/move-Array-append-prepend-from-core-to-mruby-ary-ext
Move `Array#(append|prepend)` from core to `mruby-ary-ext`
2019-04-06 22:25:55 +09:00
Yukihiro "Matz" Matsumoto 64c2ea3f02 Merge pull request #4361 from shuujii/remove-unused-mrb_proc_cfunc_p
Remove unused `mrb_proc_cfunc_p()`
2019-04-06 22:22:38 +09:00
KOBAYASHI Shuji 5adef8ba44 Move Array#(append|prepend) from core to mruby-ary-ext
They are not included in ISO standard.
2019-04-06 17:40:51 +09:00
KOBAYASHI Shuji 271a91c648 Remove unused mrb_proc_cfunc_p() 2019-04-06 16:32:27 +09:00
Yukihiro "Matz" Matsumoto 293a7b2a6e Merge pull request #4360 from shuujii/use-Module-alias_method-should-return-self-in-ISO-standard
`Module#alias_method` should return `self` in ISO standard
2019-04-05 22:17:34 +09:00
KOBAYASHI Shuji 623e15936a Module#alias_method should return self in ISO standard 2019-04-05 19:03:46 +09:00
Yukihiro "Matz" Matsumoto f882b6908e Merge pull request #4357 from mruby/stable
Update version and release date. `mruby 2.0.1 (2019-4-4)`
2019-04-05 17:06:21 +09:00
Yukihiro "Matz" Matsumoto d26f03b446 Merge pull request #4358 from shuujii/use-mrb_proc_arity-instead-of-Proc-arity-call-in-Method-arity
Use `mrb_proc_arity` instead of `Proc#arity` call in `Method#arity`
2019-04-05 13:58:20 +09:00
Yukihiro "Matz" Matsumoto dd1c100b84 Merge pull request #4355 from shuujii/modify-else-and-endif-annotations-in-src-fmt_fp.c
Modify `#else` and `#endif` annotations in `src/fmt_fp.c` [ci skip]
2019-04-05 13:41:26 +09:00
KOBAYASHI Shuji ed41bbb199 Use mrb_proc_arity instead of Proc#arity call in Method#arity 2019-04-04 22:17:26 +09:00
Hiroshi Mimaki 7c91efc1ff Update version and release date.
`mruby 2.0.1 (2019-4-4)`
2019-04-04 09:26:40 +09:00
Yukihiro "Matz" Matsumoto 50a223f21f Merge pull request #4354 from shuujii/remove-unnecessary-_set_output_format-call
Remove unnecessary `_set_output_format` call
2019-04-04 05:10:32 +09:00
KOBAYASHI Shuji 5e0caefa58 Modify #else and #endif annotations in src/fmt_fp.c [ci skip] 2019-04-03 19:25:06 +09:00
KOBAYASHI Shuji abc6c990a6 Remove unnecessary _set_output_format call
Three-digit exponent issue was fixed via another workaround (63b8f5c).
2019-04-03 18:54:25 +09:00
Yukihiro "Matz" Matsumoto 73feef9766 Merge pull request #4353 from shuujii/pad-leading-zero-to-month-and-day-in-MRUBY_RELEASE_DATE
Pad leading zero to month and day in `MRUBY_RELEASE_DATE`
2019-04-02 21:14:21 +09:00
KOBAYASHI Shuji 9b7e9addcd Pad leading zero to month and day in MRUBY_RELEASE_DATE
For Ruby compatibility.
2019-04-02 16:24:07 +09:00
Yukihiro "Matz" Matsumoto c274e1ae5a Merge pull request #4352 from shuujii/fix-modifiable-class-name
Fix modifiable class name
2019-04-02 10:27:21 +09:00
KOBAYASHI Shuji 55cb625808 Fix modifiable class name
Fix the following example:

    Object.const_set :A, Module.new{const_set :B, Class.new}
    ab = A::B.to_s
    p ab         #=> "A::B" # Good
    ab[0] = "x"
    p A::B.to_s  #=> "x::B" # Bad
2019-04-01 20:12:43 +09:00
Yukihiro "Matz" Matsumoto 2871d0cdc5 Avoid keeping pointers from mrb_sym2name_len(); fix #4342
The addresses for packed inline symbols reference `mrb->symbuf` that
could be overridden by the later call of `mrb_sym2name_len`. Since
file names in call stack information are kept as symbols, keeping the
address in the C structures could cause problems like #4342.

This changes small incompatible changes in function prototypes:
* `mrb_parser_get_filename`: return value changed to `mrb_sym`.
* `mrb_debug_get_filename`: add `mrb_state*` as a first argument.
* `mrb_debug_get_line`: ditto.

I believe above functions are almost internal, and no third-party
mrbgem use them.
2019-04-01 14:13:06 +09:00
Yukihiro "Matz" Matsumoto 6ec855a38e Merge pull request #4351 from shuujii/fix-warning-interpreted-as-argument-prefix
Fix warning: '*' interpreted as argument prefix
2019-03-31 17:39:10 +09:00
KOBAYASHI Shuji 9b024dcf7a Fix warning: '*' interpreted as argument prefix 2019-03-31 14:52:18 +09:00
Yukihiro "Matz" Matsumoto 19537b103c Merge pull request #4349 from shuujii/add-pass-and-flunk-to-test-assert.rb
Add `pass` and `flunk` to `test/assert.rb`
2019-03-30 22:07:29 +09:00
KOBAYASHI Shuji 4e9c90ed47 Add pass and flunk to test/assert.rb 2019-03-30 13:19:31 +09:00
Yukihiro "Matz" Matsumoto 3c732cd28c Merge pull request #4348 from shuujii/fix-missing-assertions-in-mruby-math-test
Fix missing assertions in `mruby-math` test
2019-03-29 15:51:20 +09:00
Yukihiro "Matz" Matsumoto 85f816528c Merge pull request #4347 from iij/include-stdarg-in-mruby-h
fixes build on OpenBSD.
2019-03-29 15:49:41 +09:00
Tomoyuki Sahara d8d59f70c1 va_list is defined in stdarg.h.
fixes build on OpenBSD.
2019-03-29 11:55:04 +09:00
KOBAYASHI Shuji d1f937e1f4 Fix missing assertions in mruby-math test 2019-03-29 09:40:13 +09:00
Yukihiro "Matz" Matsumoto 42f240796f Use Mrbtest::FLOAT_TOLERANCE instead of Math::TORELANCE; ref #4345 2019-03-28 23:22:32 +09:00
Yukihiro "Matz" Matsumoto 3b92b642eb Break loop whem sum==0 to avoid zero division; ref #4345 2019-03-28 23:22:32 +09:00
Yukihiro "Matz" Matsumoto a26856f883 Use DBL_EPSILON instead of 1E-12; ref #4345 2019-03-28 23:22:32 +09:00
Yukihiro "Matz" Matsumoto 6023180848 Merge pull request #4346 from shuujii/use-mrb_sym2str-in-implementation-of-symbol-to_s
Use `mrb_sym2str` in implementation of `Symbol#to_s`
2019-03-28 23:22:23 +09:00
KOBAYASHI Shuji da2bc9e678 Use mrb_sym2str in implementation of Symbol#to_s 2019-03-28 19:56:51 +09:00
Yukihiro "Matz" Matsumoto 21b8d20d7e Fixed mistakes in 92dce05
* rename `sym2name` to `sym2name_len`.
* `MRB_API` -> `static`
2019-03-28 07:06:44 +09:00
Yukihiro "Matz" Matsumoto 5fe00c46ba Merge pull request #4344 from shuujii/remove-unused-variable-in-each_backtrace
Remove unused variable in `each_backtrace()`
2019-03-27 20:24:31 +09:00
KOBAYASHI Shuji 58ca4061b5 Remove unused variable in each_backtrace() 2019-03-27 19:27:00 +09:00
Yukihiro "Matz" Matsumoto 92dce053ad Fix another bug related to #4342
For short symbols with alpha numeric characters, `mrb_sym2name_len()`
returns the same buffer `mrb->symbuf`. Some occasion, we forget the fact
that the second call could overwrite the result of first call of the
function.

We have prepared the static function `sym2name()` which specifies the
buffer region for inline packed symbols and use the function in
`mrb_sym_to_s`.
2019-03-27 17:38:06 +09:00
Yukihiro "Matz" Matsumoto b8f00e439d Avoid using 'mrb_str_new_static` if a symbol is packed; fix #4342 2019-03-27 12:53:24 +09:00
Yukihiro "Matz" Matsumoto 5598612336 Merge pull request #4343 from shuujii/fix-dealing-with-infinity-and-NaN-in-assert_float
Fix dealing with infinity and NaN in `test/assert.rb:assert_float`
2019-03-27 06:53:30 +09:00
KOBAYASHI Shuji 0b6696cc28 Fix dealing with infinity and NaN in test/assert.rb:assert_float
`assert_float` is always passed when expected value and/or actual value are
infinity or NaN. This behavior seems unintentional.

Before this patch:

    assert_float(Float::INFINITY, 1.0)  #=> pass
    assert_float(-Float::INFINITY, 1)   #=> pass
    assert_float(1, 1/0)                #=> pass
    assert_float(1, -1/0)               #=> pass
    assert_float(1.0, Float::NAN)       #=> pass
    assert_float(Float::NAN, 1)         #=> pass

After this patch:

    assert_float(Float::INFINITY, 1.0)  #=> fail: Expected 1.0 to be Infinity.
    assert_float(-Float::INFINITY, 1)   #=> fail: Expected 1 to be -Infinity.
    assert_float(1, 1/0)                #=> fail: Expected Infinity to be 1.
    assert_float(1, -1/0)               #=> fail: Expected -Infinity to be 1.
    assert_float(1.0, Float::NAN)       #=> fail: Expected NaN to be 1.0.
    assert_float(Float::NAN, 1)         #=> fail: Expected 1 to be NaN.
2019-03-26 22:12:09 +09:00
Yukihiro "Matz" Matsumoto c2660b8111 Fix missing MRB_API prefix for functions below; clse #4267
Functions to add prototypes to headers:
* mrb_ary_splice()
* mrb_notimplement()
* mrb_vformat()
* mrb_cstr_to_dbl()
* mrb_cstr_to_inum()

Functions to be made `static` (`MRB_API` was not needed):
* mrb_mod_module_function()
* mrb_obj_hash()
* mrb_str_len_to_inum()

Functions to remove `MRB_API` from definitions (referenced from within `libmruby`):
* mrb_mod_cv_defined()
* mrb_mod_cv_get()
* mrb_f_send()
2019-03-26 10:23:52 +09:00
Yukihiro "Matz" Matsumoto a5a6b51126 Use uppercase version of ctype macros e.g. ISSPACE; fix #4338 2019-03-25 22:05:31 +09:00
Yukihiro "Matz" Matsumoto 1e14afa4e4 Merge pull request #4341 from shuujii/remove-implementation-of-Symbol-eqq
Remove implementation of `Symbol#===`
2019-03-25 22:05:18 +09:00
KOBAYASHI Shuji b489ddcbd1 Remove implementation of Symbol#===
For reducing program size.
2019-03-25 21:39:11 +09:00
Yukihiro "Matz" Matsumoto 33a9840e4a Need to check length before packing a symbol; fix #4340 2019-03-25 20:28:21 +09:00
Yukihiro "Matz" Matsumoto f7e05c7d22 Update float test values to avoid precision errors. 2019-03-25 16:54:34 +09:00
Yukihiro "Matz" Matsumoto ce67561511 Avoid infinite binary floating numbers in float. 2019-03-25 16:21:50 +09:00
Yukihiro "Matz" Matsumoto 3e5dd40a5c Merge pull request #4339 from shuujii/fix-arguments-spec-in-src-proc.c
Fix arguments spec in `src/proc.c`
2019-03-24 22:26:37 +09:00
Yukihiro "Matz" Matsumoto e36db51bea Merge pull request #4337 from shuujii/refactor-t_print-for-test
Refactor `t_print` for test
2019-03-24 21:29:00 +09:00
KOBAYASHI Shuji 10a8e0f105 Fix arguments spec in src/proc.c 2019-03-24 20:55:04 +09:00
KOBAYASHI Shuji df4b081392 Refactor t_print for test 2019-03-23 19:27:21 +09:00
Yukihiro "Matz" Matsumoto 36c9416bff Merge pull request #4336 from shuujii/simplify-assert_step
Simplify `assert_step` in `test/t/numeric.rb`
2019-03-22 22:38:05 +09:00
KOBAYASHI Shuji 04fc265858 Simplify assert_step in test/t/numeric.rb 2019-03-22 18:37:37 +09:00
Yukihiro "Matz" Matsumoto 84241d3dba Merge pull request #4334 from shuujii/remove-redundant-content-in-assertion-failure-message-and-diff
Remove redundant content in assertion failure message and diff
2019-03-22 14:40:19 +09:00
Yukihiro "Matz" Matsumoto 19191a5476 Merge pull request #4335 from shuujii/fix-Float-eql
Fix `Float#eql?`
2019-03-22 14:38:23 +09:00
KOBAYASHI Shuji a41b02ab91 Fix Float#eql? 2019-03-21 21:36:54 +09:00
KOBAYASHI Shuji 2b72baccf3 Remove redundant content in assertion failure message and diff
Based on minitest RubyGem.

Example of before this patch:

    - Assertion[1] Failed: Expected 1 to be 2
       Expected: 2
         Actual: 1
    - Assertion[2] Failed: Expected [1, 3] to include 2
       Collection: [1, 3]
           Object: 2

Example of after this patch:

    - Assertion[1]
       Expected: 2
         Actual: 1
    - Assertion[2]
       Expected [1, 3] to include 2.
2019-03-21 20:53:52 +09:00
Yukihiro "Matz" Matsumoto 3f7cd4687f Merge pull request #4333 from shuujii/use-FrozenError-instead-of-RuntimeError-in-frozen-obj-mod-test
Use `FrozenError` instead of `RuntimeError` in frozen object modification test
2019-03-20 18:43:41 +09:00
Yukihiro "Matz" Matsumoto cd3bf55b3e Merge pull request #4332 from shuujii/use-Rake-instead-of-MiniRake-on-AppVeyor
Use Rake instead of MiniRake on AppVeyor
2019-03-20 18:42:54 +09:00
KOBAYASHI Shuji fbad7a1595 Use FrozenError instead of RuntimeError in frozen object modification test 2019-03-19 20:48:32 +09:00
KOBAYASHI Shuji bc321ece4c Use Rake instead of MiniRake on AppVeyor
1. Reduce build time

Build time becomes less than half. In MiniRake, a way of using fiber may not be good.

2. Synchronize standard output

No synchronized:

    mrbtest - Embeddable Ruby Test
    ...........................
    Total: 1165
    (snip)
     Time: 1.19 seconds
    bintest - Command Binary Test

    .....................
    Total: 21
    (snip)
     Time: 0.39 seconds
    mrbtest - Embeddable Ruby Test

    ...........................
    Total: 1165
    (snip)
     Skip: 23
     Time: 1.15 seconds
    (snip)

    >>> Test cxx_abi <<<

    >>> Bintest host <<<
    >>> Test host <<<

    >>> Test full-debug <<<

    >>> Bintest cxx_abi <<<

Synchronized:

    >>> Test full-debug <<<
    mrbtest - Embeddable Ruby Test
    ...........................
    Total: 1165
    (snip)
     Time: 1.25 seconds

    >>> Test host <<<
    mrbtest - Embeddable Ruby Test
    ...........................
    Total: 1165
    (snip)
     Time: 1.16 seconds

    >>> Bintest host <<<
    bintest - Command Binary Test
    .....................
    Total: 21
    (snip)
     Time: 0.41 seconds

    >>> Test cxx_abi <<<
    mrbtest - Embeddable Ruby Test
    (snip)
2019-03-18 14:25:24 +09:00
Yukihiro "Matz" Matsumoto f8b17d1ec4 Merge pull request #4331 from shuujii/fix-class-instance-variable-name-validation
Fix class/instance variable name validation
2019-03-17 18:38:06 +09:00
KOBAYASHI Shuji b588e5a5b7 Fix class/instance variable name validation
- `@@?` etc are invalid class variable name.
- `@1` etc are invalid instance variable name.
2019-03-17 16:58:31 +09:00
Yukihiro "Matz" Matsumoto 15b6499c8b Merge pull request #4330 from shuujii/refine-appveyor.yml
Refine `appveyor.yml`
2019-03-16 20:30:07 +09:00
KOBAYASHI Shuji 1809fb755a Refine appveyor.yml
- Add Visual Studio 2017.
- Enable `shallow_clone` for saving build time.
- Cache extracted WinFlexBison.
2019-03-16 13:37:52 +09:00
Yukihiro "Matz" Matsumoto e9b1f14cdc Merge pull request #4329 from shuujii/use-FrozenError-instead-of-RuntimeError
Use `FrozenError` instead of `RuntimeError` in `String#rstrip!`
2019-03-15 23:18:19 +09:00
KOBAYASHI Shuji cd4daf78ec Use FrozenError instead of RuntimeError in String#rstrip! 2019-03-15 22:49:40 +09:00
Yukihiro "Matz" Matsumoto a1e1201148 Merge pull request #4328 from shuujii/fix-constant-name-validation
Fix constant name validation
2019-03-15 21:19:48 +09:00
Yukihiro "Matz" Matsumoto 298807fa4e Avoid using infinite binary floating point numbers in tests. 2019-03-15 15:25:43 +09:00
Yukihiro "Matz" Matsumoto 63b8f5cf57 Use fmt_fp() for portable float representation. 2019-03-15 15:25:43 +09:00
KOBAYASHI Shuji 16b1b2978e Fix constant name validation
`X!` etc are invalid constant name.
2019-03-14 23:09:05 +09:00
Yukihiro "Matz" Matsumoto 63124bf633 Merge pull request #4327 from shuujii/do-not-raise-an-exception-when-bintest-fail
Do not raise an exception when bintest fail
2019-03-13 22:30:08 +09:00
KOBAYASHI Shuji c3122c887a Do not raise an exception when bintest fail
- An exception do not raise when mrbtest fail.
- There are no useful informations in exception message and backtrace.
2019-03-13 22:04:14 +09:00
Yukihiro "Matz" Matsumoto ad0a8888f3 Merge pull request #4326 from shuujii/fix-typo-in-AUTHORS
Fix typo in `AUTHORS` [ci skip]
2019-03-13 09:06:18 +09:00
KOBAYASHI Shuji 29951a6d07 Fix typo in AUTHORS [ci skip] 2019-03-13 07:56:32 +09:00
Yukihiro "Matz" Matsumoto 1d38c1f307 Merge pull request #4322 from shuujii/reduce-String-creation-in-checking-name
Reduce `String` creation in `check_(cv|const)_name_sym`
2019-03-12 23:48:48 +09:00
Yukihiro "Matz" Matsumoto d2c325d08a Merge pull request #4325 from shuujii/fix-missing-assertions-in-mruby-string-ext-test
Fix missing assertions in `mruby-string-ext` test
2019-03-12 23:48:03 +09:00
Yukihiro "Matz" Matsumoto 07b9a10c06 Update the description at the head of AUTHORS; ref #4324 2019-03-12 23:36:26 +09:00
KOBAYASHI Shuji e3b339bec6 Fix missing assertions in mruby-string-ext test 2019-03-12 21:47:33 +09:00
Yukihiro "Matz" Matsumoto adfb25ab13 Merge pull request #4324 from shuujii/update-AUTHORS
Update `AUTHORS` [ci skip]
2019-03-12 21:21:25 +09:00
KOBAYASHI Shuji fc96dbcac6 Update AUTHORS [ci skip] 2019-03-12 09:46:29 +09:00
Yukihiro "Matz" Matsumoto 46e4524566 Merge pull request #4323 from shuujii/rename-MITL-to-LICENSE
Rename `MITL` to `LICENSE` in `.yardopts`; ref 67728c1 [ci skip]
2019-03-12 09:27:04 +09:00
KOBAYASHI Shuji e2976172c5 Rename MITL to LICENSE in .yardopts; ref 67728c1 [ci skip] 2019-03-12 09:21:43 +09:00
Yukihiro "Matz" Matsumoto 67728c1576 Rename MITL to LICENSE to conform GitHub convention. 2019-03-12 07:54:38 +09:00
KOBAYASHI Shuji 425e6e0ffb Reduce String creation in check_(cv|const)_name_sym 2019-03-11 17:26:19 +09:00
Yukihiro "Matz" Matsumoto fba8ecf55c Merge pull request #4321 from shuujii/add-bintest-header
Add bintest header
2019-03-10 23:51:03 +09:00
KOBAYASHI Shuji 7d1a8d3f8e Add bintest header 2019-03-10 21:46:24 +09:00
Yukihiro "Matz" Matsumoto 6a0ae792df Merge pull request #4316 from shuujii/add-a-missing-file-for-4314
Add a missing file for #4314
2019-03-09 10:19:32 +09:00
Yukihiro "Matz" Matsumoto d27808ef82 Merge pull request #4319 from shuujii/allow-enable_bintest-without-enable_test
Allow `enable_bintest` without `enable_test` in build config
2019-03-08 23:05:05 +09:00
KOBAYASHI Shuji 441c964716 Allow enable_bintest without enable_test in build config 2019-03-08 22:00:06 +09:00
Yukihiro "Matz" Matsumoto 4fb3edce11 Merge pull request #4318 from shuujii/set-GEMNAME-on-bintest
Set `GEMNAME` on bintest
2019-03-08 12:22:24 +09:00
KOBAYASHI Shuji 968e3b9400 Set GEMNAME on bintest 2019-03-07 22:16:47 +09:00
KOBAYASHI Shuji f6326803c7 Add a missing file for #4314 2019-03-07 21:36:54 +09:00
Yukihiro "Matz" Matsumoto bf922c9f7a Merge pull request #4315 from shuujii/refer-also-CXX-and-CC-env-vars-as-linker-command
Refer also CXX and CC env vars as linker command in gcc and clang toolchain
2019-03-06 22:26:34 +09:00
KOBAYASHI Shuji e2bb5ce079 Refer also CXX and CC env vars as linker command in gcc and clang toolchain
ref #4292
2019-03-06 20:42:31 +09:00
Yukihiro "Matz" Matsumoto 06e07cbcd8 Merge pull request #4314 from shuujii/count-skip-test
Count skip tests
2019-03-06 19:54:37 +09:00
KOBAYASHI Shuji 650ca7da17 Count skip tests 2019-03-05 19:53:25 +09:00
Yukihiro "Matz" Matsumoto 06dae1a9b6 Merge pull request #4313 from shuujii/extract-similar-code-fragment-to-method-in-src-class.c
Extract similar code fragment to method in `src/class.c`
2019-03-04 21:57:37 +09:00
Yukihiro "Matz" Matsumoto f82e11a7ed Merge pull request #4312 from shuujii/GEMNAME-is-undefined-in-bintest
`GEMNAME` is undefined in bintest
2019-03-04 06:48:31 +09:00
KOBAYASHI Shuji ee537eceee GEMNAME is undefined in bintest
ref: https://github.com/mruby/mruby/pull/4296#discussion_r261868710
2019-03-04 00:18:54 +09:00
Yukihiro "Matz" Matsumoto d1cdb9ef75 Merge pull request #4311 from shuujii/simplify-MRubyTestSkip-in-test-assert.rb
Simplify `MRubyTestSkip` in `test/assert.rb`
2019-03-03 23:22:23 +09:00
KOBAYASHI Shuji 376dd992f1 Extract similar code fragment to method in src/class.c 2019-03-03 20:45:44 +09:00
KOBAYASHI Shuji c6b8106924 Simplify MRubyTestSkip in test/assert.rb 2019-03-03 18:58:11 +09:00
Yukihiro "Matz" Matsumoto 83a1df3785 Merge pull request #4309 from shuujii/fix-missing-assertion-in-test-t-class.rb
Fix missing assertion in `test/t/class.rb`
2019-03-02 21:14:41 +09:00
KOBAYASHI Shuji 729ab86d49 Fix missing assertion in test/t/class.rb 2019-03-02 18:55:02 +09:00
Yukihiro "Matz" Matsumoto ad45f51caf Remove unused gem.bin= method; close #4271 2019-03-02 15:57:39 +09:00
Yukihiro "Matz" Matsumoto af51119d3a Raise error on failed comparison in sort; ref #4307 2019-03-02 15:46:50 +09:00
Yukihiro "Matz" Matsumoto 73091ab202 Do not apply mrb_ptr() to immediate objects; fix #4307 2019-03-02 15:45:15 +09:00
Yukihiro "Matz" Matsumoto ca0dcbb226 Free struct mrb_time before error; fix #4308
To avoid memory leak from `time_update_datetime`.
2019-03-02 14:13:06 +09:00
Yukihiro "Matz" Matsumoto e5649eba70 Remove useless regression tests; ref #4306 2019-03-02 14:01:52 +09:00
Yukihiro "Matz" Matsumoto 997cc8238d Remove useless regression tests; fix #4306 2019-03-02 14:00:25 +09:00
Yukihiro "Matz" Matsumoto 13e0a48e3c Print length of the iseq in code dump header; fix #4304 2019-03-02 13:51:46 +09:00
Yukihiro "Matz" Matsumoto 48fb239efb Merge pull request #4305 from shuujii/add-warning-prefix-to-parser-warning-message
Add `warning: ` prefix to parser warning message
2019-03-01 06:58:33 +09:00
KOBAYASHI Shuji 8c04ba2222 Add warning: prefix to parser warning message 2019-02-28 19:54:45 +09:00
Yukihiro "Matz" Matsumoto d25b9c9d0e Remove unnecessary backticks; ref #4301 2019-02-28 12:59:16 +09:00
Yukihiro "Matz" Matsumoto f1fb2bf29e Remove ?A style string literals from string tests; #4303
We have a plan to obsolete this style in the future.
2019-02-28 12:55:44 +09:00
Yukihiro "Matz" Matsumoto 4f3067fe2f Merge pull request #4301 from shuujii/remove-unnecessary-backticks
Remove unnecessary backticks; ref #2858
2019-02-28 12:55:26 +09:00
Yukihiro "Matz" Matsumoto 5424640f6f Merge pull request #4303 from dearblue/string-literal-concatenation
String literal concatenation
2019-02-28 07:05:08 +09:00
dearblue f9a568adcb Add test for string literal concatenation 2019-02-27 22:58:13 +09:00
dearblue e871a1538d Compositing NODE_DSTR and NODE_DSTR 2019-02-27 22:58:13 +09:00
dearblue 4d2bb3cb47 Compositing NODE_DSTR and NODE_STR 2019-02-27 22:58:13 +09:00
dearblue 8ead6da913 Compositing NODE_STR and NODE_DSTR 2019-02-27 22:58:13 +09:00
dearblue 25957421bc Replacement to function for composite two string nodes 2019-02-27 22:58:13 +09:00
dearblue 477e5285e8 Replacement to function for NODE_STR cheking 2019-02-27 22:58:09 +09:00
dearblue 9913643ed8 Compositing NODE_STR and NODE_STR 2019-02-27 22:57:45 +09:00
dearblue cece016389 Concatenate string literals 2019-02-27 22:35:53 +09:00
Yukihiro "Matz" Matsumoto 6962d0ddde Merge pull request #4302 from shuujii/add-newline-to-warning-by-mrb_warn
Add newline to warning by `mrb_warn()`
2019-02-27 22:33:22 +09:00
Yukihiro "Matz" Matsumoto 759b57d22a Merge pull request #4300 from shuujii/use-yywarning-instead-of-yywarning_s-for-MRB_WITHOUT_FLOAT
Use `yywarning()` instead of `yywarning_s()` for `MRB_WITHOUT_FLOAT`
2019-02-27 22:32:31 +09:00
KOBAYASHI Shuji 62bb9c6436 Add newline to warning by mrb_warn() 2019-02-27 20:58:20 +09:00
KOBAYASHI Shuji c11bd075f7 Remove unnecessary backticks; ref #2858 2019-02-27 20:27:29 +09:00
KOBAYASHI Shuji 2894625089 Use yywarning() instead of yywarning_s() for MRB_WITHOUT_FLOAT 2019-02-27 20:21:40 +09:00
Yukihiro "Matz" Matsumoto 018f4bd32e Merge pull request #4299 from shuujii/remove-unneeded-separator-in-test-skip-error-messages
Remove unneeded `=>` in test skip/error messages
2019-02-27 07:29:17 +09:00
Yukihiro "Matz" Matsumoto d544401f1f Merge pull request #4298 from shuujii/remove-unneeded-const_defined-Time-in-mruby-io-test
Remove unneeded `const_defined?(:Time)` in `mruby-io` test
2019-02-26 21:49:32 +09:00
KOBAYASHI Shuji fdb7f9dad3 Remove unneeded => in test skip/error messages 2019-02-26 21:32:34 +09:00
KOBAYASHI Shuji c6cd69970b Remove unneeded const_defined?(:Time) in mruby-io test
`mruby-time` is included in test dependencies.
2019-02-26 21:12:41 +09:00
Yukihiro "Matz" Matsumoto 68f421c859 Merge pull request #4294 from shuujii/remove-explicit-set-of-DISABLE_GEMS
Remove explicit set of `DISABLE_GEMS`
2019-02-25 23:49:16 +09:00
Yukihiro "Matz" Matsumoto 6337bde8a5 Merge pull request #4296 from shuujii/refine-mrbgem-name-in-assertion-failure-message-for-core-test
Refine mrbgem name in assertion failure/skip message for core test
2019-02-25 23:48:04 +09:00
Yukihiro "Matz" Matsumoto 96b12b9813 Merge pull request #4297 from shuujii/refactor-src-backtrace.c
Refactor `src/backtrace.c`
2019-02-25 23:46:24 +09:00
KOBAYASHI Shuji c49a10f9a0 Refactor src/backtrace.c
- Move calling `mrb_debug_get_filename()` to after `lineno` check.
- Remove unneeded array check in `print_backtrace()`.
- Add a few `const` qualifier.
2019-02-25 20:39:20 +09:00
KOBAYASHI Shuji 5c40203930 Refine mrbgem name in assertion failure/skip message for core test 2019-02-24 19:21:40 +09:00
Yukihiro "Matz" Matsumoto ad87fd2287 Merge pull request #4295 from wataash/struct-dig
Move `Object#dig` to `Struct#dig`
2019-02-24 18:13:56 +09:00
Wataru Ashihara e91f3ec770 Move Object#dig to Struct#dig
This method seems to be mistakenly put into `Object` instead of `Struct`
since it's in `struct.rb` and daf83946b says:

  add #dig to Array,Hash and Struct
2019-02-24 16:59:02 +09:00
KOBAYASHI Shuji 31f1b4a553 Remove explicit set of DISABLE_GEMS
`DISABLE_GEMS` is automatically set (or unset); ref #790
2019-02-23 18:29:37 +09:00
Yukihiro "Matz" Matsumoto f5cfb77078 Merge pull request #4293 from shuujii/integrate-init_mrbtest.c-to-driver.c-in-mruby-test-mrbgem
Integrate `init_mrbtest.c` to `driver.c` in `mruby-test` mrbgem
2019-02-23 10:31:40 +09:00
KOBAYASHI Shuji f209f781ac Integrate init_mrbtest.c to driver.c in mruby-test mrbgem
- `mrbgemtest_init()` is needed if `DISABLE_GEMS` is enabled because core
  tests are run as part of `mruby-test` mrbgem (moreover, `DISABLE_GEMS` is
  disabled when `enable_test` is used in build config).
- For the same reason `mrb_open_core()` etc for core tests is unneeded.
2019-02-22 20:41:20 +09:00
Yukihiro "Matz" Matsumoto 5cc277340f Merge pull request #4291 from shuujii/fix-typo-in-lib-mruby-build-command.rb
Fix typo in `lib/mruby/build/command.rb`
2019-02-21 22:40:17 +09:00
Yukihiro "Matz" Matsumoto 769b56c3ae Merge pull request #4290 from shuujii/refactor-exception-handling-in-assert
Refactor exception handling in `assert`
2019-02-21 22:37:09 +09:00
KOBAYASHI Shuji 37fb5f929f Fix typo in lib/mruby/build/command.rb 2019-02-21 19:47:00 +09:00
KOBAYASHI Shuji ad789944db Refactor exception handling in assert 2019-02-21 17:44:45 +09:00
Yukihiro "Matz" Matsumoto 76262b8e28 Merge pull request #4288 from shuujii/assert_true-should-pass-when-actual-is-only-true
`assert_true`/`assert_false` should pass when actual is only `true`/`false`
2019-02-20 19:42:01 +09:00
KOBAYASHI Shuji 244abdae09 assert_true/assert_false should pass when actual is only true/false
For the following reasons:

- Previous behavior is confusable because it's different from test/unit rubygem's `assert_true`
- Tests may pass unintentionally in an inappropriate way; ref #4285 #4287
2019-02-20 18:49:38 +09:00
Yukihiro "Matz" Matsumoto baf8fbe6ed Merge pull request #4286 from kimushu/mrdb-local-variables
mrdb: add "info locals" command
2019-02-19 20:44:16 +09:00
Yukihiro "Matz" Matsumoto 8781596c35 Merge pull request #4287 from shuujii/use-more-appropriate-assertion-methods
Use more appropriate assertion methods
2019-02-19 20:31:10 +09:00
KOBAYASHI Shuji 8a7298e069 Use more appropriate assertion methods 2019-02-19 20:02:50 +09:00
kimu_shu 477ffc7473 Add "info locals" command to mrdb 2019-02-19 18:10:05 +09:00
Yukihiro "Matz" Matsumoto 971bfd13c1 Merge pull request #4284 from shuujii/use-assert_same-instead-of-assert_equal-in-enum-reverse_each-test
Use `assert_same` instead of `assert_equal` in `Enumerable#reverse_each` test
2019-02-18 21:50:08 +09:00
Yukihiro "Matz" Matsumoto 4164d4efdf Merge pull request #4285 from shuujii/fix-wrong-assertin-method-in-some-tests
Fix wrong assertion method in some tests
2019-02-18 21:47:41 +09:00
KOBAYASHI Shuji d68eb3d043 Fix wrong assertion method in some tests 2019-02-18 21:24:20 +09:00
KOBAYASHI Shuji f86e4a5d93 Use assert_same instead of assert_equal in Enumerable#reverse_each test 2019-02-18 21:06:18 +09:00
Yukihiro "Matz" Matsumoto 9215c85450 Parenthesize expression to suppress warning; ref #4278 2019-02-18 17:25:01 +09:00
Yukihiro "Matz" Matsumoto 4ccc3f1525 Use key argument register for OP_KEY_P to reduce register use. 2019-02-18 17:25:01 +09:00
Yukihiro "Matz" Matsumoto e986dfa8aa Merge pull request #4283 from shuujii/reorder-members-in-struct-backtrace_location
Reorder members in `struct backtrace_location`
2019-02-18 17:24:48 +09:00
Yukihiro "Matz" Matsumoto 93e25f4aaa Merge pull request #4282 from shuujii/remove-unneeded-memset-in-backtrace.c
Remove unneeded `memset()` in `src/backtrace.c`
2019-02-18 17:24:16 +09:00
KOBAYASHI Shuji a28d714398 Reorder members in struct backtrace_location
`sizeof(struct backtrace_location)` is 24 bytes -> 16 bytes in LP64
data model etc.
2019-02-18 16:38:56 +09:00
KOBAYASHI Shuji 15344dfd0b Remove unneeded memset() in src/backtrace.c 2019-02-18 16:12:12 +09:00
Yukihiro "Matz" Matsumoto 3e0d29b7be Merge pull request #4279 from dearblue/fix-inline-packed-symbols
Fix destroyed "inline packed symbols" on 32 bit mode with `MRB_WORD_BOXING`
2019-02-17 22:13:22 +09:00
Yukihiro "Matz" Matsumoto a3e8b750ef Merge pull request #4280 from shuujii/refine-deps-for-mruby-config
Refine dependencies for `mruby-config`
2019-02-17 22:12:19 +09:00
Yukihiro "Matz" Matsumoto 391b5aa0d8 Merge pull request #4281 from yui-knk/typos [ci skip
Fix typos
2019-02-17 22:11:32 +09:00
yui-knk f614eed13a Fix typos 2019-02-17 21:34:33 +09:00
KOBAYASHI Shuji b3e0a13989 Refine dependencies for mruby-config 2019-02-17 15:52:16 +09:00
dearblue 5067a5cd58 Use const int instead of enum 2019-02-16 22:13:16 +09:00
Yukihiro "Matz" Matsumoto 21933b7790 Merge pull request #4278 from shuujii/add-length-argument-for-sym_inline_unpack
Add length argument for `sym_inline_unpack()`
2019-02-16 21:52:39 +09:00
dearblue 81cbc92513 Fix inline packed symbols on 32 bit mode with MRB_WORD_BOXING 2019-02-16 21:26:45 +09:00
dearblue d1db959cab Fix to defined MRB_SYMBOL_BITSIZE and MRB_SYMBOL_MAX always; ref #4077 2019-02-16 21:24:05 +09:00
KOBAYASHI Shuji 2c8af128f4 Add length argument for sym_inline_unpack()
`sym_inline_unpack_with_bit()` is moved inside of `sym_inline_unpack()`
because this is used only one place.
2019-02-16 20:48:33 +09:00
Yukihiro "Matz" Matsumoto c769013f9b Merge pull request #4277 from shuujii/extract-code-fragment-for-unpacking-in-sym_inline_unpack
Extract code fragment for unpacking into method in `sym_inline_unpack()`
2019-02-15 20:12:49 +09:00
KOBAYASHI Shuji 5b10439f6f Extract code fragment for unpacking into method in sym_inline_unpack() 2019-02-15 19:48:00 +09:00
Yukihiro "Matz" Matsumoto cc94c8bf9d Merge pull request #4276 from shuujii/use-assert-for-checking-sym-in-sym_inline_unpack
Use `mrb_assert()` for checking `sym` in `sym_inline_unpack()`
2019-02-15 16:34:18 +09:00
Yukihiro "Matz" Matsumoto 702a868b86 Merge pull request #4275 from shuujii/add-const-to-pack_table-in-symbol.c
Add `const` to `pack_table` in `src/symbol.c`
2019-02-14 20:12:03 +09:00
KOBAYASHI Shuji 921af6923d Use mrb_assert() for checking sym in sym_inline_unpack() 2019-02-14 18:48:41 +09:00
KOBAYASHI Shuji bedd672571 Add const to pack_table to src/symbol.c 2019-02-14 18:44:00 +09:00
Yukihiro "Matz" Matsumoto 01c908117d Merge pull request #4274 from shuujii/lazy-message-diff-creation-for-assertion
Lazy message/diff creation for assertion in `test/assert.rb`
2019-02-14 13:10:48 +09:00
KOBAYASHI Shuji 6cdac5efb6 Lazy message/diff creation for assertion in test/assert.rb
Include the following changes too:

- Extract part of logic with block to a method
- Use `var ||= ...` instead of `var = ... unless var`
- Unify using parentheses for `t_print`
- Change methods order
2019-02-14 09:04:42 +09:00
Yukihiro "Matz" Matsumoto a6c0aa8306 Merge pull request #4269 from shuujii/always-through-assert_true-for-assertion
Always through `assert_true` for assertion methods in `test/assert.rb`
2019-02-13 07:10:13 +09:00
Yukihiro "Matz" Matsumoto ae5ff737e0 Merge pull request #4273 from shuujii/refine-mruby-bin-config-mrbgem.rake
Refine `mrbgems/mruby-bin-config/mrbgem.rake`
2019-02-13 07:09:07 +09:00
KOBAYASHI Shuji c592c093aa Refine mrbgems/mruby-bin-config/mrbgem.rake
- Use `MRuby::Gem::Specification`
- Fix a binary name is added to `MRuby::Build#bins` multiple times
- Close file immediately (avoid using `open(...).read`)
- Simplify
2019-02-12 21:45:38 +09:00
Yukihiro "Matz" Matsumoto 37bc343e0a Disable Symbol.all_symbols. 2019-02-12 17:30:34 +09:00
Yukihiro "Matz" Matsumoto 06ba5905f0 Implement inline packed symbols.
Small symbols with all alphanumeric characters (<5) are packed in 32bit
symbol integer a la base64. This means those small symbols are not
listed in `Symbol.all_symbols`.
2019-02-12 17:30:34 +09:00
Yukihiro "Matz" Matsumoto 3a95bf0ddb Merge pull request #4272 from shuujii/refactor-for-node_back_ref-in-codegen
Small refactoring in `codegen.c`
2019-02-11 22:47:43 +09:00
KOBAYASHI Shuji c6e2d91536 Small refactoring in codegen.c 2019-02-11 21:09:40 +09:00
Yukihiro "Matz" Matsumoto ef93ff6405 Should not copy keys&values when a hash table is empty; fix #4270 2019-02-11 15:20:34 +09:00
Yukihiro "Matz" Matsumoto 639f6e2799 No strict argument check for blocks when keyword arguments exist; ref #4270 2019-02-11 15:20:34 +09:00
Yukihiro "Matz" Matsumoto 55e58d8512 Merge pull request #4268 from dearblue/null-safe-mrb_open_core
NULL safed `mrb_open_core()`
2019-02-10 08:58:10 +09:00
KOBAYASHI Shuji e60f5f5cee Always through assert_true for assertion methods in test/assert.rb 2019-02-09 21:48:12 +09:00
dearblue eb6aee117b mrb_default_allocf() is default allocator for NULL safe 2019-02-09 20:22:08 +09:00
Yukihiro "Matz" Matsumoto fc883de458 Merge pull request #4266 from shuujii/add-no_method_error-tests-to-enumerator
Add `NoMethodError` tests to `mruby-enumerator`
2019-02-08 23:28:38 +09:00
KOBAYASHI Shuji 19740d45a1 Add NoMethodError tests to mruby-enumerator 2019-02-08 17:40:12 +09:00
Yukihiro "Matz" Matsumoto 3d73a29783 Merge branch 'shuujii-fix-enumerator-initialize-for-nil-or-false' 2019-02-08 09:35:34 +09:00
Yukihiro "Matz" Matsumoto e0bc87297e Update mruby-enumerator test to conform the last update. 2019-02-08 09:35:28 +09:00
Yukihiro "Matz" Matsumoto 9ab7c1111b Update #4265 patch.
* Update doc comment to clarify `Enumerator.new` without a block is
  deprecated and left only for internal use.

* Fixed some cases `mruby` raise `ArgumentError` too eagerly compared
  with `CRuby`.
2019-02-08 09:35:28 +09:00
KOBAYASHI Shuji 2650999092 Fix Enumerator#(initialize|inspect) for nil/false 2019-02-08 09:35:28 +09:00
Yukihiro "Matz" Matsumoto c32e3158f5 Update mruby-enumerator test to conform the last update. 2019-02-08 09:34:31 +09:00
Yukihiro "Matz" Matsumoto 32f3ffa2c9 Update #4265 patch.
* Update doc comment to clarify `Enumerator.new` without a block is
  deprecated and left only for internal use.

* Fixed some cases `mruby` raise `ArgumentError` too eagerly compared
  with `CRuby`.
2019-02-08 09:31:55 +09:00
Yukihiro "Matz" Matsumoto 60529fdeeb Merge branch 'fix-enumerator-initialize-for-nil-or-false' of https://github.com/shuujii/mruby into shuujii-fix-enumerator-initialize-for-nil-or-false 2019-02-08 09:13:39 +09:00
Yukihiro "Matz" Matsumoto 687a4d961f Merge pull request #4251 from shuujii/remove-no-meaning-statements-in-mruby-io-tests
Remove no meaning statements in `mruby-io` tests
2019-02-08 07:19:40 +09:00
KOBAYASHI Shuji e846db709f Fix Enumerator#(initialize|inspect) for nil/false 2019-02-07 23:52:08 +09:00
Yukihiro "Matz" Matsumoto bdc9de875f Add OP_ENTER to blocks without parameters; fix #4175
So that `lambda{}.call(1)` raises `ArgumentError` as CRuby does.
Also, fixed junk assignment for `lambda{|;a|p a}.call{}`.
2019-02-07 22:44:36 +09:00
Yukihiro "Matz" Matsumoto 156641515c Merge branch 'shuujii-rename-bin-mruby-config-to-bin-config' 2019-02-07 15:54:08 +09:00
Yukihiro "Matz" Matsumoto e199df032d Merge branch 'rename-bin-mruby-config-to-bin-config' of https://github.com/shuujii/mruby into shuujii-rename-bin-mruby-config-to-bin-config 2019-02-07 15:52:58 +09:00
Yukihiro "Matz" Matsumoto 6397ec727f Raise NameError for symbol struct access. 2019-02-07 15:52:33 +09:00
Yukihiro "Matz" Matsumoto 215906dc83 Merge pull request #4264 from shuujii/integrate-definition-of-exefile
Integrate definition of `MRuby::Build#exefile`
2019-02-07 07:05:05 +09:00
Yukihiro "Matz" Matsumoto d52f46da45 Implement symbol hash table to boost find_symbol.
In 4174e02, we removed the symbol hash table from `mrb_state` but
`find_symbol` was too slow with linear search. My performance estimation
was wrong. So we implemented a new compact hash table for symbols.
2019-02-06 22:07:11 +09:00
Yukihiro "Matz" Matsumoto 905fef2669 Reduce invocation of mrb_convert_type() from mrb_str_to_str(). 2019-02-06 22:07:11 +09:00
Yukihiro "Matz" Matsumoto 02fbb2c211 Remove symbol hash table from mrb_state structure.
Use linear search instead. Number of symbols is usually small (<1K), so
we don't need performance boost from hash tables. In our benchmark
measurement, hash tables consumes 790KB for `build/full-debug/mrbtest`.
2019-02-06 22:07:11 +09:00
KOBAYASHI Shuji c8628f7ca4 Integrate definition of MRuby::Build#exefile 2019-02-06 22:05:10 +09:00
Yukihiro "Matz" Matsumoto 1076bebde7 Merge pull request #4256 from shuujii/move-none-to-mrblib-enum
Move `NONE` to `mrblib/enum.rb`
2019-02-06 20:18:45 +09:00
Yukihiro "Matz" Matsumoto cb8bbd9e12 Merge pull request #4262 from shuujii/remove-old-comment-in-symbol
Remove old comment for `mrb_sym2name_len()` [ci skip]
2019-02-05 22:51:26 +09:00
Yukihiro "Matz" Matsumoto f51c0f5a59 Merge pull request #4261 from shuujii/fix-doc-markup-in-string
Fix markup and remove unneeded comment for doc in `src/string.c` [ci skip]
2019-02-05 22:50:56 +09:00
KOBAYASHI Shuji 5ef1e479da Remove old comment for mrb_sym2name_len() [ci skip] 2019-02-05 19:16:23 +09:00
KOBAYASHI Shuji 7a2865cfef Fix markup and remove unneeded comment for doc in src/string.c [ci skip] 2019-02-05 19:11:59 +09:00
Yukihiro "Matz" Matsumoto db2545cb3c Merge pull request #4260 from shuujii/fix-symbol-size-with-mrb_utf8_string
Fix `Symbol#size` for multi-byte characters with `MRB_UTF8_STRING`
2019-02-04 21:11:06 +09:00
KOBAYASHI Shuji 69fd1a5925 Fix Symbol#size for multi-byte characters with MRB_UTF8_STRING
Before:

  p :あ.size  #=> 3

After:

  p :あ.size  #=> 1
2019-02-04 18:11:22 +09:00
Yukihiro "Matz" Matsumoto 5fd9f68b27 Merge pull request #4259 from shuujii/use-eException_class-instead-of-mrb_class_get
Use `mrb->eException_class` instead of `mrb_class_get()`
2019-02-04 07:35:00 +09:00
KOBAYASHI Shuji c86861bddf Use mrb->eException_class instead of mrb_class_get() 2019-02-03 22:00:55 +09:00
Yukihiro "Matz" Matsumoto 3f7137feae Merge pull request #4258 from shuujii/extend-only-when-necessary
Extend only when necessary in `lib/mruby-core-ext.rb`
2019-02-02 21:14:55 +09:00
KOBAYASHI Shuji 668ed60521 Extend only when necessary in lib/mruby-core-ext.rb 2019-02-02 18:53:49 +09:00
KOBAYASHI Shuji 6da3cd5d22 Move NONE to mrblib/enum.rb 2019-02-01 16:02:01 +09:00
KOBAYASHI Shuji 465fdde52d Enumerator#size is not supported [ci skip] 2019-01-31 21:25:35 +09:00
Yukihiro "Matz" Matsumoto 32067b5005 Merge pull request #4254 from shuujii/remove-unneeded-dup-in-enumerator-initialize
Remove unneeded `dup` in `Enumerator#initialize`
2019-01-31 16:20:11 +09:00
KOBAYASHI Shuji 6218585968 Remove unneeded dup in Enumerator#initialize 2019-01-30 19:41:32 +09:00
Yukihiro "Matz" Matsumoto cc32cc50f8 Merge pull request #4253 from shuujii/remove-unused-macro-in-string
Remove unused macro in `src/string.c`
2019-01-29 23:10:27 +09:00
KOBAYASHI Shuji 486154ce34 Remove unused macro in src/string.c 2019-01-29 20:21:25 +09:00
Yukihiro "Matz" Matsumoto c02c4047f8 Merge pull request #4252 from shuujii/class-expr-with-empty-body-should-return-nil
`class`/`module` expression  with empty body should return `nil`
2019-01-28 23:14:22 +09:00
KOBAYASHI Shuji abbc501433 class/module expression with empty body should return nil
Before:

  p(class A end)          #=> A
  p(class << self; end)   #=> #<Class:#<Object:0x7fdc3880e420>>
  p(module B end)         #=> B

After/Ruby:

  p(class A end)          #=> nil
  p(class << self; end)   #=> nil
  p(module B end)         #=> nil
2019-01-28 21:29:55 +09:00
KOBAYASHI Shuji 12ba571a13 Use assertion methods in FileTest tests 2019-01-28 12:17:41 +09:00
KOBAYASHI Shuji e85cb9799c Remove no meaning statements in mruby-io tests 2019-01-27 20:35:41 +09:00
Yukihiro "Matz" Matsumoto 1b597f9da4 Merge pull request #4249 from takkaw/fix_time_carry_up_and_down
fix Time about carry-up and carry-down
2019-01-27 11:41:31 +09:00
takkaw 995a329bf4 fix Time about carry-up and carry-down 2019-01-26 23:19:53 +09:00
Yukihiro "Matz" Matsumoto 8a988643e8 Merge pull request #4241 from shuujii/fix-tests-for-string-reverse-with-mrb-utf8-string
Fix tests for `String#reverse` with `MRB_UTF8_STRING`
2019-01-26 22:34:05 +09:00
Yukihiro "Matz" Matsumoto a03e721408 Merge pull request #4237 from dearblue/fix-memleak-Data_Wrap_Struct
Fix memory leak `sval` when out of memory in `Data_Wrap_Struct()`
2019-01-26 22:33:23 +09:00
Yukihiro "Matz" Matsumoto 2f62178dda Merge pull request #4235 from shuujii/avoid-side-effect-when-run-rake
Avoid a side effect when run Rake without execution of tasks
2019-01-26 22:19:00 +09:00
Yukihiro "Matz" Matsumoto 1e67c98c85 Merge pull request #4248 from shuujii/refine-error-message-for-time-interval
Refine error message for time interval
2019-01-26 22:17:31 +09:00
KOBAYASHI Shuji 1cd57006f3 Refine error message for time interval
Time interval value can be zero, and float (in `Kernel#sleep`)
2019-01-26 18:37:53 +09:00
Yukihiro "Matz" Matsumoto aee67eaf62 Merge pull request #4240 from shuujii/refactor-sleep-test
Use `assert_raise` and `assert_nothing_raised` in `mruby-sleep` tests
2019-01-25 22:47:56 +09:00
Yukihiro "Matz" Matsumoto fc5dc5270c Merge pull request #4245 from shuujii/remove-assert_nothing_raised-in-io-test
Remove definition of `assert_nothing_raised` in `IO` test
2019-01-25 22:47:15 +09:00
Yukihiro "Matz" Matsumoto a2615900c0 Merge pull request #4246 from shuujii/use-assertion-methods-in-file-test
Use assertion methods in `File` test
2019-01-25 22:46:12 +09:00
Yukihiro "Matz" Matsumoto 89a76f4a49 Merge pull request #4247 from shuujii/remove-unused-file-for-mruby-io-test
Remove unused file for `mruby-io` test
2019-01-25 22:45:08 +09:00
KOBAYASHI Shuji b91a17b33b Remove unused file for mruby-io test 2019-01-25 20:35:55 +09:00
KOBAYASHI Shuji e9a6ec05b6 Use assertion methods in File test 2019-01-25 20:12:24 +09:00
KOBAYASHI Shuji bdbbac999f Remove definition of assert_nothing_raised in IO test 2019-01-25 20:02:45 +09:00
Yukihiro "Matz" Matsumoto 671447964f Merge pull request #4243 from shuujii/remove-definition-of-sprintf-in-mruby-print
Remove definition of `Kernel#sprintf` in `mruby-print`
2019-01-25 08:15:27 +09:00
Yukihiro "Matz" Matsumoto 8eddcbf53d Merge pull request #4244 from shuujii/remove-redundant-null-check-for-mrb_malloc
Remove redundant `NULL` check for `mrb_malloc`
2019-01-24 22:20:56 +09:00
KOBAYASHI Shuji a4c5fcc038 Remove redundant NULL check for mrb_malloc 2019-01-24 20:53:40 +09:00
KOBAYASHI Shuji 1d6679e9d1 Remove definition of Kernel#sprintf in mruby-print 2019-01-24 20:44:55 +09:00
Yukihiro "Matz" Matsumoto 5956f5b4e8 Merge pull request #4242 from shuujii/remove-no-meaning-statement
[ci skip] Remove no meaning statement in `bm_app_lc_fizzbuzz.rb`
2019-01-23 21:50:09 +09:00
KOBAYASHI Shuji f54262776e [ci skip] Remove no meaning statement in bm_app_lc_fizzbuzz.rb 2019-01-23 21:19:39 +09:00
KOBAYASHI Shuji 6d5a62cf5f Fix tests for String#reverse with MRB_UTF8_STRING 2019-01-22 19:37:14 +09:00
KOBAYASHI Shuji 3707ef3d1c Use assert_raise and assert_nothing_raised in mruby-sleep tests 2019-01-21 19:37:20 +09:00
KOBAYASHI Shuji 8c22911c86 Rename mruby-bin-mruby-config mrbgem to mruby-bin-config
For brevity and consistency (e.g. `mruby-bin-strip` doesn't have `mruby-`
after `bin-`).
2019-01-20 19:47:58 +09:00
dearblue d6d02774c5 Fix memory leak sval when out of memory in Data_Wrap_Struct() 2019-01-20 14:23:22 +09:00
Yukihiro "Matz" Matsumoto b83e4df43d Merge pull request #4236 from shuujii/remove-gitkeep
Remove `.gitkeep` files
2019-01-20 10:30:12 +09:00
KOBAYASHI Shuji dff0f2ee10 Remove .gitkeep files 2019-01-19 20:40:21 +09:00
KOBAYASHI Shuji 107dc0c778 Avoid a side effect when run Rake without execution of tasks
Avoid directory creation when run `rake -T` etc.
2019-01-18 23:29:35 +09:00
Yukihiro "Matz" Matsumoto cb1946f26c Merge pull request #4233 from shuujii/remove-special-treatments-for-without-float-in-build-scripts
Remove special treatments for `MRB_WITHOUT_FLOAT` in build scripts
2019-01-18 16:17:58 +09:00
Yukihiro "Matz" Matsumoto 3d32be6f3e Merge pull request #4231 from shuujii/avoid-runtime-eval-for-without-float
Avoid runtime evaluation for `MRB_WITHOUT_FLOAT`
2019-01-18 16:16:48 +09:00
Yukihiro "Matz" Matsumoto 9a2366ded6 Merge pull request #4234 from shuujii/fix-assertion-name-for-numeric-test
Fix assertion name for `Numeric#**` test
2019-01-18 16:16:19 +09:00
KOBAYASHI Shuji cfe3654fd1 Fix assertion name for Numeric#** test 2019-01-17 21:16:02 +09:00
KOBAYASHI Shuji 366a14f297 Remove special treatments for MRB_WITHOUT_FLOAT in build scripts 2019-01-16 23:48:59 +09:00
KOBAYASHI Shuji 8969edf03b Avoid runtime evaluation for MRB_WITHOUT_FLOAT 2019-01-16 19:32:29 +09:00
Yukihiro "Matz" Matsumoto fa34a8b5be Merge pull request #4230 from shuujii/fix-coercing-for-step-counter-in-numeric-step
Fix coercing for first step counter in `Numeric#step`
2019-01-15 22:27:40 +09:00
KOBAYASHI Shuji de5da4b7f6 Fix coercing for first step counter in Numeric#step
Before:

  a=[]; 7.step(4, -3.0) { |c| a << c }; p a  #=> [7, 4.0]

After / Ruby:

  a=[]; 7.step(4, -3.0) { |c| a << c }; p a  #=> [7.0, 4.0]
2019-01-15 21:41:54 +09:00
Yukihiro "Matz" Matsumoto 348442dd5e Merge pull request #4228 from shuujii/sort-gitignore
[ci skip] Sort `.gitignore`
2019-01-15 20:09:00 +09:00
KOBAYASHI Shuji adfc2d08c9 [ci skip] Sort .gitignore 2019-01-15 19:30:15 +09:00
Yukihiro "Matz" Matsumoto 127d355bf8 Merge pull request #4226 from dearblue/fix-build-cxx-exc
Build fails when set `conf.build_dir=<rel path>` and `conf.enable_cxx_exception`
2019-01-15 11:00:05 +09:00
Yukihiro "Matz" Matsumoto 4797542b71 Merge pull request #4227 from shuujii/ignore-compiler-tmp-files
Ignore compiler temporary files (for `-save-temps` flag)
2019-01-15 10:57:44 +09:00
KOBAYASHI Shuji bb52efd0fc Ignore compiler temporary files (for -save-temps flag) 2019-01-14 21:45:57 +09:00
Yukihiro "Matz" Matsumoto 17333bde3a Merge pull request #4222 from shuujii/use-g-instead-of-e
Use `%g` instead of `%e` for float representation in dump format
2019-01-14 19:13:48 +09:00
Yukihiro "Matz" Matsumoto 348526e1ad Merge pull request #4225 from shuujii/improve-compatibility-to-cruby-for-float-to_s
Improve compatibility to CRuby for `Float#to_s`
2019-01-14 19:13:09 +09:00
dearblue a7c2ef9dab Fix build failed when set conf.build_dir=<rel path> and conf.enable_cxx_exception 2019-01-14 15:21:21 +09:00
KOBAYASHI Shuji 0e04c46261 Use 2 digits exponent format for printf family on old MSVC
For conforming C standard.
2019-01-13 23:24:57 +09:00
KOBAYASHI Shuji 9f081183d2 Improve compatibility to CRuby for Float#to_s
Bfore:

  Float::INFINITY.to_s  #=> "inf"
  50.0.to_s             #=> "50"
  1e20.to_s             #=> "1e+20"

After / CRuby:

  Float::INFINITY.to_s  #=> "Infinity"
  50.0.to_s             #=> "50.0"
  1e20.to_s             #=> "1.0e+20"
2019-01-13 19:59:22 +09:00
Yukihiro "Matz" Matsumoto c1b92f88a2 Merge pull request #4224 from shuujii/use-__send__-instead-of-send
Use `__send__` instead of `send`; ref #4207
2019-01-13 08:03:14 +09:00
KOBAYASHI Shuji 8b951710fe Use __send__ instead of send; ref #4207 2019-01-12 22:21:34 +09:00
KOBAYASHI Shuji 2d8aec2b88 Use %g instead of %e for float representation in dump format
`%g` use shorter representation than `%e`.
2019-01-11 19:54:46 +09:00
Yukihiro "Matz" Matsumoto 980b7b5c50 Merge pull request #4221 from shuujii/remove-duplicate-code-in-numeric
Remove duplicate code in numeric.c
2019-01-11 08:47:02 +09:00
KOBAYASHI Shuji 856b8d9610 Remove duplicate code in numeric.c 2019-01-10 23:22:23 +09:00
Yukihiro "Matz" Matsumoto 8dcd66cc27 Merge pull request #4220 from shuujii/change-order-for-assertion-args
Change the order of "expected" and "actual" in test
2019-01-10 09:19:17 +09:00
KOBAYASHI Shuji 0740595f85 Change the order of "expected" and "actual" in test 2019-01-09 20:00:17 +09:00
Yukihiro "Matz" Matsumoto d88d7aaf4b Use $mrbtest_io_wfname for chmod test. 2019-01-09 13:04:23 +09:00
Yukihiro "Matz" Matsumoto 81862fd689 Update compiled binary format version; ref #4219 2019-01-08 21:44:40 +09:00
Yukihiro "Matz" Matsumoto d38a8e8807 Update OP_APOST description (typo fixed). 2019-01-08 21:43:04 +09:00
Yukihiro "Matz" Matsumoto 712a8bb1b2 Merge pull request #4219 from shuujii/fix-dump-load-float-literal-evaluate-to-infinity
Fix dump/load float leteral evaluate to infinity
2019-01-08 21:42:50 +09:00
Yukihiro "Matz" Matsumoto b575d0c45e Merge pull request #4218 from take-cheeze/export_time_api
Add `Time` object creation API
2019-01-08 21:35:51 +09:00
KOBAYASHI Shuji 68735d1261 Fix dump/load float leteral evaluate to infinity
Example:

  # example.rb
  p(2e308)
  p(-2e308)

  Good:

    $ bin/mruby example.rb
    inf
    -inf

  Bad:

    $ bin/mrbc example.rb
    $ bin/mruby -b example.mrb
    0
    -0

Cause:

  Float infinity representation is `inf` on dump and it is converted by
  corresponding `String#to_f` on load.

Treatment:

  - Introduce new representations (`i`: +infinity, `I`: -infinity)
  - Allow old representations (`inf`, `-inf`, `infinity`, `-infinity`) too
  - Raise error for unknown representations (use corresponding `Kernel#Float`)
2019-01-08 20:43:23 +09:00
take-cheeze 3e7a3a0a15 Export Time creation API 2019-01-08 20:26:39 +09:00
Yukihiro "Matz" Matsumoto 817436c33b Merge pull request #4217 from shuujii/fix-0.0-handling
Fix `0.0` and `-0.0` handling.
2019-01-07 18:16:27 +09:00
KOBAYASHI Shuji c8f904b7f5 Fix 0.0 and -0.0 handling.
Fix the following issue:

    Good:
    $ bin/mruby -e 'p(-0.0)' #=> "-0"

    Bad:
    $ bin/mruby -e 'a=0.0; p(-0.0)' #=> "0"
2019-01-06 23:05:13 +09:00
Yukihiro "Matz" Matsumoto 89c79e56c5 Merge pull request #4216 from shuujii/add-assert_same
Add `assert_same` and `assert_not_same`
2019-01-06 20:59:22 +09:00
KOBAYASHI Shuji 6f395a58d2 Add assert_same and assert_not_same 2019-01-05 20:41:09 +09:00
Yukihiro "Matz" Matsumoto d45a6d8363 Merge pull request #4215 from shuujii/integrate-float.rb-into-numeric.c
Integrate mrblib/float.rb into src/numeric.c
2019-01-04 20:49:42 +09:00
KOBAYASHI Shuji b30ca87bd0 Integrate mrblib/float.rb into src/numeric.c
- Avoid hack for `MRB_WITHOUT_FLOAT` in build scripts
- Avoid runtime dispatch for `MRB_WITHOUT_FLOAT`
2019-01-04 20:31:05 +09:00
Yukihiro "Matz" Matsumoto 1c574b065d Remove mrb_ prefix from static functions in mruby-range-ext; #4213 2019-01-04 14:46:17 +09:00
Yukihiro "Matz" Matsumoto 53d87c59c0 Remove unused local variable n in range_initialize; #4213 2019-01-04 14:42:47 +09:00
Yukihiro "Matz" Matsumoto 1e7d6890a5 Merge pull request #4210 from dearblue/enum-chain
Add enumerator chain feature (CRuby-2.6 compatible)
2019-01-04 14:39:20 +09:00
Yukihiro "Matz" Matsumoto 1bf6c84682 Merge pull request #4213 from shuujii/range-rafactor
range: Refactor range.h/range.c
2019-01-04 14:39:04 +09:00
Yukihiro "Matz" Matsumoto 2a9ccf2449 Merge pull request #4211 from dearblue/proc-composition
Add proc composition feature (CRuby-2.6 compatible)
2019-01-04 14:32:19 +09:00
Yukihiro "Matz" Matsumoto acb1fdc79f Merge pull request #4212 from shuujii/pack-remove-float-check
pack: Remove redundant float check in pack_utf8()
2019-01-04 14:27:58 +09:00
KOBAYASHI Shuji eb216fc858 range: Refactor range.h/range.c
Functions order, name, linkage and so on.
2019-01-03 20:09:41 +09:00
KOBAYASHI Shuji 668d632c6e pack: Remove redundant float check in pack_utf8()
The argument is converted to fixnum before calling.
2019-01-03 19:11:30 +09:00
dearblue f392337e10 Add test for Enumerator::Chain 2019-01-03 18:16:26 +09:00
dearblue fc20d0186d Add test for #<< and #>> for Proc and Method class 2019-01-03 18:16:26 +09:00
dearblue a98359faa7 Add enumerator chain feature (CRuby-2.6 compatible)
- Enumerator::Chain
  - Enumerable#chain
  - Enumerable#+
2019-01-03 18:16:26 +09:00
dearblue 9a9e12a129 Add proc composition feature (CRuby-2.6 compatible)
- Proc#<< and Proc#>>
  - Method#<< and Method#>>
2019-01-03 18:16:26 +09:00
Yukihiro "Matz" Matsumoto cca19532c5 Remove Kernel#class_defined? which is not available in CRuby; #3829 2019-01-03 11:34:35 +09:00
Yukihiro "Matz" Matsumoto f9d89e3fa5 mruby-inline-struct to support MRB_WITHOUT_FLOAT. 2019-01-03 11:29:10 +09:00
Yukihiro "Matz" Matsumoto 3e59f25eef Merge pull request #4208 from shuujii/io-skip-tty-test
io: Skip TTY test for environments that TTY device is unavailable.
2019-01-02 11:41:57 +09:00
Yukihiro "Matz" Matsumoto 4ffc280372 Merge pull request #4209 from shuujii/range-embed-edges-in-rrange
range: Embed edges in RRange on boxing environment.
2019-01-02 11:40:32 +09:00
KOBAYASHI Shuji ff0ab552d0 io: Skip TTY test for environments that TTY device is unavailable.
e.g. GitLab CI
2019-01-01 19:25:12 +09:00
KOBAYASHI Shuji 648b57620a range: Embed edges in RRange on boxing environment.
[Breaking changes]

Developers must use following APIs for accessing attributes of RRange
because RRange structure depends on boxing setting.

- mrb_range_beg
- mrb_range_end
- mrb_range_excl_p
2019-01-01 15:35:56 +09:00
Yukihiro "Matz" Matsumoto c6f9a09e39 Merge pull request #4207 from shuujii/use-__send__-instead-of-send
Use `__send__` instead of `send` in a Range test.
2019-01-01 11:24:54 +09:00
KOBAYASHI Shuji 4da687a6c3 Use __send__ instead of send in a Range test.
This assertion is accidentaly passed because `send` was removed from mruby
core so `NoMethodError` is raised and `NoMethodError` is subclass of
`NameError`.
2019-01-01 09:38:58 +09:00
Yukihiro "Matz" Matsumoto b04506cdcc Should not check non-node value to void_expr_error; fix #4203
This is also a reason for #4192 as well.
2018-12-31 12:52:27 +09:00
Yukihiro "Matz" Matsumoto 23ca1dcb4e Merge pull request #4206 from shuujii/enumerator-refine-accessor
mruby-enumerator: Refine accessors (obj/meth/args/fib).
2018-12-31 11:22:11 +09:00
Yukihiro "Matz" Matsumoto a5ad768cac Merge pull request #4204 from shuujii/fix-yacc-running-multiple-times
Fix Yacc running multiple times.
2018-12-31 11:21:11 +09:00
KOBAYASHI Shuji bc03650c6a mruby-enumerator: Refine accessors (obj/meth/args/fib).
- `fib=` writer is not used.
- All accessors are used as public (e.g. in `initialized_copy`).
2018-12-30 11:30:14 +09:00
KOBAYASHI Shuji 482b2ea01e Use each_with_object instead of reduce.
For fix Codacy issue.
2018-12-30 11:16:00 +09:00
KOBAYASHI Shuji ce5e45443e Fix Yacc running multiple times.
Example:

  $ MRUBY_CONFIG=<(echo 'MRuby::Build.new{toolchain(:gcc);gem(core:"mruby-bin-mruby");enable_test}') ./minirake

  Before:

    ...
    CC    build/host/mrbgems/gem_init.c -> build/host/mrbgems/gem_init.o
    YACC  mrbgems/mruby-compiler/core/parse.y -> build/host/mrbgems/mruby-compiler/core/y.tab.c
    YACC  mrbgems/mruby-compiler/core/parse.y -> build/host/mrbgems/mruby-compiler/core/y.tab.c
    YACC  mrbgems/mruby-compiler/core/parse.y -> build/host/mrbgems/mruby-compiler/core/y.tab.c
    YACC  mrbgems/mruby-compiler/core/parse.y -> build/host/mrbgems/mruby-compiler/core/y.tab.c
    CC    build/host/mrbgems/mruby-compiler/core/y.tab.c -> build/host/mrbgems/mruby-compiler/core/y.tab.o
    CC    build/host/mrbgems/mruby-compiler/core/y.tab.c -> build/host/mrbgems/mruby-compiler/core/y.tab.o
    CC    build/host/mrbgems/mruby-compiler/core/y.tab.c -> build/host/mrbgems/mruby-compiler/core/y.tab.o
    CC    build/host/mrbgems/mruby-compiler/core/y.tab.c -> build/host/mrbgems/mruby-compiler/core/y.tab.o
    AR    build/host/lib/libmruby_core.a
    ...

  After:

    ...
    CC    build/host/mrbgems/gem_init.c -> build/host/mrbgems/gem_init.o
    YACC  mrbgems/mruby-compiler/core/parse.y -> build/host/mrbgems/mruby-compiler/core/y.tab.c
    CC    build/host/mrbgems/mruby-compiler/core/y.tab.c -> build/host/mrbgems/mruby-compiler/core/y.tab.o
    AR    build/host/lib/libmruby_core.a
    ...
2018-12-29 10:40:06 +09:00
Yukihiro "Matz" Matsumoto 37d795dec7 Revert "Simplify full-core.gembox"
This reverts commit e20d652f22.
This change cannot handle hidden dependency between `mruby-print` and
`mruby-sprintf`; ref #4202
2018-12-25 23:17:10 +09:00
Yukihiro "Matz" Matsumoto f2b48875a4 Merge pull request #4201 from take-cheeze/patch-2
Fix `$rake_root_fiber` checking
2018-12-25 18:44:15 +09:00
Yukihiro "Matz" Matsumoto 2216fb2895 Merge pull request #4202 from shuujii/simplify-full-core-gembox
Simplify full-core.gembox
2018-12-25 18:43:45 +09:00
KOBAYASHI Shuji e20d652f22 Simplify full-core.gembox
Dependencies order is auto detected.
2018-12-25 15:23:05 +09:00
Takeshi Watanabe 5b5e54d38e Fix $rake_root_fiber checking.
https://github.com/mruby/mruby/pull/4101#pullrequestreview-187752352
2018-12-25 14:37:32 +09:00
Yukihiro "Matz" Matsumoto 45e8cb47ea Merge pull request #4200 from shuujii/add-test-dependency-for-mruby
mruby-bin-mruby: Add test dependency.
2018-12-25 09:55:32 +09:00
KOBAYASHI Shuji 1f91482585 mruby-bin-mruby: Add test dependency.
`Kernel#p` etc are used.
2018-12-25 09:47:28 +09:00
Yukihiro "Matz" Matsumoto ecd2bcc9ae Merge pull request #4199 from shuujii/refine-desc-for-rake-test
Refine description for rake test tasks.
2018-12-24 16:02:57 +09:00
KOBAYASHI Shuji 96bea076ec Refine description for rake test tasks.
Before:
    $ rake -T test
    rake test_test  # run all mruby tests

After:
    $ rake -T test
    rake test  # run all mruby tests
2018-12-24 12:12:10 +09:00
Yukihiro "Matz" Matsumoto c34aa8a63e Merge pull request #4197 from shuujii/suppress-struct-initializer-warn
Suppress a struct initializer warning
2018-12-23 22:26:55 +09:00
Yukihiro "Matz" Matsumoto 2fbea74de5 Merge pull request #4198 from dearblue/missing-macros
Suppress missing macro warns
2018-12-23 22:18:07 +09:00
dearblue 0bfeefad2a Suppress _MSC_VER warns for mingw32 2018-12-23 17:36:06 +09:00
dearblue 027f4ded34 Suppress TARGET_OS_IPHONE warns 2018-12-23 17:24:16 +09:00
dearblue be980e9a7a Suppress __FreeBSD_version warns for FreeBSD 2018-12-23 17:23:51 +09:00
dearblue 49cce74c1a Suppress __STDC_VERSION__ warns for C++ 2018-12-23 17:22:59 +09:00
KOBAYASHI Shuji b0dc163b5d Suppress a struct initializer warning
Suppress a compiler (clang) warning bellow:

    src/vm.c:104:38: warning: suggest braces around initialization of
        subobject [-Wmissing-braces]
      const mrb_value mrb_value_zero = { 0 };
                                         ^
                                         {}
2018-12-23 14:23:44 +09:00
Yukihiro "Matz" Matsumoto f6c07b8835 Merge pull request #4196 from dearblue/add-Wundef-cflags
Append cflags for undefined macro
2018-12-22 22:49:14 +09:00
Yukihiro "Matz" Matsumoto a154d657ae Merge pull request #4194 from shuujii/mirb-drop-dependency-on-mruby-print
mirb: drop dependency on mruby-print in a test
2018-12-22 22:47:27 +09:00
Yukihiro "Matz" Matsumoto 30dae4742b Merge pull request #4195 from dearblue/fix-byteorder
Fix byte order
2018-12-22 22:47:03 +09:00
dearblue 129a804136 Append cflags for undefined macro 2018-12-22 21:58:58 +09:00
dearblue b7a832bf4f Define byte order macros, if not defined it and there are alternatives 2018-12-22 21:05:27 +09:00
dearblue e9ceb865b6 Fix MRB_ENDIAN_BIG is always defined, if byte order macro is not defined 2018-12-22 20:37:51 +09:00
KOBAYASHI Shuji 6578fec779 mirb: drop dependency on mruby-print in a test 2018-12-22 17:26:11 +09:00
Yukihiro "Matz" Matsumoto 281d0ff4ea Merge pull request #4193 from dearblue/fix-assert-variable
Fix undefined variable is using
2018-12-22 13:31:06 +09:00
dearblue 9377da9775 Fix undefined variable is using 2018-12-21 23:44:38 +09:00
Yukihiro "Matz" Matsumoto aeafce23e4 Merge branch 'cubicdaiya-feature/optimize_proc_parameters' 2018-12-21 13:00:27 +09:00
Tatsuhiko Kubo d2fb4752e2 Add test for Proc#parameters 2018-12-21 12:59:38 +09:00
Tatsuhiko Kubo cc71bd51f1 optimize Proc#parameters 2018-12-21 12:59:38 +09:00
Yukihiro "Matz" Matsumoto 94b73b1440 Add NULL pointer check before void_expr_error(); fix #4192 2018-12-21 09:35:10 +09:00
Yukihiro "Matz" Matsumoto ed2bc5d4ed Simplify MRB_ENDIAN_BIG macro definition; ref #4190
`cpp` does not raise error on undefined macro access in condition.
2018-12-21 09:28:19 +09:00
Yukihiro "Matz" Matsumoto 445c64d0ad Fixed a bug on platforms without BYTE_ORDER; ref #4190 2018-12-21 09:26:48 +09:00
Yukihiro "Matz" Matsumoto f5537912ab Define MRB_ENDIAN_BIG automatically; ref #4190
You had to define this macro on big endian platforms, but it is very
error-prone. So define the macro automatically if possible.
2018-12-21 08:57:17 +09:00
Yukihiro "Matz" Matsumoto 2fdb309e55 mruby-pack should not rely on MRB_ENDIAN_BIG macro; fix #4190
The `MRB_ENDIAN_BIG` macro is originally used for `NaN` boxing.
We cannot assume it is defined on every big endian platform (#4190
is the case). So instead of relying on untrusted `MRB_ENDIAN_BIG`, we
use `BYTE_ORDER` macro with a fallback function to check endian in
runtime.
2018-12-21 08:52:31 +09:00
Yukihiro "Matz" Matsumoto 7e35c659aa Remove things we've done in TODO file. 2018-12-21 00:47:56 +09:00
Yukihiro "Matz" Matsumoto e588e9df23 Merge pull request #4191 from dearblue/parenthesis
Fix parenthesis for macros
2018-12-19 20:40:34 +09:00
Yukihiro "Matz" Matsumoto 624b126fb6 Added Android Hack to time.c.
Android bionic defines `TIME_UTC` but does not provide `timespec_get`.
2018-12-19 13:12:30 +09:00
dearblue e19353be25 Fix macro expressions with paren 2018-12-18 23:14:26 +09:00
dearblue 14133f4057 Fix macro arguments with paren 2018-12-18 23:05:36 +09:00
Yukihiro "Matz" Matsumoto 11071b9ab1 Merge pull request #4189 from sdottaka/fix-mrb_ary_clear
Make mrb_ary_clear() function callable from C again
2018-12-17 16:29:00 +09:00
Yukihiro "Matz" Matsumoto ccc5edc60d Small refactoring of #4188 2018-12-17 16:00:22 +09:00
Yukihiro "Matz" Matsumoto e65d42644a Remove #include <mruby/khash.h> from mruby/hash.h. 2018-12-17 15:59:42 +09:00
Yukihiro "Matz" Matsumoto e690314525 Recover #to_int; ref #4177
We have removed implicit conversion to strings using `to_int`. But some
users still using `to_int` as a typical integer method, i.e. they do
string check by code like: `obj.respond_to?(:to_int)`. So we have
recovered the method.
2018-12-17 15:59:42 +09:00
Yukihiro "Matz" Matsumoto c03fa0e1b3 Recover String#to_str; ref #4177
We have removed implicit conversion to strings using `to_str`. But some
people still using `to_str` as a typical string method, i.e. they do
string check by code like: `obj.respond_to?(:to_str)`. So we have
recovered the method.
2018-12-17 15:59:42 +09:00
Yukihiro "Matz" Matsumoto ea71f1165b Merge pull request #4188 from dearblue/mrb_hash_size
Add `mrb_hash_size()` function
2018-12-17 15:59:31 +09:00
Takashi Sawanaka d8c70167f7 Make mrb_ary_clear() function callable from C again 2018-12-15 05:17:38 +09:00
dearblue 62dd4d89fc Add mrb_hash_size() function. 2018-12-14 21:41:07 +09:00
Yukihiro "Matz" Matsumoto ec812c646f Merge pull request #4185 from icm7216/fix-sleep-example
Fix sleep example
2018-12-12 13:48:58 +09:00
icm7216 59651f43ad Specify the core library instead of the external library. 2018-12-12 00:54:15 +09:00
icm7216 74c5402211 Sleep module is undefined. Remove module name. 2018-12-12 00:52:07 +09:00
Yukihiro "Matz" Matsumoto 730b925332 Merge pull request #4184 from mruby/stable
Release mruby 2.0.0
2018-12-11 11:52:33 +09:00
Yukihiro "Matz" Matsumoto 60da293d5c Avoid using floating point number for HT_SEG_INCREASE_RATIO; ref #4182 2018-12-11 10:54:47 +09:00
Hiroshi Mimaki 1c09046c13 Update release date. 2018-12-11 10:52:20 +09:00
Yukihiro "Matz" Matsumoto 265171a28c Rename ht_foreach_func to mrb_hash_foreach_func. 2018-12-11 10:41:26 +09:00
Yukihiro "Matz" Matsumoto e935d20ab5 Add mrb_ prefix to iv_foreach_func. 2018-12-11 10:39:53 +09:00
Yukihiro "Matz" Matsumoto a0df27d8e0 Add new API mrb_iv_foreach() to iterate over instance variables. 2018-12-11 09:48:15 +09:00
Yukihiro "Matz" Matsumoto f6b2e6231a Update iv_foreach() function.
* return `void` instead of `mrb_bool'.
* non zero return value from `func` breaks the loop.
* no longer remove items on negative return value from `func`.
2018-12-11 09:47:06 +09:00
Hiroshi Mimaki 716e7b815f Fixed missing comma in mruby/mirb usage. 2018-12-11 09:37:23 +09:00
Yukihiro "Matz" Matsumoto 378c728338 Update comments. 2018-12-11 09:04:08 +09:00
Yukihiro "Matz" Matsumoto c0d91a14e7 Add API function mrb_hash_foreach() to iterate over items in a hash. 2018-12-11 09:01:05 +09:00
Yukihiro "Matz" Matsumoto c23e68d32b Need to clear stack before invoking a block; fix #4181 2018-12-10 10:23:01 +09:00
take-cheeze b6850f88a1 Support lock file for git. 2018-12-06 11:47:17 +09:00
Bhargava Shastry 05b4eaac4b ossfuzz: Moved config related files to a namesake directory under ossfuzz 2018-12-05 18:06:30 +01:00
Bhargava Shastry bccf9e4a3f ossfuzz: Add fuzzing dictionary for mruby. 2018-12-05 18:00:47 +01:00
Bhargava Shastry 1d1b47044c ossfuzz: Add simple mruby compile test harness 2018-12-05 17:45:27 +01:00
Yukihiro "Matz" Matsumoto e6bad6766a Add new methods Module#{>,>=,<=>}; ref #4174 2018-12-04 08:41:09 +09:00
Yukihiro "Matz" Matsumoto d5d9cc8b62 Remove unnecessary check in Module#<; ref #4174 2018-12-04 08:40:23 +09:00
Yukihiro "Matz" Matsumoto 6ef4a5fd6b Replace RDoc <i></i> to Markdown back quotes; ref #4174 2018-12-04 08:39:44 +09:00
Yukihiro "Matz" Matsumoto 20c655dc45 Merge pull request #4174 from robfors/module_operators
Adds Module#< and Module#<=
2018-12-04 08:09:18 +09:00
Rob e300ac8e3a Adds Module#< and Module#<= 2018-12-02 20:56:47 -05:00
Hiroshi Mimaki e3ae0e4f29 Merge branch 'master' into stable 2018-11-27 09:09:20 +09:00
Yukihiro "Matz" Matsumoto 26475d0a78 Update doc/limitations.md for argument destructuring. 2018-11-25 18:03:27 +09:00
Yukihiro "Matz" Matsumoto 762f682b80 Allow destructuring in formal arguments.
e.g.
```
def m(a,(b,c),d); p [a,b,c,d]; end
m(1,[2,3],4)  # => [1,2,3,4]
```

mruby limitation:
Destructured arguments (`b` and `c` in above example) cannot be accessed
from the default expression of optional arguments and keyword arguments,
since actual assignment is done after the evaluation of those default
expressions. Thus:

```
def f(a,(b,c),d=b)
  p [a,b,c,d]
end
f(1,[2,3])
```

raises `NoMethodError` for `b` in mruby.
2018-11-25 09:07:49 +09:00
Yukihiro "Matz" Matsumoto e6b72b2121 Remove redundant rules from parse.y. 2018-11-25 07:30:32 +09:00
Yukihiro "Matz" Matsumoto 7ed9bb3bd3 Fix wrong number of arguments in Array#fetch; fix #4170 2018-11-25 06:05:07 +09:00
Yukihiro "Matz" Matsumoto e2e6554b56 Protect from exceptions raised outside of mrb_vm_run().
It can happen if signals are used (e.g. from `mruby-alarm` gem).
2018-11-25 06:05:07 +09:00
Yukihiro "Matz" Matsumoto 91bf55bbe5 Remove do { ... } while(0) hacks from MRB_TRY macros.
Because it can swallow `break` etc. if they are used in loops.
2018-11-25 06:05:07 +09:00
Hiroshi Mimaki 0711c861ca Fix mruby-socket test failure on MinGW. 2018-11-22 09:49:00 +09:00
Yukihiro "Matz" Matsumoto b158f26f0c Merge pull request #4168 from robfors/doc
Add documentation to mrb_load_irep
2018-11-21 12:16:07 +09:00
Rob Fors c9a66d4c41 Update documentation to mrb_load_irep 2018-11-20 21:27:03 -05:00
Yukihiro "Matz" Matsumoto 68c5384830 Update version number; fix #4165 2018-11-20 10:43:34 +09:00
Yukihiro "Matz" Matsumoto ec19c34a20 Fixed a bug in mirb heredoc handling; fix #3989 2018-11-20 10:39:34 +09:00
Yukihiro "Matz" Matsumoto f1eeaad84a Stop special treating of \r in the lexer; fix #4132 2018-11-20 09:35:38 +09:00
Yukihiro "Matz" Matsumoto 86d102350b Restrict total recursion number of ecall(); fix #3789 2018-11-20 09:14:34 +09:00
Yukihiro "Matz" Matsumoto afd46eccd1 Add -fpermissive to C++ compiler flags. 2018-11-19 17:11:59 +09:00
Yukihiro "Matz" Matsumoto 65a2c2082d Call mrb_str_to_str from mrb_string_value_ptr for compatibility. 2018-11-19 17:11:19 +09:00
Yukihiro "Matz" Matsumoto 53e2df3e93 Restore mrb_string_type function for compatibility. 2018-11-19 16:13:26 +09:00
Yukihiro "Matz" Matsumoto c308a149f0 Add Hash type check for OP_KARG and OP_KEY_P; ref #4166 2018-11-19 15:35:59 +09:00
Yukihiro "Matz" Matsumoto 423f872c84 Need to keep rooms for empty splat; fix #4166 2018-11-19 15:26:19 +09:00
Yukihiro "Matz" Matsumoto 87ffab5713 Adjust codedump output format; ref #4166 2018-11-19 15:25:42 +09:00
Yukihiro "Matz" Matsumoto 9516731329 Use type checking mrb_to_str instead of converting mrb_str_to_str. 2018-11-19 12:08:28 +09:00
Yukihiro "Matz" Matsumoto c022e4643f Avoid assignments from type checking String#__to_str. 2018-11-19 12:08:28 +09:00
Yukihiro "Matz" Matsumoto 610bcc88c2 Removed to_hash conversion method. 2018-11-19 12:08:28 +09:00
Yukihiro "Matz" Matsumoto 698f5f707c Removed to_ary conversion method. 2018-11-19 12:08:28 +09:00
Yukihiro "Matz" Matsumoto 5bbcea9b3b Removed try_convert method from Array and Hash. 2018-11-19 12:08:28 +09:00
Yukihiro "Matz" Matsumoto b5d43a16a3 Removed String#try_convert method from mruby-string-ext gem.
Because `try_convert` method rarely used in production. For mruby users,
we have `__to_str` utility method to check string type.
2018-11-19 12:08:28 +09:00
Yukihiro "Matz" Matsumoto ff08856fe3 Remove implicit conversion using to_str method; fix #3854
We have added internal convenience method `__to_str` which
does string type check.

The issue #3854 was fixed but fundamental flaw of lack of stack
depth check along with fibers still remains. Use `MRB_GC_FIXED_ARENA`
for workaround.
2018-11-19 12:05:46 +09:00
Yukihiro "Matz" Matsumoto afca99a40b Remove implicit conversion using to_int method.
The ISO standard does not include implicit type conversion using
`to_int`. This implicit conversion often causes vulnerability.
There will be no more attacks like #4120.

In addition, we have added internal convenience method `__to_int` which
does type check and conversion (from floats).
2018-11-19 11:28:51 +09:00
Yukihiro "Matz" Matsumoto 426c1f9e0b fix non-ASCII comment. 2018-11-19 11:28:03 +09:00
Yukihiro "Matz" Matsumoto 0a0cc5a217 Check method existence for Enumerators; fix #3920
The issue #3920 was fixed but the fundamental flaw of lack of stack
depth check along with fibers still remains, even though it's not
easy to cause the issue.  Use `MRB_GC_FIXED_ARENA` to avoid the issue
for workaround.

After this patch, `obj.to_enum` raises `ArgumentError` if the object
does not respond to the enumerating method. This is incompatible to
CRuby but I think this behavior is better and CRuby should be updated
to behave like this.
2018-11-19 10:57:07 +09:00
Yukihiro "Matz" Matsumoto 31a961acf1 The current context may be changed in mrb_vm_exec; ref #3668 #4104 2018-11-19 09:50:31 +09:00
Yukihiro "Matz" Matsumoto cab6b0f39b Protect Fiber from GC in ecall(); fix #4104 2018-11-19 09:49:20 +09:00
Yukihiro "Matz" Matsumoto 25d390d6cc Improve Hash table using variable sized segments. 2018-11-19 09:30:15 +09:00
Yukihiro "Matz" Matsumoto 180b73fec4 The key or value object could be reclaimed by GC; fix #4164
The GC may occur between `sg_shift` and `mrb_assoc_new`, in which
case `key` and `value` could be freed even tough they are still alive.

The issue is found and fixed by https://hackerone.com/hexodus
2018-11-16 01:04:57 +09:00
Yukihiro "Matz" Matsumoto 0a022f7b8d The saved pc from ERR_PC_SET was wrong; fix #4138
The saving `pc` position should be beginning of the instruction.
But after `mruby 2.0` byte code modification, the `pc` variable
points the beginning of the next instruction. We save the previous
position in a local variable `pc0`.
2018-11-15 23:34:32 +09:00
Yukihiro "Matz" Matsumoto 418ad65db4 Fixed a bug in continuous read of target files; ref #4138
Line number information in a compiled file was wrong.
2018-11-15 23:34:32 +09:00
Yukihiro "Matz" Matsumoto 7e3e8d8ed5 Shrink file name table size to uint16_t; ref #4138 2018-11-15 23:34:32 +09:00
Yukihiro "Matz" Matsumoto faf51f82c7 Rename local variables in mrb_debug_info_append_file 2018-11-15 23:34:32 +09:00
Yukihiro "Matz" Matsumoto 56db3cf3eb Simplify argument parsing; ref #4161 2018-11-15 21:01:56 +09:00
Yukihiro "Matz" Matsumoto f39f428ed4 Silence -fsanitize=undefined warning in src/enum.c; fix #4161 2018-11-15 21:01:56 +09:00
Yukihiro "Matz" Matsumoto 61f49690e4 Remove filename&lines from mrb_irep struct.
This patch slightly reduce memory consumption (2% for my test).
2018-11-15 21:01:56 +09:00
Yukihiro "Matz" Matsumoto 1bea1e2050 Small renaming refactor in dump.c 2018-11-15 19:24:45 +09:00
Yukihiro "Matz" Matsumoto 485955eccc String#{squeeze,delete,count} to use bitmap for matching; ref #4163 2018-11-15 04:51:27 +09:00
Yukihiro "Matz" Matsumoto 4550f4e381 Pattern length may overflow uint16_t; fixed #4163
The issue is reported by `https://hackerone.com/dgaletic`.
2018-11-15 02:03:54 +09:00
Yukihiro "Matz" Matsumoto c3188cac43 Merge pull request #4160 from mimaki/wrong-negative-float-in-mrb
Wrong pool data length for negative floating value in a mrb file.
2018-11-07 18:22:13 +09:00
Hiroshi Mimaki 7d7f9feee7 Wrong pool data length for negative floating value in a mrb file. 2018-11-07 17:20:18 +09:00
Yukihiro "Matz" Matsumoto d25ebec988 Fixed wrong ArgumentError with keyword arguments; fix #4159 2018-11-05 21:52:17 +09:00
Yukihiro "Matz" Matsumoto d47003aea4 Fixed a bug in argument number check with kwargs; fix #4159 2018-11-05 07:44:25 +09:00
Yukihiro "Matz" Matsumoto d9e2532552 Remove reserved symbols for now.
It should be done by planned embedded symbols.
2018-11-02 22:58:12 +09:00
Yukihiro "Matz" Matsumoto 9c5e28646b Merge pull request #4151 from take-cheeze/remove_op_symidx
Reduce instruction size
2018-11-02 22:37:47 +09:00
Yukihiro "Matz" Matsumoto 788e4388f8 Merge branch 'take-cheeze-fix_dump_load'
Since our new VM instruction is byte based, there's no need to endian
conversion of instruction sequences.
2018-11-02 20:58:15 +09:00
take-cheeze 57a435aa1d Suppress warning 2018-11-02 15:49:34 +09:00
take-cheeze 659c680a5b Fix dump and load with endianess 2018-11-02 15:47:28 +09:00
Yukihiro "Matz" Matsumoto 0419f07915 Add NULL checks for mrb->ci and proc->upeer; #4024 2018-11-02 14:57:03 +09:00
Yukihiro "Matz" Matsumoto f2084f300b Add tests for empty patterns for tr and count; #4156 #4157 2018-11-02 08:58:21 +09:00
Yukihiro "Matz" Matsumoto 8e59695625 Empty pattern string for String#tr should remove characters; fix #4157 2018-11-02 08:55:17 +09:00
Yukihiro "Matz" Matsumoto 65b04066a2 Empty pattern string can generate TR_UNINITIALIZED pattern; fix #4156 2018-11-02 08:54:24 +09:00
Yukihiro "Matz" Matsumoto 7ad53273a2 Silence Appveyor's VC compilation warnings. 2018-11-01 22:52:12 +09:00
Yukihiro "Matz" Matsumoto d68da042b3 The env object referenced from fibers may be freed; fix #4154
By dffa203 that reclaim `env` objects from heaps, there's more chance
for `env` objects referenced from fibers may be freed from heap pages.
2018-11-01 22:36:06 +09:00
Yukihiro "Matz" Matsumoto 830321fed5 Merge pull request #4155 from mimaki/fix-4153
Fixed a bug in INIT_DISPATCH for non direct threading; fix #4153
2018-11-01 22:31:31 +09:00
Hiroshi Mimaki 73727aeb50 Fixed a bug in INIT_DISPATCH for non direct threading; fix #4153 2018-11-01 11:10:47 +09:00
Yukihiro "Matz" Matsumoto 31eb5f4e1b Merge pull request #4152 from take-cheeze/build_debug_flag
Add debug flag to `MRuby::Build`
2018-10-30 09:04:35 +09:00
Yukihiro "Matz" Matsumoto cca5e0977c VS 2017 C does not understand inline struct initialization; ref #4153 2018-10-30 09:01:12 +09:00
take-cheeze 08bd095446 Add debug flag to MRuby::Build 2018-10-29 20:10:03 +09:00
take-cheeze 6a6586ca84 Reduce unnecessary symbol table entry 2018-10-29 19:40:33 +09:00
take-cheeze 486c9d902d Fix codedumper 2018-10-29 19:35:31 +09:00
take-cheeze 7d51a7bbf5 Fix document 2018-10-29 19:34:56 +09:00
take-cheeze 557805da07 Fix operator 2018-10-29 19:29:43 +09:00
take-cheeze 68714ab648 Fix SEGV 2018-10-29 19:26:00 +09:00
take-cheeze e022080390 Define null symbol 2018-10-29 19:22:53 +09:00
take-cheeze 3248de83b6 Reduce instruction size 2018-10-29 19:17:05 +09:00
Yukihiro "Matz" Matsumoto eebb56713e Merge pull request #4149 from take-cheeze/static_tr_pattern
Keep `tr_pattern` static if possible
2018-10-29 15:34:07 +09:00
Yukihiro "Matz" Matsumoto ae5463c9e4 Merge pull request #4148 from take-cheeze/rename_libmruby_stuff
Rename `MRuby::Build#libmruby` stuff to avoid confusion
2018-10-29 15:13:24 +09:00
Yukihiro "Matz" Matsumoto 63fade1396 Merge pull request #4147 from take-cheeze/add_missing_dep
Add missing dependency of source code generator
2018-10-29 15:12:07 +09:00
Yukihiro "Matz" Matsumoto a7e42a2024 Merge pull request #4146 from take-cheeze/sup_sleep_warn
Suppress sleep test script warning
2018-10-29 15:11:07 +09:00
Yukihiro "Matz" Matsumoto c7327c84dc Merge pull request #4145 from take-cheeze/sort_test_rbfiles
Sort test script list too
2018-10-29 15:10:36 +09:00
take-cheeze b37b312081 Rename libmruby stuff to avoid confusion 2018-10-29 14:07:16 +09:00
take-cheeze c240aeada9 Add missing dependency of source code generator 2018-10-29 13:58:57 +09:00
take-cheeze 1b185f08e7 Suppress sleep test script warning 2018-10-29 13:58:25 +09:00
take-cheeze ac512e9d9f Sort test script list too 2018-10-29 13:57:41 +09:00
take-cheeze 52d55e6069 Keep tr_pattern static 2018-10-29 13:21:36 +09:00
Yukihiro "Matz" Matsumoto fa33a4d75a We need no write barrier here; ref #4143 2018-10-29 12:01:27 +09:00
Yukihiro "Matz" Matsumoto 3dc3643e34 Marking from terminated fibers are not needed; ref #4143
The old condition marks the top-level callinfo even after the
fiber is terminated.
2018-10-29 11:58:10 +09:00
Yukihiro "Matz" Matsumoto 34872e90d4 Re-implement Array#_inspect and Hash#_inspect without blocks.
To reduce the env object allocation; ref #4143
2018-10-29 11:55:49 +09:00
Yukihiro "Matz" Matsumoto dffa203d07 Need to mark shared env objects as MRB_TT_FREE; fix #4143
The following code mistakenly exits from the function without marking
the env object as `MRB_TT_FREE`.

``` ruby
      if (MRB_ENV_STACK_SHARED_P(e)) {
        /* cannot be freed */
        return; // <- should be `break`
      }
```
2018-10-29 11:51:04 +09:00
Yukihiro "Matz" Matsumoto 7ff84789c3 Add argument check to Array#clear; fix #4144 2018-10-29 10:12:10 +09:00
Yukihiro "Matz" Matsumoto b3a181aaa1 Fixed a bug in processing OP_EXT? instructions.
fix haconiwa/haconiwa#171
2018-10-23 21:10:03 +09:00
Yukihiro "Matz" Matsumoto 80b5a56f51 Need to freeze string keys. 2018-10-20 19:02:12 +09:00
Yukihiro "Matz" Matsumoto e89676a6ec Merge pull request #4142 from iij/mergesort
replace quicksort with mergesort.
2018-10-18 13:02:11 +08:00
Tomoyuki Sahara 91444c4747 replace quicksort with mergesort. 2018-10-18 13:07:47 +09:00
Yukihiro "Matz" Matsumoto fdd5ce8fac Fixed a bug caused by too much optimization; fix #4137 2018-10-13 00:31:13 +09:00
Yukihiro "Matz" Matsumoto d2313aebd6 Fixed broken stack consistency; fix #4135 2018-10-12 23:26:14 +09:00
Yukihiro "Matz" Matsumoto e5f160dc7e Should not compare undef (deleted) key in hashes; fix #4136 2018-10-12 19:00:45 +09:00
Yukihiro "Matz" Matsumoto ab0f4db688 Call uniq! for each union processing in Array#union. 2018-10-12 19:00:14 +09:00
Yukihiro "Matz" Matsumoto 249fef7dc4 Add NULL check in sg_compact(); fix #4139 2018-10-12 08:30:57 +09:00
Yukihiro "Matz" Matsumoto 82e00ce60f Hash#delete should return the deleted value; fix #4133 2018-10-12 08:25:54 +09:00
Yukihiro "Matz" Matsumoto a690aef8d3 Merge pull request #4131 from junaruga/feature/ci-refactoring
Refactor .travis.yml to remove duplicated env: MRUBY_CONFIG.
2018-10-05 22:10:51 +09:00
Jun Aruga f38e6c63e9 Refactor .travis.yml to remove duplicated env: MRUBY_CONFIG. 2018-10-05 14:15:33 +02:00
Yukihiro "Matz" Matsumoto 8392578216 Fixed SEGV from eval called form top-level mrb_funcall(); fix #4028 2018-10-02 17:26:43 +09:00
Yukihiro "Matz" Matsumoto e6841abad6 Fixed a String#squeeze bug in handling iso-8859-1 strings; ref #4127 2018-09-27 21:43:35 +09:00
Yukihiro "Matz" Matsumoto 54ec08c7f1 Implement Hash#rehash in C using sg_compact(). 2018-09-26 23:09:48 +09:00
Yukihiro "Matz" Matsumoto d78acc7afe Add index to larger segment lists for performance 2018-09-26 23:09:48 +09:00
Yukihiro "Matz" Matsumoto 8ffd4e47fb Use mrb_undef_value for delete mark instead of shifting Hash entry table.
That means entry table should be compacted periodically by `sg_compact()`.
2018-09-26 23:09:48 +09:00
Yukihiro "Matz" Matsumoto e8dcfe1745 Use segmented list to implement Hash [Experimental]
I know it's not hash at all, but reduce memory consumption.
2018-09-26 12:55:22 +09:00
Yukihiro "Matz" Matsumoto 01c2f59e14 Revert "Fix comparisons in str_squeeze."
This reverts commit 7b04fcd092.
The issue was addressed by 9e3cbaa. No longer needed.
2018-09-26 12:35:25 +09:00
Yukihiro "Matz" Matsumoto 9e3cbaaacd Avoid using memmove() for performance; fix #4130 2018-09-26 12:20:37 +09:00
Yukihiro "Matz" Matsumoto 87ce740168 Disambiguate block braces. 2018-09-26 12:17:38 +09:00
Yukihiro "Matz" Matsumoto fb49a94314 Rename tr_pattern_free() to tr_free_pattern(). 2018-09-26 12:17:38 +09:00
Yukihiro "Matz" Matsumoto 78195eb2ae Small refactoring in vm.c 2018-09-26 12:17:38 +09:00
Yukihiro "Matz" Matsumoto 09a99154c0 Merge pull request #4128 from take-cheeze/patch-1
Fix memory leak in `mrb_str_count`
2018-09-25 12:03:26 +09:00
Takeshi Watanabe 67897195de Fix leak in mrb_str_count 2018-09-25 11:48:59 +09:00
Yukihiro "Matz" Matsumoto 152e8c5bb2 Merge pull request #4127 from clayton-shopify/fix-str-squeeze-comparisons
Fix comparisons in str_squeeze.
2018-09-25 11:43:41 +09:00
Daniel Varga 4d5e3e1e63 Fix minor typos (#4126) 2018-09-25 09:14:01 +09:00
Clayton Smith 7b04fcd092 Fix comparisons in str_squeeze. 2018-09-24 18:16:12 -04:00
sbsoftware 8fc56f062e Add compiler flag to disable direct threading (#4075)
* Add option to disable direct threading

* Prepend MRB_ to option name
2018-09-21 11:22:53 +09:00
Yukihiro "Matz" Matsumoto 9bd2a3b5d9 Fixed a top-level local variable bug in mirb.
`OP_STOP` returned a wrong value.
2018-09-21 00:51:29 +09:00
Yukihiro "Matz" Matsumoto 346f154ece Implement String#delete and #delete!; ref #4086
mruby restriction:
In mruby, `String#delete` only takes single pattern argument.
2018-09-21 00:03:07 +09:00
Yukihiro "Matz" Matsumoto 58f7f2361a Implement String#count; ref #4086
mruby restriction:
In mruby, `String#count` does not take multiple pattern arguments,
but only one pattern.
2018-09-21 00:03:07 +09:00
Yukihiro "Matz" Matsumoto 68523b4ec4 Add String#squeeze and #squeeze!; ref #4086
mruby restriction:
`String#squeeze` can take more than 1 pattern arguments in CRuby,
in that case, the intersection of patterns will be used to match.
But in mruby, it doesn't take multiple patterns.
2018-09-21 00:03:07 +09:00
Yukihiro "Matz" Matsumoto c0ae8a96a1 Add String#tr_s and String#tr_s!; ref #4086 2018-09-21 00:03:07 +09:00
Yukihiro "Matz" Matsumoto 58ba38fe1e Add String#tr and #tr! to mruby-string-ext gem; fix #4086
This patch is based on `mruby/c` implementation by Hirohito Higashi.

We might need to add `#tr_s`, `#squeeze` and `#delete` as well.
Adding them should not be too hard using functions we implemented here.
2018-09-21 00:03:07 +09:00
Yukihiro "Matz" Matsumoto f23f2bbdad Implement Array#union which is introduced in Ruby2.6. 2018-09-21 00:01:48 +09:00
Yukihiro "Matz" Matsumoto dd346be99a Improve performance of Array#uniq!. 2018-09-20 23:56:53 +09:00
Yukihiro "Matz" Matsumoto 5ec5a41fd2 Merge branch 'dearblue-assign-anon-class-name' 2018-09-20 13:58:36 +09:00
Yukihiro "Matz" Matsumoto 159575f630 Renamed is_namespace() to namespace_p(). 2018-09-20 13:57:43 +09:00
Yukihiro "Matz" Matsumoto 505e601730 Revert "Add MRB_IMPROVE_META_PROGRAMMING configuration"
This reverts commit 1997fcf98f.
It became the default behavior.
2018-09-20 13:53:55 +09:00
Yukihiro "Matz" Matsumoto d192a52edb Merge branch 'assign-anon-class-name' of https://github.com/dearblue/mruby into dearblue-assign-anon-class-name 2018-09-20 13:50:16 +09:00
Yukihiro "Matz" Matsumoto 3a9caad8eb Move Symbol#to_proc to the core from mruby-symbol-ext gem.
Even though `Symbol#to_proc` is not included in ISO standard, the
`some_method(&:method_name)` is used very widely and convenient.
So we moved it to the core.
2018-09-20 13:47:29 +09:00
Yukihiro "Matz" Matsumoto 19d3bb2d90 Make #to_h to take a block; [ruby-core:89088] 2018-09-20 13:47:29 +09:00
Yukihiro "Matz" Matsumoto fa5f5954da Merge pull request #4112 from dearblue/fix-outer-module-name
Fix outer module name
2018-09-20 13:47:16 +09:00
Yukihiro "Matz" Matsumoto b7e5c86612 Allow nested gemboxes; fix #4124 2018-09-20 11:10:34 +09:00
Yukihiro "Matz" Matsumoto 3820ef791f Small refactoring in mruby-hash-ext. 2018-09-20 09:07:24 +09:00
Yukihiro "Matz" Matsumoto 8b43754644 Use mrb_to_flo() to check return value from to_f; fix #4115
The ISO standard does not include implicit type conversion using
`to_int`, `to_str` and sometimes `to_f`. For the compactness of the
mruby implementation, maybe we should remove those implicit conversion
from mruby.
2018-09-18 09:35:09 +09:00
Yukihiro "Matz" Matsumoto e9b1d9dc2f Array size may be changed in mrb_get_args() reentry.
fix #4116; fix #4117; fix #4118; fix #4119; fix #4120
2018-09-18 07:07:43 +09:00
Yukihiro "Matz" Matsumoto 0ff1540e8b Merge pull request #4122 from blacktm/iphone-exclude-pipe-exec
Exclude pipe and exec on iOS/tvOS
2018-09-17 13:26:04 +09:00
Tom Black 82053dd945 Exclude pipe and exec on iOS/tvOS
Use of `execl()` is prohibited on these platforms
2018-09-15 13:55:11 -07:00
Yukihiro "Matz" Matsumoto ed4dbce052 fixup! Add support for iOS platforms that does not support fork; fix #4113 2018-09-16 00:58:52 +09:00
Yukihiro "Matz" Matsumoto 05595c1284 Merge pull request #4121 from clayton-shopify/fix-sprintf-overflow
Prevent signed integer overflow.
2018-09-16 00:45:55 +09:00
Yukihiro "Matz" Matsumoto 2661ac7049 Add support for iOS platforms that does not support fork; fix #4113 2018-09-16 00:41:48 +09:00
Clayton Smith 2760cea451 Prevent signed integer overflow. 2018-09-14 16:53:26 -04:00
Yukihiro "Matz" Matsumoto f93734f622 Merge pull request #4110 from dearblue/fix-typo1
Fix typo
2018-09-08 11:20:11 +09:00
dearblue 292ea06d4d Fix outer module name
example:
  a = Module.new
  a::B = Module.new
  p [a, a::B] # => [#<Module:0x801825890>, #<Class:0x801825890>::B]
              # => [#<Module:0x801825890>, #<Module:0x801825890>::B] (Fixed)
2018-09-08 10:25:30 +09:00
dearblue 5e6cd86f6e Fix to not define outer when outer is itself.
example:
  a = Class.new
  a::A = a
2018-09-07 23:56:06 +09:00
dearblue 366848996a Clear terminated space 2018-09-07 22:32:34 +09:00
dearblue 1997fcf98f Add MRB_IMPROVE_META_PROGRAMMING configuration 2018-09-07 22:32:34 +09:00
dearblue 1595e8368a Fix indent 2018-09-07 22:32:34 +09:00
dearblue 9b0ef58a48 A class/module name is now defined for meta programing 2018-09-07 22:32:34 +09:00
dearblue fd57af3ea4 Undesirable line split 2018-09-07 22:32:34 +09:00
dearblue 2a24b40d30 Not set a class/module name into anonymous class/module 2018-09-07 22:32:34 +09:00
dearblue 9da9e5eb4e Fix typo for concatenate 2018-09-07 22:32:34 +09:00
Yukihiro "Matz" Matsumoto 625976d793 Fix integer overflow issue; fix #4108
I misunderstood the return value from `snprintf()`, which is NOT number
of characters written in buffer, but the number of character the buffer
has to have to write the complete output.
2018-09-07 03:20:57 +09:00
Yukihiro "Matz" Matsumoto 3447162a4c Add a new method unpack1 to mruby-pack gem. 2018-09-07 02:16:56 +09:00
Yukihiro "Matz" Matsumoto 04f8b0431c Fix heap buffer overflow in unpack_a; fix #4103 2018-09-07 02:15:55 +09:00
Yukihiro "Matz" Matsumoto fdaec90780 Make Kernel#sleep to accept float as a duration time.
But when `MRB_WITHOUT_FLOAT` is set, there's no way to sleep for
sub seconds. So mruby specific `usleep` is provided.
2018-09-06 23:42:05 +09:00
Yukihiro "Matz" Matsumoto 72522f8e0e Remove Sleep module that does not exist in CRuby. 2018-09-06 23:35:32 +09:00
Yukihiro "Matz" Matsumoto 0b44e802a9 Need to check if merging hash is empty; fix #4107 2018-09-06 23:30:32 +09:00
Yukihiro "Matz" Matsumoto 4cd4c64266 Need to support multiple ** splats in argument list; fix #4106 2018-09-06 14:40:21 +09:00
Yukihiro "Matz" Matsumoto a170c1dd70 Refactored mruby-sleep gem.
* Method implementation functions made `static`.
 * Function declaration style has been changed.
 * Unnecessary header file `mrb_sleep.h` removed.
 * Used `mrb_get_args()` instead of self parsing.
 * Indentation kept untouched.
2018-09-05 14:55:49 +09:00
Yukihiro "Matz" Matsumoto 44fdd53f2e Add mruby-sleep gem to the core. 2018-09-05 13:30:14 +09:00
Yukihiro "Matz" Matsumoto b01b0d242b Free mrbc_context on exit from mruby. 2018-09-05 07:58:36 +09:00
Yukihiro "Matz" Matsumoto ade7185a2b Merge pull request #4055 from take-cheeze/verbose_bintest
Support verbose mode in bintest.
2018-09-05 07:11:23 +09:00
Yukihiro "Matz" Matsumoto 2a9525caab Add argv and argc check in OP_ENTER; fix #4102
`argv` may be retrieved from an array whose `ptr` is `NULL` when it`s
empty.
2018-09-05 07:06:25 +09:00
Yukihiro "Matz" Matsumoto 9b5910bd0f Revert "Remove top-level constant lookup; CRuby2.5"; fix #4070
This reverts commit c96def7c96.
This change was from my misunderstanding.
2018-09-04 21:19:07 +09:00
Yukihiro "Matz" Matsumoto 7592dfcf7d Need more precise constant name check.
This change was inspired by [ruby-bugs#7573]
2018-09-04 20:50:54 +09:00
Yukihiro "Matz" Matsumoto c2634e18b6 Add type casts to silence MSVC warnings. 2018-09-04 16:22:50 +09:00
Yukihiro "Matz" Matsumoto 28c50b3e90 Merge pull request #4101 from take-cheeze/fix_4085
Avoid root fiber initialization for CRuby.
2018-09-04 16:22:40 +09:00
take-cheeze 901dccb2df Avoid root fiber initialization for CRuby workaround.
closes #4085.
2018-09-04 16:18:01 +09:00
take-cheeze e6357f3baa Fix indent. 2018-09-04 16:18:01 +09:00
Yukihiro "Matz" Matsumoto 02adae167f Merge pull request #4098 from dearblue/reverse-gems-final
Reversing gems final
2018-09-04 07:26:25 +09:00
dearblue cbf2738861 Reverse gems final 2018-09-02 14:13:09 +09:00
Yukihiro "Matz" Matsumoto a657117e4e Avoid warning in MSVC compilation. 2018-09-01 17:36:35 +09:00
Yukihiro "Matz" Matsumoto 20c0c6330f Too much peephole optimization in gen_call; fix #4091
It causes trouble for safe navigation operator.
2018-09-01 17:14:54 +09:00
Yukihiro "Matz" Matsumoto b80e0ef742 Move Kernel#send to mruby-metaprog gem.
But `BasicObject#__send__` is still available from the core.
2018-09-01 11:20:30 +09:00
Yukihiro "Matz" Matsumoto 593c12a5cd Avoid NoMethodError exception from mrb_func_basic_p. 2018-09-01 11:18:12 +09:00
Yukihiro "Matz" Matsumoto 05f377dee4 Use __send__ instead of send. 2018-09-01 11:02:59 +09:00
Yukihiro "Matz" Matsumoto 0c6353aa2c Remove MRB_API from mrb_f_send which is not API. 2018-09-01 11:01:50 +09:00
Yukihiro "Matz" Matsumoto 2be42aef0f Fix ISO/JIS section numbers. 2018-09-01 09:35:46 +09:00
Yukihiro "Matz" Matsumoto 1bc1fed534 Update RITE_BINARY_FORMAT_VER and RITE_VM_VER.
The bytecode format was updated so the header version constants must be
updated as well.
2018-08-30 22:48:05 +09:00
Yukihiro "Matz" Matsumoto 50b840c9de Use mrb_ensure_hash_type() to check if an operand is a Hash; fix #4097 2018-08-30 22:30:36 +09:00
Yukihiro "Matz" Matsumoto f6564dd83e Add new function mrb_ensure_hash_type(); ref #4097
Unlike `mrb_check_hash_type()` that returns `nil` if the argument is
not a `Hash`, `mrb_ensure_hash_type()` raises a `TypeError` exception.
2018-08-30 22:30:36 +09:00
Yukihiro "Matz" Matsumoto e471d37ca5 Separate meta-programming features to mruby-metaprog gem.
We assume meta-programming is less used in embedded environments.
We have moved following methods:

 * Kernel module
   global_variables, local_variables, singleton_class,
   instance_variables, instance_variables_defined?, instance_variable_get,
   instance_variable_set, methods, private_methods, public_methods,
   protected_methods, singleton_methods, define_singleton_methods

 * Module class
   class_variables, class_variables_defined?, class_variable_get,
   class_variable_set, remove_class_variable, included_modules,
   instance_methods, remove_method, method_removed, constants

 * Module class methods
   constants, nesting

Note:
Following meta-programming methods are kept in the core:

 * Module class
   alias_method, undef_method, ancestors, const_defined?, const_get,
   const_set, remove_const, method_defined?, define_method

 * Toplevel object
   define_method

`mruby-metaprog` gem is linked by default (specified in default.gembox).
When it is removed, it will save 40KB (stripped:8KB) on x86-64
environment last time I measured.
2018-08-30 22:30:36 +09:00
Yukihiro "Matz" Matsumoto 75a01af710 Remove consequent OP_RETURN by peephole optimization. 2018-08-30 01:23:17 +09:00
Yukihiro "Matz" Matsumoto 5addd5db4a Need to clear mrb->c->cibase->ridx (toplevel ridx) at L_STOP; fix #4092
This problem only appears when `mrb` executed multiple times (i.e. `mirb`)
2018-08-30 01:20:59 +09:00
Yukihiro "Matz" Matsumoto 500bd38dfe uint16_t is too small for reference count; fix #4093
Use `uint32_t` instead. Theoretically `uint32_t` can overflow as well,
but I think it is sufficient size for embeddable Ruby VM.
2018-08-30 00:29:35 +09:00
Yukihiro "Matz" Matsumoto 2c93e4a0a8 The operand of OP_ARYDUP may not be an array; fix #4094
This commit also fix #4096.
2018-08-30 00:29:35 +09:00
Yukihiro "Matz" Matsumoto f76cc483d5 Fix off-by-one error in OP_EPUSH and OP_ONERR; fix #4095 2018-08-29 23:59:20 +09:00
Yukihiro "Matz" Matsumoto e91b6a0378 Merge pull request #4080 from 'ukrainskiysergey-node_negate_fix' 2018-08-29 13:34:02 +09:00
Yukihiro "Matz" Matsumoto 441ff45a51 Merge branch 'node_negate_fix' of https://github.com/ukrainskiysergey/mruby into ukrainskiysergey-node_negate_fix 2018-08-29 13:29:54 +09:00
Yukihiro "Matz" Matsumoto 98c759e86a Check the size of rescue&ensure stacks; ref #4088
Those small stack indexes can cause integer overflow.
2018-08-29 13:17:18 +09:00
Yukihiro "Matz" Matsumoto 2a88a546b2 Fix type of eidx and ridx from uint8_t to uint16_t; fix #4088
A byte was too small to hold ensure&rescue stacks indexes.
2018-08-29 13:15:24 +09:00
Yukihiro "Matz" Matsumoto 6aa091e5aa Simplified #ifdef nesting in codedump.c; fix #4089
`printf()` and related functions should not be called when
`MRB_DISABLE_STDIO` is defined.
2018-08-29 12:37:07 +09:00
Yukihiro "Matz" Matsumoto bc88fc6ed1 Check iseq buffer size before code emission; fix #4090
The type of `s->pc` is now `uint16_t` that can be overflowed easily.
Need more checks.
2018-08-29 12:31:48 +09:00
Yukihiro "Matz" Matsumoto 814b7b5ef8 Move back mrb_define_alias to mruby.h to avoid breakage. 2018-08-29 07:00:13 +09:00
Yukihiro "Matz" Matsumoto 93bab387a7 Merge branch 'mruby2-draft' 2018-08-28 22:13:52 +09:00
Yukihiro "Matz" Matsumoto 471288f37d Reduce integer casting warnings. 2018-08-25 16:58:01 +09:00
Yukihiro "Matz" Matsumoto d79dbd92f9 fixup! New bytecode implementation of mruby VM. 2018-08-25 09:49:20 +09:00
Yukihiro "Matz" Matsumoto 49d1b16822 Hash splat ** should not be ignored.
Implemented by adding `OP_HASHCAT` that merges hashes.
2018-08-25 09:41:21 +09:00
Yukihiro "Matz" Matsumoto 306732e02d Fixed a bug in OP_HASHADD. 2018-08-25 09:41:21 +09:00
Yukihiro "Matz" Matsumoto a3fb80904d Remove unused Hash#__update method. 2018-08-25 09:41:21 +09:00
Yukihiro "Matz" Matsumoto 3554fc54de Add a new function mrb_hash_merge(). 2018-08-25 09:41:21 +09:00
Yukihiro "Matz" Matsumoto b06dad43fa Remove unused NODE_* constants from node.h. 2018-08-25 09:41:21 +09:00
Yukihiro "Matz" Matsumoto e5eb7ef046 Add NODE_KW_HASH support in mrb_parser_dump(). 2018-08-25 09:41:21 +09:00
Yukihiro "Matz" Matsumoto 162243d95c Remove arg_value from parse.y. 2018-08-25 09:41:21 +09:00
Yukihiro "Matz" Matsumoto b7e56e9d20 Add bytecode support for MRB_WORD_BOXING. 2018-08-25 09:41:21 +09:00
Yukihiro "Matz" Matsumoto eeb6d5658d New bytecode implementation of mruby VM. 2018-08-25 09:41:21 +09:00
Yukihiro "Matz" Matsumoto a16885efe5 Try to fix a fragile File#mtime test. 2018-08-25 09:19:17 +09:00
Yukihiro "Matz" Matsumoto 31827189ab Remove potential path to avoid uninitialized variable access. 2018-08-25 09:19:17 +09:00
Yukihiro "Matz" Matsumoto fbfe519be7 Simplify mruby-inline-struct tests.
`gcc -O3` raises error on truncation using `snprintf`.
2018-08-25 09:19:17 +09:00
Yukihiro "Matz" Matsumoto b3a1d37926 Make Array.new to accept both integers and floats.
This time we used `Integral` module which is mruby specific.
2018-08-25 09:19:17 +09:00
Kazuhiro Sera 2b2ff844a1 Fix misspelling words in comments 2018-08-25 09:19:17 +09:00
Yukihiro "Matz" Matsumoto b083c1351f Fixed the corner case bug in String#{gsub!,sub!}.
`"a".sub!("a", "a")` should not return `nil`.
2018-08-25 09:17:46 +09:00
pyama86 821135e2df irep is released when Fiber is terminated 2018-08-25 09:17:46 +09:00
Yukihiro "Matz" Matsumoto 49d9fb8f41 Reimplement Hash#compact! to conform the standard behavior.
`Hash#compact!` should return `nil` if the receiver does not change.
2018-08-25 09:17:46 +09:00
Yukihiro "Matz" Matsumoto 9409a2ff6d Rename ambiguous function names.
`mrb_iv_p` -> `mrb_iv_name_sym_p`
`mrb_iv_check` -> `mrb_iv_name_sym_check`
2018-08-25 09:17:46 +09:00
Yukihiro "Matz" Matsumoto 5e469d2b92 Remove utility functions: mrb_vm_iv_{get,set}. 2018-08-25 09:17:46 +09:00
Yukihiro "Matz" Matsumoto c88fd32713 Revert 04dbbff.
Use segment list for instance variable again to reduce memory.
2018-08-25 09:16:01 +09:00
Yukihiro "Matz" Matsumoto 4c974b9523 Small refactoring.
The macro `RCLASS_SUPER`, `RCLASS_IV_TBL` and `RCLASS_M_TBL` are
removed from `include/mruby/class.h`.
2018-08-25 09:16:01 +09:00
Yukihiro "Matz" Matsumoto f3564a405e Small refactoring of flodivmod(). 2018-08-25 09:16:01 +09:00
dearblue 322eb2328a Fix mrb_value size with MRB_WORD_BOXING on 32-bit mode 2018-08-25 09:16:01 +09:00
Yukihiro "Matz" Matsumoto 6681e22c71 Simply use snprintf instead of custom fmt_fp,
Unless `MRB_DISABLE_STDIO` is set. `snprintf` is used anyway
if mruby is configured to use `stdio`. This change reduces 8KB
of program size on the Linux box.
2018-08-25 09:16:01 +09:00
Yukihiro "Matz" Matsumoto 91c08d7631 Remove nregs member from mrb_callinfo.
This means reducing one word per a call frame.
2018-08-25 09:16:01 +09:00
Yukihiro "Matz" Matsumoto 8a18d1539b Should update ci->env to share the environment; fix #4073 2018-08-25 09:13:09 +09:00
Yukihiro "Matz" Matsumoto fd086833ff Reorganize flags values for classes; fix #3975
Renamed flag macro names as well:
`MRB_FLAG_IS_FROZEN` -> `MRB_FL_OBJ_FROZEN`
`MRB_FLAG_IS_PREPENDED` -> `MRB_FL_CLASS_IS_PREPENDED`
`MRB_FLAG_IS_ORIGIN` -> `MRB_FL_CLASS_IS_ORIGIN`
`MRB_FLAG_IS_INHERITED` -> `MRB_FL_CLASS_IS_INHERITED`
2018-08-25 09:13:09 +09:00
Yukihiro "Matz" Matsumoto bfd11aab35 Check size of the integer multiply before actual overflow; fix #4062 2018-08-25 09:13:09 +09:00
Yukihiro "Matz" Matsumoto fe77272c25 Kernel#p should return an array of arguments; fix #4083
Although the return value is not defined in ISO, it is better to behave
as CRuby does.
2018-08-18 22:40:44 +09:00
Yukihiro "Matz" Matsumoto c095736002 Try to fix a fragile File#mtime test. 2018-08-13 23:15:52 +09:00
Yukihiro "Matz" Matsumoto 14206a75a3 Remove potential path to avoid uninitialized variable access. 2018-08-13 23:15:52 +09:00
Yukihiro "Matz" Matsumoto 1e52d47bc3 Simplify mruby-inline-struct tests.
`gcc -O3` raises error on truncation using `snprintf`.
2018-08-13 23:15:52 +09:00
Yukihiro "Matz" Matsumoto fee9ec61bb Make Array.new to accept both integers and floats.
This time we used `Integral` module which is mruby specific.
2018-08-13 23:15:52 +09:00
Yukihiro "Matz" Matsumoto 11d5782687 Merge pull request #4081 from seratch/fix-typo
Fix misspelling words in comments, docs
2018-08-11 10:35:13 +09:00
Kazuhiro Sera b03f1f78e3 Fix misspelling words in comments 2018-08-11 00:28:32 +09:00
Ukrainskiy Sergey fbe876b871 Added push() after OP_SEND 2018-08-10 06:44:19 +09:00
Ukrainskiy Sergey 672110dbe8 Small fix 2018-08-09 17:57:18 +09:00
Ukrainskiy Sergey e3b181586c Fix weird behavior of the NODE_NEGATE 2018-08-09 17:31:57 +09:00
Yukihiro "Matz" Matsumoto 35be8b2524 Fixed the corner case bug in String#{gsub!,sub!}.
`"a".sub!("a", "a")` should not return `nil`.
2018-08-07 23:03:17 +09:00
pyama86 54246db00a irep is released when Fiber is terminated 2018-08-06 19:13:19 +09:00
Yukihiro "Matz" Matsumoto 62e8e910b2 Reimplement Hash#compact! to conform the standard behavior.
`Hash#compact!` should return `nil` if the receiver does not change.
2018-08-06 16:40:19 +09:00
Yukihiro "Matz" Matsumoto 0dca6206c1 Rename ambiguous function names.
`mrb_iv_p` -> `mrb_iv_name_sym_p`
`mrb_iv_check` -> `mrb_iv_name_sym_check`
2018-08-06 10:15:55 +09:00
Yukihiro "Matz" Matsumoto 8f386f7663 Remove utility functions: mrb_vm_iv_{get,set}. 2018-08-06 10:15:55 +09:00
Yukihiro "Matz" Matsumoto 14c7a9c548 Revert 04dbbff.
Use segment list for instance variable again to reduce memory.
2018-08-06 10:15:55 +09:00
Yukihiro "Matz" Matsumoto afbbc0a2cb Small refactoring.
The macro `RCLASS_SUPER`, `RCLASS_IV_TBL` and `RCLASS_M_TBL` are
removed from `include/mruby/class.h`.
2018-08-06 10:15:55 +09:00
Yukihiro "Matz" Matsumoto 005ccd9c7e Small refactoring of flodivmod(). 2018-08-06 10:15:55 +09:00
Yukihiro "Matz" Matsumoto 708d6a4964 Merge pull request #4077 from dearblue/fix-wordboxing-symbol
Fix to sizeof(mrb_value) is 4 bytes with MRB_WORD_BOXING on 32-bit mode
2018-08-06 10:15:34 +09:00
dearblue ca01c8792d Fix mrb_value size with MRB_WORD_BOXING on 32-bit mode 2018-08-05 20:33:44 +09:00
Yukihiro "Matz" Matsumoto 4713cd9eb7 Simply use snprintf instead of custom fmt_fp,
Unless `MRB_DISABLE_STDIO` is set. `snprintf` is used anyway
if mruby is configured to use `stdio`. This change reduces 8KB
of program size on the Linux box.
2018-08-01 16:50:44 +09:00
Yukihiro "Matz" Matsumoto b9817b00a4 Remove nregs member from mrb_callinfo.
This means reducing one word per a call frame.
2018-08-01 13:18:32 +09:00
Yukihiro "Matz" Matsumoto e89cc9b9fa Should update ci->env to share the environment; fix #4073 2018-08-01 10:08:40 +09:00
Yukihiro "Matz" Matsumoto d886676690 Merge pull request #4074 from znz/patch-1
Remove unmatched quotation mark
2018-08-01 09:26:23 +09:00
Kazuhiro NISHIYAMA 64748691de Remove unmatched quotation mark 2018-07-31 22:09:45 +09:00
Yukihiro "Matz" Matsumoto beb6e5c299 Bytecode support for mrdb. 2018-07-31 17:28:42 +09:00
Yukihiro "Matz" Matsumoto 889f0f5f36 Add test case corresponding to 53e2723. 2018-07-31 17:27:59 +09:00
Yukihiro "Matz" Matsumoto 8558627b9b Reorganize flags values for classes; fix #3975
Renamed flag macro names as well:
`MRB_FLAG_IS_FROZEN` -> `MRB_FL_OBJ_FROZEN`
`MRB_FLAG_IS_PREPENDED` -> `MRB_FL_CLASS_IS_PREPENDED`
`MRB_FLAG_IS_ORIGIN` -> `MRB_FL_CLASS_IS_ORIGIN`
`MRB_FLAG_IS_INHERITED` -> `MRB_FL_CLASS_IS_INHERITED`
2018-07-31 16:48:50 +09:00
Yukihiro "Matz" Matsumoto 180f39bf4c Check size of the integer multiply before actual overflow; fix #4062 2018-07-31 16:14:18 +09:00
Yukihiro "Matz" Matsumoto 4ce9058f64 Describe the difference of the keyword argument behavior.
The implementation of keyword arguments is heavily rely on the prototype
made by @take-cheeze in #3629.
2018-07-31 03:26:53 +09:00
Yukihiro "Matz" Matsumoto e27565152f Removed merge hiccups in doc/opcode.md. 2018-07-31 03:20:27 +09:00
Yukihiro "Matz" Matsumoto 43173e1299 Removed unused instruction: OP_KDICT. 2018-07-31 03:20:00 +09:00
Yukihiro "Matz" Matsumoto 53e2723fae Fixed a small bug in keyword argument parsing.
def m(a=1,**k) p [a,k] end
m(a: 1)
2018-07-31 03:14:42 +09:00
Yukihiro "Matz" Matsumoto 8c9e712784 Keyword argument implemented. 2018-07-30 22:58:01 +09:00
Yukihiro "Matz" Matsumoto 891839b976 New bytecode implementation of mruby VM. 2018-07-30 22:57:54 +09:00
Yukihiro "Matz" Matsumoto b09d2eb900 Kernel#instance_eval should define singleton methods; fix #4069 2018-07-23 18:26:24 +09:00
Tomoyuki Sahara cb42c98757 Merge pull request #4072 from katzer/fix/unsupported_servname
[mruby-socket] Network services might not be available
2018-07-21 20:07:37 +09:00
Sebastián Katzer 0bc8d1979c Network services might not be available 2018-07-21 10:18:22 +02:00
Yukihiro "Matz" Matsumoto e3bc680d98 Merge pull request #4068 from yurie/mrbc
add mrbc option `--remove-lv`
2018-07-11 15:09:57 +09:00
yuri a921b936d6 move declaration of mrb_irep_remove_lv from dump.h to irep.h 2018-07-11 14:14:12 +09:00
yuri 5fef38e4c7 move mrb_irep_remove_lv to codegen.c in mruby-compiler 2018-07-10 15:44:25 +09:00
yuri dabb20ddbb add mrbc option --remove-lv
* refactor: move `irep_remove_lv` from `mruby-bin-strip` gem to src/dump and rename to `mrb_irep_remove_lv`
* add: mrbc option `--remove-lv` to remove LVAR section
2018-07-10 01:42:33 +09:00
Yukihiro "Matz" Matsumoto ea435f99da Merge pull request #4067 from katzer/patch-1
[mruby-test] Fix task name is not necessarily a valid path
2018-07-09 08:19:12 +09:00
Sebastián Katzer b1f1fe2f81 Fix task name is not necessarily a valid path
Errno::ENOENT: No such file or directory @ dir_s_mkdir - mruby:Z:/Documents
2018-07-08 13:51:00 +02:00
Yukihiro "Matz" Matsumoto 17c9e65603 Merge pull request #4066 from duangsuse/master
Added ~/Android/Sdk/ndk-bundle as default NDK home
2018-07-04 22:12:41 +09:00
duangsuse 06428059f6 Add ~/Android/Sdk/ndk-bundle as default NDK home 2018-07-04 19:33:11 +08:00
Yukihiro "Matz" Matsumoto 5bb3f60e49 Merge pull request #4064 from mame/mrb_without_float-for-mruby-io
Support MRB_WITHOUT_FLOAT to mruby-io
2018-07-02 11:00:35 +09:00
Yusuke Endoh 7917b7f8bf Support MRB_WITHOUT_FLOAT to mruby-io 2018-07-02 10:47:56 +09:00
Yukihiro "Matz" Matsumoto adb1eae912 Use mrb_raise() instead of mrb_raisef(); ref #4062 2018-06-28 22:40:24 +09:00
Yukihiro "Matz" Matsumoto e60829405c Merge pull request #4063 from graywolf/patch-1
Add information about Kernel#binding
2018-06-28 08:43:25 +09:00
W 3116d06003 Add information about Kernel#binding 2018-06-27 12:20:24 +00:00
Yukihiro "Matz" Matsumoto 695f29cd60 Add negative check in mrb_str_resize; fix #4062 2018-06-27 16:32:24 +09:00
Yukihiro "Matz" Matsumoto 7e79840587 initialize a local variable to avoid warning 2018-06-22 12:03:52 +09:00
Yukihiro "Matz" Matsumoto 351614bbdd Merge pull request #4059 from take-cheeze/parallel_tests
Run tests parallelly for each target.
2018-06-22 12:02:09 +09:00
Yukihiro "Matz" Matsumoto 864a998c24 Merge pull request #4058 from take-cheeze/exp_sleep
Increase sleep duration exponentially instead of `Thread.pass`.
2018-06-22 12:01:33 +09:00
take-cheeze eaf463ada3 Run tests parallelly for each target. 2018-06-22 11:43:14 +09:00
take-cheeze 48ba7c7bb0 Increase sleep duration exponentially instead of Thread.pass. 2018-06-22 11:41:12 +09:00
Yukihiro "Matz" Matsumoto 3671404391 Merge pull request #4053 from take-cheeze/use_transfer
Use Fiber#transfer instead in minirake.
2018-06-22 10:26:37 +09:00
Yukihiro "Matz" Matsumoto 410a5031fc Merge pull request #4057 from take-cheeze/use_thread_pass
Use `Thread.pass` instead of sleeping.
2018-06-22 10:19:16 +09:00
take-cheeze 61e8f831dd Use Thread.pass instead of sleeping. 2018-06-22 09:29:59 +09:00
Yukihiro "Matz" Matsumoto 36e1796e41 Merge branch 'master' into use_transfer 2018-06-22 07:23:50 +09:00
Yukihiro "Matz" Matsumoto 640fca3276 Merge pull request #4056 from take-cheeze/fix_rake_jobs
Fix job waiter of minirake.
2018-06-22 07:18:01 +09:00
Yukihiro "Matz" Matsumoto 485efd9253 Merge pull request #4054 from take-cheeze/show_rake_bt
Show minirake backtrace in verbose mode.
2018-06-22 07:16:48 +09:00
take-cheeze 7c246cb9db Fix job waiter. 2018-06-21 12:45:55 +09:00
take-cheeze acd04ad519 Support verbose mode in bintest. 2018-06-21 11:33:34 +09:00
take-cheeze c90dbd12ef Show minirake backtrace in verbose mode. 2018-06-21 11:29:50 +09:00
take-cheeze 6f35b07fab Use Fiber#transfer instead in minirake. 2018-06-21 11:26:55 +09:00
Yukihiro "Matz" Matsumoto fd9617cad0 Merge pull request #4052 from take-cheeze/fix_mtime_test
Use temporary file name for `File#mtime` test to avoid conflicts.
2018-06-20 23:19:52 +09:00
Yukihiro "Matz" Matsumoto 1829b76929 Merge pull request #4051 from take-cheeze/para_rake
Make minirake parallel.
2018-06-20 22:09:54 +09:00
take-cheeze 7bb2fc70f2 Set jobs to 4 since it have 2 CPUs. 2018-06-20 21:44:23 +09:00
take-cheeze 8f808cc9b1 Use temporary name for File#mtime test to avoid conflicts. 2018-06-20 21:42:48 +09:00
take-cheeze 33f72bb038 disable sudo. 2018-06-20 21:34:03 +09:00
take-cheeze c3ac33d9cd Make minirake parallel. 2018-06-20 20:51:24 +09:00
Yukihiro "Matz" Matsumoto cfed6e3a4b Merge pull request #4050 from take-cheeze/fix_build_script
Fix build scripts.
2018-06-20 20:42:53 +09:00
Yukihiro "Matz" Matsumoto 1a9195285c Merge pull request #4049 from take-cheeze/fix_mirb_leak
Fix memory leaks in mirb.
2018-06-20 19:13:43 +09:00
take-cheeze b8fec13cab Make codacy happy. 2018-06-20 18:29:11 +09:00
take-cheeze 1d7c69a7cb Fix dependencies. 2018-06-20 18:23:08 +09:00
take-cheeze a212428fed Comment out unused variable. 2018-06-20 18:22:50 +09:00
take-cheeze 633599a2cb Fix forgotten argument passing. 2018-06-20 18:21:57 +09:00
take-cheeze dfddc6a09f Fix dependencies. 2018-06-20 18:21:33 +09:00
take-cheeze e050cfb349 Add forgotten mkdir_ps. 2018-06-20 18:20:26 +09:00
take-cheeze 26d143bda8 Fix memory leaks in mirb. 2018-06-20 18:16:25 +09:00
Yukihiro "Matz" Matsumoto f29bc4607a Add test_dependency from mruby-io to mruby-time. 2018-06-20 15:24:46 +09:00
Yukihiro "Matz" Matsumoto 54cd2623b3 Turn off enable_debug flag in build_config.rb by default.
This will improve the default performance of mruby; fix #4045
2018-06-20 15:24:46 +09:00
Yukihiro "Matz" Matsumoto 58d819f317 Merge pull request #4048 from kou/export-mrb-utf8-locale
Export mrb_utf8_from_locale() and mrb_locale_from_utf8()
2018-06-20 13:39:59 +09:00
Kouhei Sutou e38d1d278b Export mrb_utf8_from_locale() and mrb_locale_from_utf8() 2018-06-20 11:45:15 +09:00
Yukihiro "Matz" Matsumoto 5e7ced0785 Merge pull request #4047 from kou/stop-to-use-freed-value
Stop to use freed value
2018-06-19 19:33:37 +09:00
Yukihiro "Matz" Matsumoto 47413d0507 Merge pull request #4046 from kou/fix-wrong-free-function
Fix wrong free function
2018-06-19 19:32:18 +09:00
Kouhei Sutou 33c8c8f8a6 Stop to use freed value 2018-06-19 17:27:34 +09:00
Kouhei Sutou fb9358206e Fix wrong free function
mrb_locale_free() should be used for the return value of
mrb_locale_from_utf8().
2018-06-19 17:25:38 +09:00
Yukihiro "Matz" Matsumoto a9abf65f03 Fixed wrong usages of mrb_raisef(); ref #4043
`mrb_raisef()` only takes `%S` specifier. If you don't have extra
arguments, use `mrb_raise()`.
2018-06-15 07:47:18 +09:00
Yukihiro "Matz" Matsumoto 70600c3ba8 Resolve sign comparison warning; ref #4044 2018-06-14 14:16:04 +09:00
Tomoyuki Sahara 5340d39ed4 Merge pull request #4044 from iij/fixes-from-iij-socket
incorporate fixes from iij/socket
2018-06-14 13:58:48 +09:00
Tomoyuki Sahara af8020e7fd sa_family_t is not defined on windows. 2018-06-14 13:52:37 +09:00
Tomoyuki Sahara 2eeac91098 set sockaddr_un.sun_len on the systems that have sockaddr.sa_len.
If your system has sa_len but is not BSD-derived, define HAVE_SA_LEN=1
on mrbgem.rake or build_config.rb.
2018-06-14 13:36:01 +09:00
Tomoyuki Sahara 5013d2b20f struct sockaddr_un can be truncated.
When we have "struct sockaddr_un *s_un", we could not assume *s_un
points to a memory region which size is at least sizeof(*s_un).
Even worse, it may be shorter than sizeof(struct sockaddr) on some
systems.
2018-06-14 13:28:32 +09:00
Tomoyuki Sahara 3618556a95 struct sockaddr_un can be shorter than struct sockaddr.
ref: https://github.com/iij/mruby-socket/issues/45
2018-06-14 13:25:57 +09:00
Yukihiro "Matz" Matsumoto 97933665b6 Restore GC arena after raised exceptions; ref #4042 2018-06-14 11:42:34 +09:00
Yukihiro "Matz" Matsumoto ba090a46af Need to add a write barrier for ranges; fix #4042
Ranges are almost immutable but `initialize` and `initialize_copy`
modify the receiver so that we need to add a write barrier.
2018-06-14 11:25:12 +09:00
Yukihiro "Matz" Matsumoto a7f77fefa9 Check for switching to uninitialized fiber; fix #4041
The problem was caused by `Fiber.current.resume'.
2018-06-14 11:15:49 +09:00
Yukihiro "Matz" Matsumoto 896de5532b Merge pull request #4043 from take-cheeze/fix_test_dep
Fix unnecessary rebuild of tests.
2018-06-14 10:13:35 +09:00
take-cheeze f715f2ddea Fix unnecessary rebuild of tests. 2018-06-13 23:32:08 +09:00
Yukihiro "Matz" Matsumoto 23a4e7149d Revert "No longer need to insert write barriers for fibers."
This reverts commit c6736357a7.
The assumption was wrong and caused the issue; fix #4020
2018-06-11 14:50:42 +09:00
Yukihiro "Matz" Matsumoto a9b740b36b Retrieve b operand from the instruction (for debugging); ref #4020 2018-06-11 14:50:03 +09:00
Yukihiro "Matz" Matsumoto faa4eaf680 mrb_class_real() did not work for BasicObject; fix #4037 2018-06-08 14:13:06 +09:00
Yukihiro "Matz" Matsumoto 55edae0226 Allow Object#clone to copy frozen status only; fix #4036
Copying all flags from the original object may overwrite the clone's
flags e.g. the embedded flag.
2018-06-07 16:17:00 +09:00
Yukihiro "Matz" Matsumoto cfd0c93d7d Merge pull request #4035 from katzer/patch-1
[mruby-socket] Declare inet_ntop and inet_pton as static
2018-06-07 16:03:14 +09:00
Yukihiro "Matz" Matsumoto 55dcdd26cc Merge pull request #4039 from i110/i110/fix-broken-lexical-variables
fix broken lexical variables
2018-06-07 16:02:30 +09:00
Yukihiro "Matz" Matsumoto 778500563a Extend stack when pushing arguments that does not fit in; fix #4038 2018-06-07 15:59:00 +09:00
Yukihiro "Matz" Matsumoto ff0a4f7867 Export stack_extend function (renamed mrb_stack_extend); fix #3219
This change is required to support #4038.
2018-06-07 15:55:20 +09:00
Ichito Nagata 1dbeda5c9c add test for eval 2018-06-06 15:35:41 +09:00
Ichito Nagata c2b2bec9e2 Revert "Fix heap use after free on mruby-aws-sigv4."
This reverts commit b8869498b7.
2018-06-06 15:04:58 +09:00
Sebastián Katzer e7a4699135 Declare inet_ntop and inet_pton as static
To avoid conflicts with multiple definitions of inet_ntop and inet_pton if compiled with # define _WIN32_WINNT _WIN32_WINNT_VISTA

C:/mingw-w64/x86_64-7.2.0-posix-seh-rt_v5-rev1/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/7.2.0/../../../../x86_64-w64-mingw32/lib/../lib/libWs2_32.a(dghfs00169.o):(.text+0x0): multiple definition of `inet_pton'
722C:/projects/iss/mruby/build/host/lib/libmruby.a(socket.o):C:/projects/iss/mruby/mrbgems/mruby-socket/src/socket.c:80: first defined here

define _WIN32_WINNT _WIN32_WINNT_VISTA
2018-06-05 15:59:12 +02:00
Ichito Nagata 2af92d0ebc Let inspect recursion do the right thing 2018-06-04 11:25:10 +09:00
Yukihiro "Matz" Matsumoto aa5c5de4fd Merge pull request #4033 from i110/i110/fix-envadjust
fix env->stack misadjusting: fix #4029
2018-06-03 20:54:12 +09:00
Ichito Nagata edaa7a1ba1 fix env->stack misadjusting 2018-06-03 19:40:33 +09:00
Yukihiro "Matz" Matsumoto 395260747a Instead of defining Hash#dup, we should define Hash#initialize_copy.
`Hash#clone` did not work properly; fix #4030
2018-06-01 22:40:42 +09:00
Yukihiro "Matz" Matsumoto f408143c28 The clone method should copy object status (e.g. frozen) too; #4030 2018-06-01 22:39:40 +09:00
Yukihiro "Matz" Matsumoto 7ed164ba89 Merge pull request #4031 from i110/i110/hash_default
let Hash#merge keep ifnone value
2018-06-01 20:29:45 +09:00
Ichito Nagata 4a2b055cdd let Hash#merge keep ifnone value 2018-06-01 12:48:17 +09:00
Yukihiro "Matz" Matsumoto b64ce17852 Should not call initialize_copy for TT_ICLASS; fix #4027
Since `TT_ICLASS` is a internal object that should never be revealed
to Ruby world.
2018-05-30 17:05:40 +09:00
Yukihiro "Matz" Matsumoto 1dddc2f712 Clear __classname__ of duped class/module; ref #4027 2018-05-30 17:05:05 +09:00
Yukihiro "Matz" Matsumoto 14c21793a0 Check if the exception is frozen; fix #4025
`exc_debug_info()` and `mrb_keep_backtrace()` raise `FrozenError`
if the exception is frozen and lead to infinite loop.
2018-05-23 08:30:50 +09:00
Yukihiro "Matz" Matsumoto c8fb7453fc Add then alias to yield_self.
`then' was added in CRuby 2.6.
2018-05-23 08:30:50 +09:00
Yukihiro "Matz" Matsumoto a7c8575fe3 Merge pull request #4023 from iwamatsu/fix-upstream
Fix test of mruby-pack with big-endian CPUs
2018-05-11 10:34:01 +09:00
Nobuhiro Iwamatsu 0759647f06 Fix test of mruby-pack with big-endian CPUs
When running the mruby-pack test with big endian, test data is incorrect,
so it will fail with "i" and "I".

------
Fail: pack/unpack "i" (mrbgems: mruby-pack)
 - Assertion[1] Failed: Expected to be equal
    Expected: "\xff\xff\xc7\xcf"
      Actual: "\xff\xff\xcf\xc7"
 - Assertion[2] Failed: Expected to be equal
    Expected: [-12345]
      Actual: [-14385]
Fail: pack/unpack "I" (mrbgems: mruby-pack)
 - Assertion[1] Failed: Expected to be equal
    Expected: "\x00\x0090"
      Actual: "\x00\x0009"
 - Assertion[2] Failed: Expected to be equal
    Expected: [12345]
      Actual: [14640]
------

This will fix the test data at big-endian.

Signed-off-by: Nobuhiro Iwamatsu <iwamatsu@nigauri.org>
2018-05-10 12:54:08 +09:00
Yukihiro "Matz" Matsumoto bda88bdbea Merge pull request #4022 from mimaki/mruby-r-option
Add `-r` option for `mruby` and `mirb`. (mrbgem is not supported)
2018-05-09 18:31:34 +08:00
Hiroshi Mimaki e76492c776 Fix CI build errors and warnings. 2018-05-08 09:55:09 +09:00
Hiroshi Mimaki d973a8ebc4 Add -r option for mruby and mirb. 2018-05-07 18:17:50 +09:00
Yukihiro "Matz" Matsumoto fc247449e2 Merge pull request #4017 from mimaki/mruby-d-option
Add `-d` option for `mruby` and `mirb`.
2018-05-07 14:31:19 +08:00
Hiroshi Mimaki 0c01afc3c9 Fix CI build errors and warnings. 2018-05-07 12:23:32 +09:00
Yukihiro "Matz" Matsumoto 72581696d3 env referred from top-level callinfo should not be unshared; fix #4019
Because `mirb` keeps top-level environment across each iteration.
2018-05-03 15:15:30 +09:00
Yukihiro "Matz" Matsumoto 2d4c092de7 Need to call mrb_str_modify() in mrb_str_cat_str(); fix #4018
If `str` and `str2` are the same string object `str->ptr` may be
rewritten by `mrb_str_modify()`.
2018-05-02 22:50:55 +09:00
Hiroshi Mimaki 1d16646506 Add -d option for mruby and mirb. 2018-05-02 20:52:02 +09:00
Yukihiro "Matz" Matsumoto 028e34d345 Update MRB_FLO_TO_STR_FMT to "%.16g"; fix #4016 2018-05-01 17:21:01 +09:00
Yukihiro "Matz" Matsumoto 2a38eb9325 Check the return value from mrb_get_datatype(); fix #4009
The return value (void*) may be NULL. Avoid using `mrb_get_datatype()`
directly and use `io_get_open_fptr()` instead.
2018-05-01 13:29:08 +09:00
Yukihiro "Matz" Matsumoto a8122a9d56 Fix stack position in multiple assignment; fix #4008
This was caused by a patch from #2684.
2018-05-01 12:25:04 +09:00
Yukihiro "Matz" Matsumoto 59c8fdd651 Update OP_APOST description; ref #4008 2018-04-28 15:36:23 +09:00
Yukihiro "Matz" Matsumoto 0fee6e1ee9 Fix broken support of MRB_WITHOUT_FLOAT; fix #4015 2018-04-28 15:15:28 +09:00
Yukihiro "Matz" Matsumoto 50a9c5d7c7 Update the patch to not use funcall in C; ref #4013 2018-04-28 11:26:23 +09:00
kimu_shu 4b29abc565 Fix Enumerable#hash on non 32-bit integer conf. 2018-04-28 11:26:23 +09:00
Yukihiro "Matz" Matsumoto 84b499d02b Merge pull request #4014 from mruby/stable
Set the mruby-1.4.1 release date to `2018-4-27`.
2018-04-28 10:08:56 +09:00
Yukihiro "Matz" Matsumoto b956c0f43c Merge pull request #4012 from take-cheeze/fix_heap_use_after_free
Fix heap use after free on mruby-aws-sigv4.
2018-04-28 10:08:20 +09:00
Hiroshi Mimaki 023070a639 Set the mruby-1.4.1 release date to 2018-4-27. 2018-04-27 11:30:30 +09:00
Takeshi Watanabe b8869498b7 Fix heap use after free on mruby-aws-sigv4. 2018-04-27 10:45:59 +09:00
Yukihiro "Matz" Matsumoto 1b261382a0 Merge pull request #4011 from kou/fix-gc-env-children
Fix wrong the number of marked objects of MRB_TT_ENV in gray mark phase
2018-04-26 23:00:25 +09:00
Kouhei Sutou 4194fe9d65 Fix wrong the number of marked objects of MRB_TT_ENV in gray mark phase
If MRB_TT_ENV has stack shared flag or bidx flag, flags is too large
than the real stack size.
2018-04-26 15:25:36 +09:00
Yukihiro "Matz" Matsumoto 1c66d42e47 Merge pull request #4010 from take-cheeze/fix_ary_replace_leak
Fix array replace leak error in mruby-uri.
2018-04-25 15:59:56 +09:00
Takeshi Watanabe e66c990234 Fix array replace leak error in mruby-uri. 2018-04-25 13:27:00 +09:00
Yukihiro "Matz" Matsumoto 8bfad558f8 Merge pull request #4007 from iij/sort-should-not-consume-system-stack
sort method should not consume system stack.
2018-04-23 13:15:10 +09:00
Yukihiro "Matz" Matsumoto 1ca06f407b Merge pull request #4006 from take-cheeze/fix_ub_check
Fix undefined error of pointer dereference.
2018-04-23 13:13:36 +09:00
Tomoyuki Sahara f0e54df4fe sort method should not consume system stack. 2018-04-23 12:28:15 +09:00
Takeshi Watanabe 25c40c2f12 Fix undefined error of pointer dereference. 2018-04-23 12:06:13 +09:00
Yukihiro "Matz" Matsumoto 2213deeeaa Implement String#upto in Ruby.
Avoid using `mrb_yield` in C code. The function is not recommended.
Because it doesn't work well with fibers.
2018-04-21 22:30:54 +09:00
Yukihiro "Matz" Matsumoto 8b92ab5c7b CRuby2.6 stops deprecating String#lines with a block.
`String#lines` (with a block) is now implemented in Ruby.
2018-04-19 17:33:00 +09:00
Yukihiro "Matz" Matsumoto c79e81ebc3 String#lines with a block is deprecated style. 2018-04-19 09:07:11 +09:00
Yukihiro "Matz" Matsumoto 54905e98cf ary_dup() should not use `ary_replace(); fix #4004
Otherwise the duplicated object may have shared entities that
should not be modified in-line.
2018-04-18 17:30:33 +09:00
Yukihiro "Matz" Matsumoto 391e24210f A new function ary_from_values(); ref #4004 2018-04-18 17:29:45 +09:00
Yukihiro "Matz" Matsumoto c9275bbbed mrb_io_initialize_copy should not free existing fptr; fix #4005
When arguments `copy` and `orig` are the same object.
2018-04-18 17:27:41 +09:00
Yukihiro "Matz" Matsumoto 05db341ef5 mrb_dup() should fail if fd is a negative integer; ref #4005 2018-04-18 17:25:52 +09:00
Yukihiro "Matz" Matsumoto 135b4773e3 Turn off major GC mode before full GC; fix #4000 2018-04-18 00:18:03 +09:00
Yukihiro "Matz" Matsumoto 0866fa38b0 Avoid unnecessary object allocation (addrinfo) in _accept; ref #3999 2018-04-18 00:18:03 +09:00
Yukihiro "Matz" Matsumoto f7cf5812b1 Merge pull request #4003 from take-cheeze/int32_overflow
Fallback to float when compiled binary with 64bit compiler.
2018-04-17 23:08:36 +09:00
Takeshi Watanabe 87ef6aeb02 Fallback to float when caompiled binary with 64bit compiler.
closes #3997.
2018-04-17 22:59:07 +09:00
Yukihiro "Matz" Matsumoto 4880f6dc89 Socket.accept should have returned [fd, addr]; fix #3999 2018-04-17 17:21:49 +09:00
Yukihiro "Matz" Matsumoto 0e76faed8c Make ary_replace() to share entry buffers if possible. 2018-04-17 17:21:45 +09:00
Yukihiro "Matz" Matsumoto 5c15aa2f3b Make ary_concat() to replace the receiver when it is empty. 2018-04-17 12:34:30 +09:00
Yukihiro "Matz" Matsumoto c078783a5a Make ary_replace() to take struct RArray* argument. 2018-04-17 12:33:01 +09:00
Yukihiro "Matz" Matsumoto 66b1695ba9 Define SOL_IP and SOL_TCP; ref #3999 2018-04-17 12:01:32 +09:00
Yukihiro "Matz" Matsumoto d88191e7e7 Implement Array#__svalue in C. 2018-04-17 11:32:31 +09:00
Yukihiro "Matz" Matsumoto b51b21fc63 Fix use after free in File#initilialize_copy; fix #4001
The bug and the fix were reported by https://hackerone.com/pnoltof
2018-04-17 09:57:41 +09:00
Yukihiro "Matz" Matsumoto fabc460880 Invoke full GC when too many objects allocated during GC; fix #3998
When object allocation rate during incremental GC is too high, the
`gc->majorgc_old_threshold` becomes too big. This means major GC
start slower and old objects stay longer (and consume too much memory).
2018-04-14 06:18:49 +09:00
Yukihiro "Matz" Matsumoto 3b273243e6 Change MAJOR_GC_INC_RATIO to 120; ref #3998
Because 200% is consumes too much memory for some cases.
2018-04-14 06:13:00 +09:00
Yukihiro "Matz" Matsumoto fc85016a32 Remove DEFAULT_ from DEFAULT_MAJOR_GC_INC_RATIO; ref #3998
Because unlike other GC ratio constants, it's not a default value.
2018-04-14 06:12:12 +09:00
Yukihiro "Matz" Matsumoto c6736357a7 No longer need to insert write barriers for fibers.
Those barriers are inserted to fix #3699 but all living fibers are
marked from `mark_context()` anyway now.
2018-04-13 23:46:40 +09:00
Yukihiro "Matz" Matsumoto e3e87ee26a The #3871 fix caused wrong break from proc-closure error; fix #3996 2018-04-13 21:56:45 +09:00
Yukihiro "Matz" Matsumoto 4df0380f1e Add fallthrough comment to silence gcc warning. 2018-04-13 11:23:27 +09:00
Yukihiro "Matz" Matsumoto 4b09c7364e Silence gcc initializer warning. 2018-04-13 11:22:54 +09:00
Yukihiro "Matz" Matsumoto 1905091634 Check length of env stack before accessing upvar; fix #3995 2018-04-11 10:24:44 +09:00
Yukihiro "Matz" Matsumoto e340b17252 Merge pull request #3994 from kou/fix-windows-build-error-on-dll-build
Fix build error on Windows with MRB_BUILD_AS_DLL
2018-04-10 16:35:48 +09:00
Kouhei Sutou 0bc6c17490 Fix build error on Windows with MRB_BUILD_AS_DLL
Error message:

    C:\projects\groonga\vendor\mruby-source\include\mruby.h(1098): error C2375: 'mrb_gc_arena_save' : redefinition; different linkage [C:\projects\groonga\vendor\mruby\mruby.vcxproj]
              C:\projects\groonga\vendor\mruby-source\include\mruby.h(1083) : see declaration of 'mrb_gc_arena_save'
    C:\projects\groonga\vendor\mruby-source\include\mruby.h(1099): error C2375: 'mrb_gc_arena_restore' : redefinition; different linkage [C:\projects\groonga\vendor\mruby\mruby.vcxproj]
              C:\projects\groonga\vendor\mruby-source\include\mruby.h(1084) : see declaration of 'mrb_gc_arena_restore'
2018-04-10 15:24:41 +09:00
Yukihiro "Matz" Matsumoto e9ddb593f3 Merge pull request #3991 from take-cheeze/fix_eval_env_gc
Fix possible heap use after free in `mrb_exec_irep` and stack expanding.
2018-04-05 15:44:24 +09:00
Takeshi Watanabe 26e436e247 Adjust environment when mrb_exec_irep happened. 2018-04-05 11:53:30 +09:00
Yukihiro "Matz" Matsumoto f23c3cddc8 Merge pull request #3990 from mimaki/fix-mrdb-illegal-free
Fixed memory failure on mruby debugger.
2018-04-04 15:44:49 +09:00
mimaki e57d9e6047 Fixed test case for mruby ddebugger. 2018-04-04 14:07:59 +09:00
mimaki c1b9ec0c30 Fixed illegal memory operation on mruby debugger. 2018-04-04 13:20:40 +09:00
Yukihiro "Matz" Matsumoto 951ebbafdc Merge pull request #3988 from ksss/each_with_object
Refactoring for `Enumerable#each_with_object`
2018-03-28 14:50:41 +09:00
ksss e683c95e90 Refactoring for Enumerable#each_with_object
`each_with_object` arity should be 1
2018-03-27 23:09:10 +09:00
Yukihiro "Matz" Matsumoto a072015c4e Merge pull request #3987 from ksss/enum-lazy-zip
Reimplement `Enumerable#zip` with Enumerator
2018-03-27 13:53:37 +09:00
Yukihiro "Matz" Matsumoto 211d417b02 Merge pull request #3986 from ksss/enum-zip
Support block yielding for Enumerable#zip
2018-03-27 13:52:13 +09:00
ksss 3a22d113ee Reimplement Enumerable#zip with Enumerator
for fix some specs
- [passes each element of the result array to a block and return nil if a block is given](https://github.com/ruby/spec/blob/a585ec35d185435e5c11f371ba4ed2a29d8817bd/core/enumerable/zip_spec.rb#L11-L17)
- [converts arguments to arrays using #to_ary](https://github.com/ruby/spec/blob/a585ec35d185435e5c11f371ba4ed2a29d8817bd/core/enumerable/zip_spec.rb#L23-L27)
- [converts arguments to enums using #to_enum](https://github.com/ruby/spec/blob/a585ec35d185435e5c11f371ba4ed2a29d8817bd/core/enumerable/zip_spec.rb#L29-L34)
- [gathers whole arrays as elements when each yields multiple](https://github.com/ruby/spec/blob/a585ec35d185435e5c11f371ba4ed2a29d8817bd/core/enumerable/zip_spec.rb#L36-L39)
2018-03-27 10:53:33 +09:00
ksss b1c8fad94a Should raise TypeError instead of NoMethodError 2018-03-27 10:52:32 +09:00
ksss 5a7ce01f12 Support block yielding for Enumerable#zip 2018-03-27 10:51:59 +09:00
Yukihiro "Matz" Matsumoto 203b071ca2 Merge pull request #3985 from take-cheeze/revert_ai_protocol
Revert #3984 .
2018-03-26 11:07:50 +09:00
Takeshi Watanabe baff7c63ee Revert #3984 . 2018-03-26 11:02:05 +09:00
Yukihiro "Matz" Matsumoto 0da7b4454f Merge pull request #3984 from take-cheeze/merge_socket
Catch up with latest mruby-socket.
2018-03-25 22:25:15 +09:00
Takeshi Watanabe 306cb99b10 Merge commit '36d016afd663d34607c843d03371bedb71efa34e' 2018-03-25 21:10:11 +09:00
Yukihiro "Matz" Matsumoto 4b5c21cf3b Merge pull request #3982 from take-cheeze/fix_str_cmp
Return nil if type differ in `String#<=>`.
2018-03-24 16:27:22 +09:00
Takeshi Watanabe 77a3863a3d Return nil if type differ in String#<=>. 2018-03-24 16:18:44 +09:00
Yukihiro "Matz" Matsumoto 8e8bc9e40b Merge pull request #3974 from take-cheeze/repo_path
Add `:path` option for git repository.
2018-03-22 17:06:31 +09:00
Takeshi Watanabe 4940ddb9fc Add :path option for git repository. 2018-03-22 12:42:41 +09:00
Yukihiro "Matz" Matsumoto fb78f10893 Need to keep block argument in mrb_exec_irep; fix #3973 2018-03-22 01:01:18 +09:00
Yukihiro "Matz" Matsumoto c8538be471 Needed to set ci->proc in OP_SUPER; fix #3966 2018-03-20 23:16:38 +09:00
Yukihiro "Matz" Matsumoto a85bc19f35 Merge pull request #3972 from take-cheeze/fix_ary_set_len_assert
Set array length after expanding capacity.
2018-03-20 23:15:37 +09:00
Takeshi Watanabe 1218ff5d47 Set array length after expanding capacity. 2018-03-19 21:40:17 +09:00
Tomoyuki Sahara 36d016afd6 Set protocol of AddrInfo
backport https://github.com/mruby/mruby/pull/3891
2018-03-16 17:05:37 +09:00
Yukihiro "Matz" Matsumoto 1a8483f17e __sort_sub__ is a method defined in Array; fix #3970
Reorganize `__sort_sub__` arguments.
2018-03-16 14:49:51 +09:00
Yukihiro "Matz" Matsumoto 1abff3f2ab Merge pull request #3957 from take-cheeze/fix_io_read
Pass same mode parameter to `IO.sysopen` and `IO.open` in `IO.read`.
2018-03-16 14:34:44 +09:00
Yukihiro "Matz" Matsumoto ceeb8c05df Needed to pass sort block. 2018-03-16 08:20:43 +09:00
Yukihiro "Matz" Matsumoto ec390e8f1b Update mrb_get_args reference comment; ref #3963 2018-03-16 08:18:52 +09:00
Yukihiro "Matz" Matsumoto 6c84e6e4a5 Merge pull request #3969 from hfm/patch-1
Fix tinytypo
2018-03-16 08:18:38 +09:00
Okumura Takahiro 0664c452ee Fix tinytypo 2018-03-16 00:19:09 +09:00
Yukihiro "Matz" Matsumoto 59dabb38ab Merge pull request #3963 from dearblue/forced-block-arguments
Give me block by mrb_get_args() (forced block arguments)
2018-03-12 22:14:08 +09:00
Yukihiro "Matz" Matsumoto 843053c97c Merge pull request #3965 from take-cheeze/patch-1
Add same fix as #3964 to lib/mruby/gem.rb .
2018-03-05 10:51:32 +09:00
Takeshi Watanabe e8cea2accf Add same fix as #3964 to lib/mruby/gem.rb . 2018-03-05 10:38:44 +09:00
Yukihiro "Matz" Matsumoto e924501693 Merge pull request #3964 from take-cheeze/patch-1
Close `mrb_state` before error exit.
2018-03-05 10:26:02 +09:00
Takeshi Watanabe 0f5cf385b8 Close mrb_state before exit. 2018-03-05 10:13:55 +09:00
Takeshi Watanabe 94aebe3137 Close on exception too. 2018-03-05 10:12:33 +09:00
dearblue a5ac49de30 fix && to &! in mrb_get_args() 2018-03-04 23:48:45 +09:00
dearblue 2ce6d23db6 add forced block arguments feature to mrb_get_args 2018-03-04 22:23:47 +09:00
Yukihiro "Matz" Matsumoto 10f28fc82d Add mrb_fiber_alive_p to C API. 2018-03-02 10:14:36 +09:00
Yukihiro "Matz" Matsumoto a95b6d34aa Round up the dstlen value; fix #3949
The fix was proposed by https://hackerone.com/aerodudrizzt
2018-03-02 10:14:36 +09:00
Takeshi Watanabe 92641248fa Pass same mode parameter to IO.sysopen and IO.open in IO.read. 2018-02-23 20:42:13 +09:00
Yukihiro "Matz" Matsumoto 097bfdcac5 Merge pull request #3953 from take-cheeze/fix_cross_test_runner_verbose
Add verbose flag to cross test runner too. [experimental]
2018-02-17 18:34:46 +09:00
Takeshi Watanabe 5d43a93046 Add verbose flag to cross test runner too. 2018-02-16 23:44:58 +09:00
Yukihiro "Matz" Matsumoto 75c1fccd08 Check if to_int returns fixnum value; fix #3946 2018-02-13 09:12:39 +09:00
Yukihiro "Matz" Matsumoto ef1a0e6358 Check sizeof(base64_dec_tab) in base64 encoding; fix #3947
The issue (and the fix) reported by https://hackerone.com/aerodudrizzt
2018-02-13 08:55:24 +09:00
Yukihiro "Matz" Matsumoto 7483753094 Check negative offset in pack method; fix #3944 2018-02-13 08:48:23 +09:00
Yukihiro "Matz" Matsumoto c5ec37a8ab Fixed wrong offset in pack_x function; ref #3944 2018-02-13 08:47:33 +09:00
Yukihiro "Matz" Matsumoto 00845ea908 Use 'mrb_raise instead of mrb_raisef` when no argument given. 2018-02-13 08:35:01 +09:00
Yukihiro "Matz" Matsumoto 1d55260423 String#inspect to use hexadecimal, not octal to print unprintable. 2018-02-12 22:56:24 +09:00
Yukihiro "Matz" Matsumoto b9523d0e06 Merge pull request #3945 from take-cheeze/fix_dep_core_gems
Fix core dependencies resolving in dependencies gems.
2018-02-12 22:41:31 +09:00
Yukihiro "Matz" Matsumoto 2c84d94854 Merge pull request #3915 from llothar/master
Uncommented the Visual Studio version check
2018-02-12 09:32:35 +09:00
Yukihiro "Matz" Matsumoto 4790f28d62 Resolve conflicts between labels and conditional ternary; fix #3931 2018-02-12 09:28:09 +09:00
Takeshi Watanabe 3dc8634d86 Fix core dependencies resolving in dependencies gems. 2018-02-10 23:23:57 +09:00
Yukihiro "Matz" Matsumoto 7a116f27e4 Need to determine IS_LABEL_POSSIBLE() properly.
Otherwise, `{"a": 1}` will cause `SyntaxError`.
2018-02-10 17:17:36 +09:00
Yukihiro "Matz" Matsumoto 79cfa377e1 Check negative count in pack_x and unpack_x; fix #3944 2018-02-10 16:59:14 +09:00
Yukihiro "Matz" Matsumoto 4f31bcbc84 Add mruby-io and mruby-pack to default.gembox 2018-02-10 16:58:59 +09:00
Yukihiro "Matz" Matsumoto 4c1494d58f Check if mruby-pack template count overflow; fix #3942 2018-02-09 12:55:13 +09:00
Yukihiro "Matz" Matsumoto b43c146455 Check ensure proc is NULL before calling; fix #3943 2018-02-09 12:34:54 +09:00
Yukihiro "Matz" Matsumoto 4c18e37f71 Merge pull request #3941 from matsumotory/patch-1
Depend mruby-io and mruby-pack in mruby core
2018-02-04 00:01:03 +09:00
MATSUMOTO, Ryosuke 6ae4fb707a Depend mruby-io and mruby-pack in mruby core 2018-02-03 14:57:12 +09:00
Yukihiro "Matz" Matsumoto e02cbb4426 Need fcntl.h and sys/stat.h as well for _open; ref #3938 2018-02-02 14:58:09 +09:00
Yukihiro "Matz" Matsumoto c9fa7b1919 Need to include io.h anyway for _WIN32/64; ref #3938 2018-02-02 14:18:25 +09:00
Yukihiro "Matz" Matsumoto cafe6ce4f4 Merge pull request #3940 from take-cheeze/fix_proc_ctx_access
Fix possible memory access error.
2018-02-02 14:16:10 +09:00
Takeshi Watanabe 3c18ec27e9 Fix possible memory access error. 2018-02-02 13:30:32 +09:00
Yukihiro "Matz" Matsumoto 6f1e1777cb Merge pull request #3938 from mattn/include-io
include io.h on mingw
2018-01-31 12:32:23 +09:00
Yasuhiro Matsumoto 0e0dad7697 include io.h on mingw 2018-01-31 12:18:35 +09:00
Yukihiro "Matz" Matsumoto f7ff2d0ee3 Define compatibility only for _MSC_VER; ref #3923
Suggested by @mattn.
2018-01-31 12:10:51 +09:00
Yukihiro "Matz" Matsumoto 1ad2dd6187 Merge pull request #3923 from ksss/tempnam
Shouldn't use tempnam
2018-01-31 11:58:49 +09:00
ksss e422ba0bff Use mkstemp instead of tempnam 2018-01-31 11:34:29 +09:00
Yukihiro "Matz" Matsumoto 55431b4cef Need not to pop callinfo on OP_STOP. 2018-01-30 22:55:58 +09:00
Yukihiro "Matz" Matsumoto 43594843d7 Merge pull request #3937 from mattn/file-mtime
add File#mtime
2018-01-30 21:39:08 +09:00
Yasuhiro Matsumoto f4f006ba40 add File#mtime 2018-01-30 16:02:00 +09:00
Yukihiro "Matz" Matsumoto 3498a787ba Merge pull request #3936 from ken-mu/uint
mruby-time: support time_t is uint
2018-01-30 12:42:49 +09:00
ken-mu a1b71b64b3 mruby-time: remove ifdef for mktime error handling 2018-01-29 09:43:43 +00:00
ken-mu 6a2c0c6e2a mruby-time: support time_t is uint 2018-01-28 03:03:20 +00:00
Yukihiro "Matz" Matsumoto 83f2654bac Do not use MRB_METHOD_TABLE_INLINE by default; fix #3924
It was default on Linux. Abandoned for 2 reasons:

* some cross-platform compiler defines `__linux__` even on bare metal
  environment (RTL8196 (MIPS big endian soc) for example).

* some compilers do not align functions pointers so that we need to
  specify `-falign-functions=n` (where n>1). It's not suitable for
  default configuration.

By our measurement, `mrbtest` consumes 400KB less memory. So if your
target machine is memory tight, add the following command-line options
to `GCC` (unfortunately `clang` does not support `-falign-functions`).

`-falign-functions=2 -DMRB_METHOD_TABLE_INLINE`
2018-01-25 14:22:01 +09:00
Yukihiro "Matz" Matsumoto ec1a5af719 Use LSB not MSB for MRB_METHOD_TABLE_INLINE; ref #3924 2018-01-25 14:02:38 +09:00
Yukihiro "Matz" Matsumoto d895861a30 Check arena_idx before accessing; fix #3934 2018-01-25 12:30:10 +09:00
Yukihiro "Matz" Matsumoto 0e93f1ff12 Merge pull request #3921 from ksss/cloexec
Should be true for close_on_exec flag
2018-01-24 22:04:05 +09:00
Yukihiro "Matz" Matsumoto dfb56074d6 Add big_endian and little_endian methods to CrossBuild; ref #3922
When your target machine is big endian, specify as following in the
`build_config.rb`:

```ruby
MRuby::CrossBuild.new('32bit') do |conf|
  toolchain :gcc

  conf.big_endian
end
```
2018-01-24 21:42:25 +09:00
Yukihiro "Matz" Matsumoto 3ff56a8e55 Time.new(1969,12,31,23,59,59) may or may not faile; ref #3932
On some platform and timezone it is a valid time spec.
2018-01-24 21:42:25 +09:00
Yukihiro "Matz" Matsumoto f8ab3c1eeb Merge pull request #3932 from ken-mu/timegm
mruby-time: Fix mruby specific timegm() cannot return minus
2018-01-21 21:10:01 +09:00
ken-mu d398cd47d7 mruby-time: remove test case less than Dec 31 23:59:58 1969 2018-01-21 02:47:17 +00:00
ken-mu a1f36316d2 mruby-time: Fix mruby specific timegm() cannot return minus 2018-01-20 13:09:58 +00:00
Yukihiro "Matz" Matsumoto e5fb21b6d2 Detect cyclic link of class path references; fix #3926 2018-01-17 09:41:26 +09:00
Yukihiro "Matz" Matsumoto 3ae621fcb3 Typo fixed. 2018-01-17 09:38:41 +09:00
Yukihiro "Matz" Matsumoto ec63b1a0e0 Limit size of iseq buffer; fix #3927 2018-01-16 15:17:56 +09:00
Yukihiro "Matz" Matsumoto ca837b1a24 Allow -> do rescue; end as well as proc do rescue; end [Ruby2.6] 2018-01-16 15:08:51 +09:00
Yukihiro "Matz" Matsumoto 03e88b9ae0 Merge pull request #3930 from mruby/stable
Set the mruby-1.4.0 release date to `2018-1-16`.
2018-01-16 15:07:53 +09:00
Hiroshi Mimaki 58fb6f421a Set the mruby-1.4.0 release date to 2018-1-16. 2018-01-16 10:15:19 +09:00
ksss dc9c40f72d Remove trailing space 2018-01-14 22:40:46 +09:00
ksss 540efd3730 IO#close_on_exec? is not supported on MinGW 2018-01-14 22:40:46 +09:00
ksss e5e9d03482 Should be true for close_on_exec flag 2018-01-14 22:40:45 +09:00
Yukihiro "Matz" Matsumoto 623436276e Merge pull request #3916 from mimaki/mruby-socket-cygwin-test
Passed mruby-test on Cygwin.
2017-12-26 15:51:18 +09:00
Hiroshi Mimaki f55df0da7b addrinfo.ai_protocol was not set on Cygwin. 2017-12-26 11:12:49 +09:00
Hiroshi Mimaki bce811a53a Disabled UNIXSocket test on Cygwin 2017-12-26 11:05:28 +09:00
Yukihiro "Matz" Matsumoto 6b09692684 Add `Integer#{allbits?,anybits?,nobits?}. [Ruby2.5]
In mruby, those methods are defined in `Integral` module.
2017-12-26 09:44:39 +09:00
Yukihiro "Matz" Matsumoto 3d7141b7fe Move Intefer#chr to Integral#chr.
Since mruby mixes `Integer` and `Float`, integer operations have
been moved to `Integral` module.
2017-12-26 09:42:34 +09:00
Yukihiro "Matz" Matsumoto ad17ba0e11 KeyError from Hash#fetch should inspect key.
To distinguish string keys and symbol keys.
2017-12-25 23:52:40 +09:00
Yukihiro "Matz" Matsumoto e4a9b4a3ad `Enumerable#{one?,none?,all?,any?} to take pattern argument [Ruby2.5] 2017-12-25 23:43:43 +09:00
Yukihiro "Matz" Matsumoto 421819dc2c Add Hash#slice [Ruby 2.5] 2017-12-25 23:43:37 +09:00
Yukihiro "Matz" Matsumoto df68a3345d assert_equal() takes result as the first argument 2017-12-25 15:39:45 +09:00
Lothar Scholz a9d0d90f74 Removed the Visual Studio Version Check because it does not
work with internationalized versions of Visual Studio. It will capture
the returned string in the local codepage encoding and make ruby exits
with an invalid UTF8 error message.

Also "Version" might be translated and not appear in the output.
2017-12-24 06:28:38 +01:00
Yukihiro "Matz" Matsumoto 2a5545cc25 Update Kernel#method_missing tests for new NoMethodError message.
Also removed tests that depends on implementation details of the default
`method_missing` behavior.
2017-12-23 15:18:13 +09:00
Yukihiro "Matz" Matsumoto 6999e45742 Do not include object string representation in NoMethodError message.
This information is not mandatory but causes a lot of problems in the
past due to infinite recursion by redefining `to_str`, `inspect` etc.
2017-12-23 15:15:03 +09:00
Yukihiro "Matz" Matsumoto ca0f32a208 super should raise TypeError when the receiver is switched; fix #3911
The receiver can be switched using `#instance_eval` etc.
2017-12-23 11:14:12 +09:00
Yukihiro "Matz" Matsumoto aa8786f79c Do not initialize a local variable soon to be assigned. 2017-12-23 11:14:12 +09:00
Yukihiro "Matz" Matsumoto 7e520838b3 Avoid infinite recursion in method_missing; ref #3908 2017-12-23 11:13:27 +09:00
Yukihiro "Matz" Matsumoto 44b4f69fce May need more stack space in mrb_funcall_with_block; fix #3908 2017-12-23 10:01:30 +09:00
Yukihiro "Matz" Matsumoto 8d7e95282c Add #module_exec and #class_exec in mruby-class-ext gem. 2017-12-23 10:01:30 +09:00
Yukihiro "Matz" Matsumoto 7fbbd7ab9f Should not overwrite ci->target_class in mrb_exec_irep().
For example, the following code behaved wrong:

```ruby
Object.instance_exec(1,2,3){|*a|
  def foo
    42
  end
}
p foo()
```
2017-12-23 10:01:30 +09:00
Yukihiro "Matz" Matsumoto 7990bb7fa7 Merge pull request #3913 from llothar/master
Make source compilable with C++17
2017-12-23 09:44:00 +09:00
Lothar Scholz 06f90a3b45 Make source compilable with C++17
Changes applied:

- Removing "register" keyword
- Fixing const pointer to pointer assignments
- Adding type casts to rb_malloc calls
2017-12-23 01:10:43 +01:00
Yukihiro "Matz" Matsumoto 100f0e6759 Do not need to take target_class from the upper proc.
Since it is already set in `mrb_proc_new()`.
2017-12-20 19:37:26 +09:00
Yukihiro "Matz" Matsumoto 73b05f0130 Should not overwrite MRB_PROC_TARGET_CLASS(p) if p has env; fix #3905 2017-12-20 19:37:26 +09:00
Yukihiro "Matz" Matsumoto 165e7b181b Fixed method look-up for method_missing in OP_SUPER; ref #3905
Method look-up for `OP_SUPER` should start from the superclass of
the `target_class` but if it fails, the look-up for `method_missing`
should start from the class of the receiver.

The following code explains the case:
```ruby
class Bar
  def foo
    super
  end
end

class Foo<Bar
  def method_missing(mid, *)
    p mid
  end
end
```
Foo.new.foo
2017-12-20 19:37:26 +09:00
Yukihiro "Matz" Matsumoto d0f60182af The superclass info should be taken from `TARGET_CLASS(ci->proc).
Not from `ci->target_class` that may be switched using `class_eval` etc.
fix #3899, fix #3906

We found out there is a mruby specific limitation that `super` may be
screwed up when a method is defined in a module and `super` is called
in the block with the target class switched (for example, `super` in
`class_eval` block).  Now we raise `RuntimeError` for such cases.

The following code works in CRuby but not in mruby.
```
module M
  def foo
    "aaa".singleton_class.class_eval{super 2}
  end
end
class Foo
  def foo(*); end
end
class Bar<Foo
  include M
end
Bar.new.foo
```
2017-12-20 10:34:54 +09:00
Yukihiro "Matz" Matsumoto d9049c10fa Merge pull request #3904 from ksss/mruby-method
Add mruby-method
2017-12-18 11:59:36 +09:00
Yukihiro "Matz" Matsumoto bba6c9a1ce Fix descriptor leakage; ref #3903 2017-12-18 11:55:12 +09:00
Yukihiro "Matz" Matsumoto e5056d058a Fix fptr leakage; ref #3903 2017-12-18 11:55:12 +09:00
Yukihiro "Matz" Matsumoto 83d02bcd5a Use _dup2 instead of dup2 on Windows; ref #3903 2017-12-18 11:55:12 +09:00
Yukihiro "Matz" Matsumoto 5e22e8e350 open on Windows takes int 3rd argument instead of mode_t. 2017-12-18 11:15:27 +09:00
ksss c0914dbb65 mruby/data.h doesn't need 2017-12-18 11:11:44 +09:00
Yukihiro "Matz" Matsumoto b4dcb8f286 Use _dup instead of dup on Windows; ref #3903 2017-12-18 11:10:49 +09:00
ksss 615f296fcf Clean up some files and docs 2017-12-18 11:10:10 +09:00
ksss ae786b18d5 Shouldn't use alloca 2017-12-18 11:05:55 +09:00
Yukihiro "Matz" Matsumoto a510564d6d Merge pull request #3903 from ksss/io-dup
Implement IO#initialize_copy
2017-12-18 10:58:12 +09:00
ksss b83ff8ccd8 Add mrbgems/mruby-method
from https://github.com/ksss/mruby-method/commit/0837a0b507a5b4cdf8a1f1039ee371cee4e3b7fb
2017-12-18 10:54:37 +09:00
ksss 35185e69bf Implement IO#initialize_copy 2017-12-17 18:02:37 +09:00
Yukihiro "Matz" Matsumoto ddb1aae41d Need to set ci->proc before calling methods; fix #3902 2017-12-16 09:33:37 +09:00
Yukihiro "Matz" Matsumoto 03614ed918 Need to clear exception handler on return; fix #3898 2017-12-16 09:17:07 +09:00
Yukihiro "Matz" Matsumoto 05129ab9b3 Check if destinations are too distant; fix #3900 fix #3901 2017-12-15 17:57:45 +09:00
Yukihiro "Matz" Matsumoto 7ecb96a00a Merge pull request #3897 from mimaki/initialize-is_socket
Initialized mrb_io.is_socket
2017-12-14 13:58:27 +09:00
Hiroshi Mimaki 41039524a9 Initialized mrb_io.is_socket 2017-12-14 12:36:25 +09:00
Yukihiro "Matz" Matsumoto 5b304c156c On Windows, _S_IREAD and _S_IWRITE is defined in sys/stat.h. 2017-12-14 01:19:44 +09:00
Yukihiro "Matz" Matsumoto 7ac39333b5 Use _open and _close on Windows. 2017-12-14 01:19:21 +09:00
Yukihiro "Matz" Matsumoto ebf49932c7 Merge pull request #3895 from mattn/fix-mkstemp
fix mkstemp implementation for MSVC
2017-12-14 00:46:19 +09:00
Yasuhiro Matsumoto e7e5db51de fix mkstemp implementation for MSVC 2017-12-14 00:43:38 +09:00
Yukihiro "Matz" Matsumoto f0379c8c45 Merge pull request #3892 from mimaki/ipproto-winsock
Use IPPROTO enum values on WinSock.
2017-12-14 00:09:45 +09:00
Yukihiro "Matz" Matsumoto 16e473caad Rename BasicSocket#is_socket= to #_is_socket; ref #3878 2017-12-14 00:07:42 +09:00
Yukihiro "Matz" Matsumoto 69ad12de06 Exclude UNIXSocket tests again; ref #3878 2017-12-14 00:05:23 +09:00
Takeshi Watanabe d2163d13a8 Declare super class in socket.rb. 2017-12-14 00:05:23 +09:00
Takeshi Watanabe 949bf6ca43 Fix socket closing by using closesocket API in windows instead. 2017-12-14 00:05:23 +09:00
Yukihiro "Matz" Matsumoto 2300c9f737 Merge pull request #3893 from mimaki/add-mrbgem-summary
Added mrbgem's summary.
2017-12-14 00:00:10 +09:00
Yukihiro "Matz" Matsumoto dc5de38414 Merge pull request #3894 from mattn/mirb-locale
fix locale message in mirb
2017-12-13 23:11:49 +09:00
Yukihiro "Matz" Matsumoto 1a150a6e48 Merge pull request #3891 from mimaki/set-addrinfo-protocol
Set protocol of AddrInfo
2017-12-13 23:00:25 +09:00
Yasuhiro Matsumoto 0ab9ac6b22 fix locale in mirb 2017-12-13 22:28:18 +09:00
Hiroshi Mimaki 584e4e413a Added mrbgem's summary. 2017-12-13 16:05:06 +09:00
Hiroshi Mimaki 9fac1a3f8b Use IPPROTO enum values on WinSock. 2017-12-13 15:58:23 +09:00
Hiroshi Mimaki 398da99d05 Set protocol of AddrInfo 2017-12-13 14:44:13 +09:00
Yukihiro "Matz" Matsumoto 55fced30cd Use _tempnam instead of tempnam on Windows. 2017-12-13 14:17:49 +09:00
Yukihiro "Matz" Matsumoto a3925f3dec Merge pull request #3889 from mattn/fix-crash
fix crash bug on Windows
2017-12-13 14:10:44 +09:00
Yukihiro "Matz" Matsumoto aec65f2605 Merge pull request #3890 from mimaki/mruby-socket-windows-test
Skip tests on Windows platform
2017-12-13 13:59:28 +09:00
Hiroshi Mimaki 4353623b72 Skip tests on Windows platform 2017-12-13 13:02:59 +09:00
Yasuhiro Matsumoto 6123d653b7 fix crash bug on Windows 2017-12-13 12:48:26 +09:00
Yukihiro "Matz" Matsumoto fa33bd86a8 Remove VC++ compiler warnings. 2017-12-13 11:39:32 +09:00
Yukihiro "Matz" Matsumoto 7d940e3682 Merge pull request #3888 from mattn/fix-locale
fix path locales
2017-12-13 10:24:52 +09:00
Yasuhiro Matsumoto 16c2ac2588 fix path locales 2017-12-13 10:12:59 +09:00
Yukihiro "Matz" Matsumoto e14387440e Skip test/t/float.rb tests; ref #3827 2017-12-13 08:45:46 +09:00
Yukihiro "Matz" Matsumoto 11b6696ce2 Retrieve operands at the beginning of OP_SCLASS. 2017-12-13 08:43:15 +09:00
Yukihiro "Matz" Matsumoto e647b16d1d Should not define Float class in mrblib/00class.rb; ref #3828
Unless it is defined in `numeric.c`.
2017-12-13 08:42:07 +09:00
Yukihiro "Matz" Matsumoto ad06781107 Fixed wrong MRB_WITHOUT_FLOAT condition; ref #3827 2017-12-13 08:38:34 +09:00
Yukihiro "Matz" Matsumoto c66978521d Reduce VC++ type mismatch warnings. 2017-12-13 08:10:35 +09:00
Yukihiro "Matz" Matsumoto 5a5adafabf Merge pull request #3886 from mattn/io-windows
implement popen/flock on Windows
2017-12-13 07:56:24 +09:00
Yasuhiro Matsumoto b07269584c fix build for MSVC 2017-12-13 00:21:30 +09:00
Yasuhiro Matsumoto e0e23b1765 close file descriptors 2017-12-13 00:18:02 +09:00
Yasuhiro Matsumoto 7c8c9f9532 mingw have mkstemp 2017-12-13 00:08:10 +09:00
Yasuhiro Matsumoto 7ff907f680 fix test 2017-12-13 00:07:51 +09:00
Yasuhiro Matsumoto f1ea7a31c0 implement flock on Windows 2017-12-12 23:21:41 +09:00
Yasuhiro Matsumoto df2c3771f8 fix compilation error 2017-12-12 22:39:21 +09:00
Yasuhiro Matsumoto f6f8bb2416 fix compilation error 2017-12-12 22:39:20 +09:00
Yasuhiro Matsumoto 06ec17de60 add definition for pid_t on MSVC 2017-12-12 22:39:19 +09:00
Yasuhiro Matsumoto d549603a8a close handle 2017-12-12 22:39:18 +09:00
Yasuhiro Matsumoto b8ca0b7cd8 implement popen on Windows 2017-12-12 22:39:17 +09:00
Yukihiro "Matz" Matsumoto c863e0dac8 Merge pull request #3885 from Shokuji/cygwin_mruby_io_test
fixed mruby-io so that the test passes on cygwin
2017-12-12 22:34:10 +09:00
Yukihiro "Matz" Matsumoto c6ea948030 Revert "Update .travis.yml to use gcc-6"
This change caused Travis CI errors on OSX.  This reverts
commit c76631d445.
2017-12-12 22:31:14 +09:00
Yukihiro "Matz" Matsumoto 346ebfb0ea Merge pull request #3882 from mattn/fix-filename
use filename in locale
2017-12-12 22:27:25 +09:00
Yukihiro "Matz" Matsumoto 25bee356b1 Merge pull request #3884 from mimaki/mruby-io-test-on-windows
Fixed mruby-io test failure on Windows platform.
2017-12-12 22:21:08 +09:00
Yasuhiro Matsumoto 17cd7a65e7 fix wrong variable name 2017-12-12 18:52:41 +09:00
Yasuhiro Matsumoto bceb6640fa fix compilation error 2017-12-12 18:52:41 +09:00
Yasuhiro Matsumoto 977f79478f use filename in locale 2017-12-12 18:52:40 +09:00
Yukihiro "Matz" Matsumoto bbb0882343 Modifying frozen objects will raise FrozenError.
`FrozenError` is a subclass of `RuntimeError` which used to be
raised.  [Ruby2.5]
2017-12-12 18:41:18 +09:00
Yukihiro "Matz" Matsumoto d4ff92bcf6 Do not use FIXABLE when mrb_int is big enough. 2017-12-12 17:45:15 +09:00
Yukihiro "Matz" Matsumoto 3d98fa2e46 Reduce type mismatch warnings in pack.c. 2017-12-12 17:45:15 +09:00
Yukihiro "Matz" Matsumoto a5b8603aa2 Winsock uses int where UNIX uses size_t. 2017-12-12 17:45:15 +09:00
Yukihiro "Matz" Matsumoto a9e434e69a Merge pull request #3883 from mattn/fix-ssize_t
fix build on mingw
2017-12-12 17:31:26 +09:00
窪山 翔士 e71a6a7b2c fixed mruby-io so that the test passes on cygwin 2017-12-12 17:29:05 +09:00
Hiroshi Mimaki 5ef8f18e9b Fixed mruby-io test failure on Windows platform. 2017-12-12 16:57:13 +09:00
Yasuhiro Matsumoto 99328695e3 fix build on mingw 2017-12-12 16:47:34 +09:00
Yukihiro "Matz" Matsumoto 9c0426c990 Winsock does not provide ssize_t; Use int instead. 2017-12-12 09:52:39 +09:00
Yukihiro "Matz" Matsumoto 2db06c471e Revert "Update .travis.yml"
This reverts commit f73ac4112f.
This change caused Travis errors.
2017-12-12 09:49:26 +09:00
Yukihiro "Matz" Matsumoto 08a508cbee Fixed the mixture of int and long in mruby-pack. 2017-12-12 09:48:53 +09:00
Yukihiro "Matz" Matsumoto 5bf60b4837 Merge pull request #3881 from mame/mrb_without_float-for-mruby-io-and-mruby-pack
Support MRB_WITHOUT_FLOAT to mruby-io and mruby-pack
2017-12-12 07:49:30 +09:00
Yusuke Endoh d96b2c9a76 Support MRB_WITHOUT_FLOAT to mruby-io and mruby-pack 2017-12-12 00:47:56 +09:00
Yukihiro "Matz" Matsumoto 85fc9b88d0 Merge pull request #3880 from mruby/matz-patch-1
Update .travis.yml
2017-12-11 23:23:10 +09:00
Yukihiro "Matz" Matsumoto f73ac4112f Update .travis.yml 2017-12-11 22:17:30 +09:00
Yukihiro "Matz" Matsumoto 0e452a75ac Update .travis.yml 2017-12-11 19:36:52 +09:00
Yukihiro "Matz" Matsumoto b763759972 Reduce VC++ compiler warnings. 2017-12-11 17:22:46 +09:00
Yukihiro "Matz" Matsumoto c76631d445 Update .travis.yml to use gcc-6
The patch is created by @take_cheese in #3872
2017-12-11 17:19:49 +09:00
Yukihiro "Matz" Matsumoto 6d42195fb2 Add enable_sanitizer method for clang and gcc.
The patch is created by @take_cheese in #3872
2017-12-11 17:14:50 +09:00
Yukihiro "Matz" Matsumoto 274884abe5 Reduce VC++ compiler warnings. 2017-12-09 16:14:12 +09:00
Yukihiro "Matz" Matsumoto 761218e70b Skip socket tests on Windows platform.
Some test may be OK but we skip everything as a starting point.
2017-12-09 14:22:53 +09:00
Yukihiro "Matz" Matsumoto b103fa229d File.symlink may not be implemented on some platforms; ref #3877 2017-12-09 14:22:03 +09:00
Yukihiro "Matz" Matsumoto bda273f35d Merge pull request #3877 from bamchoh/patch-3
Skip "File.readlink fails" test on MSVC
2017-12-09 14:16:20 +09:00
Yukihiro "Matz" Matsumoto 6bc38f4637 Merge pull request #3876 from bamchoh/patch-2
Use same format between Fail and Skip
2017-12-09 13:15:10 +09:00
bamchoh 0ded91c806 Skip "File.readlink fails" test on MSVC
When MSVC, "File.readlink fails with non-symlink" test was failed even if raising NotImplementedError
2017-12-09 03:27:05 +09:00
bamchoh 81dc383291 Use same format between Fail and Skip
We can see gem name in skip message by this fix
2017-12-09 02:12:37 +09:00
Yukihiro "Matz" Matsumoto 550c878216 Use RL_READLINE_VERSION to determine rl_free existence; fix #3875 2017-12-08 21:49:12 +09:00
Yukihiro "Matz" Matsumoto e17092debd Merge pull request #3874 from mimaki/fix-mingw-compile-error
Fixed compile error of `mruby-io` gem on MinGW.
2017-12-08 14:34:10 +09:00
Yukihiro "Matz" Matsumoto c47a1984b4 Merge pull request #3873 from take-cheeze/fix_socket_test_leak
Fix memory leak found by leak sanitizer.
2017-12-08 14:33:49 +09:00
Hiroshi Mimaki 7f3bda5653 Fixed compile error of mruby-io gem on MinGW. 2017-12-08 12:58:26 +09:00
Takeshi Watanabe 5de7dc2948 Fix memory leak found by leak sanitizer. 2017-12-08 12:10:28 +09:00
Yukihiro "Matz" Matsumoto 83065df67a Reduce compiler warnings from mruby-io gem. 2017-12-08 10:07:41 +09:00
Yukihiro "Matz" Matsumoto f9d1d72217 Avoid VC++ reserved word template. 2017-12-08 09:55:55 +09:00
Yukihiro "Matz" Matsumoto 36a0b864ba Reduce VC++ compiler warnings. 2017-12-08 09:50:02 +09:00
Yukihiro "Matz" Matsumoto f1207573bd Uninitialized value returned. 2017-12-08 09:50:02 +09:00
Yukihiro "Matz" Matsumoto 6ebcb7417a AppVeyor compile errors resolution. 2017-12-08 09:37:50 +09:00
Yukihiro "Matz" Matsumoto 9df7bceb15 AppVeyor compiler does not proved some POSIX functions.
- `mode_t` by `int`
- `umask` by `_umask`
- `rmdir` by `_rmdir`
- `mkstemp` and `mkdtemp` by using `_mktemp`
2017-12-08 09:19:59 +09:00
Yukihiro "Matz" Matsumoto b724e06cf2 Avoid uninitialized local variables in mruby-pack. 2017-12-07 20:28:30 +09:00
Yukihiro "Matz" Matsumoto bc9e3e6fd0 Add type cast to readline(2) return value. 2017-12-07 20:26:34 +09:00
Yukihiro "Matz" Matsumoto 764a568aa4 Remove unused variable usock from mruby-socket/src/socket.c. 2017-12-07 20:25:40 +09:00
Yukihiro "Matz" Matsumoto ff1194c134 fixup! Fix type casting errors when mruby-socket compiled by C++. 2017-12-07 20:24:13 +09:00
Yukihiro "Matz" Matsumoto a5412d48fd Add 'mrbgems/mruby-pack/' from commit '383a9c79e191d524a9a2b4107cc5043ecbf6190b'
git-subtree-dir: mrbgems/mruby-pack
git-subtree-mainline: 842e6945f2
git-subtree-split: 383a9c79e1
2017-12-07 18:35:09 +09:00
Yukihiro "Matz" Matsumoto 842e6945f2 Fix type casting errors when mruby-socket compiled by C++.
Also `bool` is a reserved word in C++.
2017-12-07 18:23:01 +09:00
Yukihiro "Matz" Matsumoto 73ef548c63 Add 'mrbgems/mruby-socket/' from commit 'ab54185005ec87fe4f5b10df95ad29659884141b'
git-subtree-dir: mrbgems/mruby-socket
git-subtree-mainline: d75266dd1b
git-subtree-split: ab54185005
2017-12-07 18:11:13 +09:00
Yukihiro "Matz" Matsumoto d75266dd1b Add 'mrbgems/mruby-io/' from commit '3c8e1f94c44252c836f79a48bb17726da28e2756'
git-subtree-dir: mrbgems/mruby-io
git-subtree-mainline: 10ed730e4b
git-subtree-split: 3c8e1f94c4
2017-12-07 18:11:06 +09:00
Yukihiro "Matz" Matsumoto 10ed730e4b Cancel df3507660 that does not do any good. 2017-12-07 15:18:41 +09:00
Yukihiro "Matz" Matsumoto cdf173d32c Avoid updating to reallocated stack in OP_RETURN; fix #3870
The code was introduced to address #3175 but it's no longer needed.
2017-12-07 15:05:14 +09:00
Yukihiro "Matz" Matsumoto 0e46b14b9e The ci should not be equal to cibase with OP_R_BREAK; #3871 2017-12-06 17:28:20 +09:00
Yukihiro "Matz" Matsumoto 6975258efd The proc with top-level env must be 'proc-closure'; fix #3871 2017-12-06 17:28:20 +09:00
Yukihiro "Matz" Matsumoto ae44e80668 Limit ecall() depth to 32 (default). 2017-12-06 17:28:20 +09:00
Yukihiro "Matz" Matsumoto b00d45b095 mrb_method_search_vm() should gives the defined class.
Otherwise `super` may call a wrong method.
2017-12-06 17:28:20 +09:00
Yukihiro "Matz" Matsumoto 4a99f4949e Need to set ci->proc when we have RProc structure.
Mentioned in https://qiita.com/bamchoh/items/eabebbbb330cb0e0470a
2017-12-05 11:43:12 +09:00
Yukihiro "Matz" Matsumoto cbb6f29875 Merge pull request #3868 from bamchoh/patch-1
Revise MRB_METHOD_PROC macro's argument
2017-12-05 06:47:22 +09:00
bamchoh 940133b627 Revise MRB_METHOD_PROC macro's argument
I revised MRB_METHOD_PROC macro's argument fn to m.
2017-12-05 01:22:43 +09:00
Yukihiro "Matz" Matsumoto 1fea63429e Some OS uses libedit that does not provide rl_free().
`libedit` is a `readline` compatible library with BSD license.
2017-12-04 11:53:19 +09:00
Yukihiro "Matz" Matsumoto 0b5d97ec42 Need to unshare env stack on break; fix #3866 2017-12-04 10:15:12 +09:00
Yukihiro "Matz" Matsumoto 6f4d4bbcc7 Remove temporary objects from GC arena in `mrb_vformat()'; #3863 2017-12-04 08:56:11 +09:00
Yukihiro "Matz" Matsumoto 5d04e3316b Check if ci->proc is not NULL and MRB_PROC_CFUNC_P(); fix #3867 2017-12-04 08:56:11 +09:00
Yukihiro "Matz" Matsumoto ff8b608c52 Free read lines using the deallocation function from the library.
To avoid potential `malloc/free` mismatch.
2017-12-04 08:56:11 +09:00
Yukihiro "Matz" Matsumoto cd9f53d42e Pop exception objects from the bottom of GC arena; fix #3863 2017-12-04 08:56:11 +09:00
Yukihiro "Matz" Matsumoto c35a402676 The stack shift width should be determined by p->upper; fix #3864
And check required register number from `ci->proc` as well.
The fixes for #3859 and #3862 were incomplete.
2017-12-01 10:01:46 +09:00
Yukihiro "Matz" Matsumoto 86ef9a2806 Avoid calling mrb_env_unshare() when env is NULL.
Small performance improvement by reducing function invocations.
2017-11-30 08:19:38 +09:00
Yukihiro "Matz" Matsumoto 2b9f762ba1 Avoid double free() of env stack; fix #3860
Should turn on `MRB_ENV_STACK_UNSHARED` flag only after env stack
reallocation.  `malloc()` may fail.
2017-11-30 08:17:14 +09:00
Yukihiro "Matz" Matsumoto d3e273ba4e Wrong stack adjustment in ecall() (f35f975 #3859); fix #3862 2017-11-30 08:04:27 +09:00
Yukihiro "Matz" Matsumoto f3279b41e6 Stop infinite recursion in Class#to_s; fix #3861 2017-11-30 07:58:11 +09:00
Yukihiro "Matz" Matsumoto 5f7cdecdc9 Clear c->prev on fiber termination. 2017-11-29 20:25:55 +09:00
Yukihiro "Matz" Matsumoto b746a0f0d2 Need to free contexts when freeing fibers.
Memory leak fixed; ref #3711
2017-11-29 20:24:03 +09:00
Yukihiro "Matz" Matsumoto 9c78a9bfa2 Set MRB_FIBER_TERMINATED flag on exception termination of a fiber. 2017-11-29 20:17:33 +09:00
Yukihiro "Matz" Matsumoto b7c3a876f1 Add most recent call last message to the backtrace. 2017-11-29 16:56:10 +09:00
Yukihiro "Matz" Matsumoto 3e67a116d1 Call all ensure clauses pushed at OP_STOP. 2017-11-29 12:16:16 +09:00
Yukihiro "Matz" Matsumoto afa53809e2 No need to use ecall_adjust(). 2017-11-29 12:15:24 +09:00
Yukihiro "Matz" Matsumoto f35f975d26 Fixed stack address adjustment in ecall(); fix #3859 2017-11-29 12:14:05 +09:00
Yukihiro "Matz" Matsumoto d4fc980527 Need to evaluate ensure clauses at fiber termination. 2017-11-29 11:57:33 +09:00
Yukihiro "Matz" Matsumoto 6bb5ad786c Remove unnecessary code; ref #3711 2017-11-29 11:44:07 +09:00
Yukihiro "Matz" Matsumoto 597149ae23 Change newline style of test/t/lang.rb (from DOS) 2017-11-22 16:10:28 +09:00
Yukihiro "Matz" Matsumoto b4f9b031de Some cosmetic changes 2017-11-22 16:09:50 +09:00
Yukihiro "Matz" Matsumoto 284a1d12ee Provide shortcut comparison methods for numbers for performance. 2017-11-22 15:43:48 +09:00
Yukihiro "Matz" Matsumoto 0ab21a9a5e Stack adjustment should be based on p->upper; fix #3857
It used to be based on `ci->proc` but the callinfo position may be
wrong when `ecall()` is called during stack rewinding from `OP_RETURN`.
2017-11-22 14:05:11 +09:00
Yukihiro "Matz" Matsumoto fbafa78098 Clear ensure stack after calling in OP_EPOP; #3855 3856 2017-11-22 12:22:45 +09:00
Yukihiro "Matz" Matsumoto 4665b07f7b No need to pop ensure stack if eidx is smaller than epos; #3855 #3856 2017-11-22 12:21:24 +09:00
Yukihiro "Matz" Matsumoto fe3ac50845 fixup! Remove fixed argument of ecall(); ref #3855 #3856 2017-11-22 12:20:56 +09:00
Yukihiro "Matz" Matsumoto cb4b042777 Remove fixed argument of ecall(); ref #3855 #3856 2017-11-22 12:19:40 +09:00
Yukihiro "Matz" Matsumoto 393133e741 Should have marked all ensure stack entries; fix #3855 fix #3856 2017-11-22 12:18:20 +09:00
Yukihiro "Matz" Matsumoto 8b7a8978e2 Reduce the size of struct RBreak to reduce memory usage.
The old size of `struct RBreak` was 56 bytes (`MRB_NO_BOXING`)
and it's bigger than other object structures. That increase the
size of `RVALUE` thus increase the total amount of memory consumption.
2017-11-20 18:33:41 +09:00
Yukihiro "Matz" Matsumoto 8f2c62407c Add MRB_METHOD_TABLE_INLINE option.
Now the method tables (in classes/modules and caches) keeps C function
pointers without wrapping in `struct RProc` objects. For the sake of
portability, `mrb_method_t` is represented by the struct and union, but
if the most significant bit of the pointer is not used by the platform,
`mrb_method_t` should be packed in `uintptr_t` to reduce memory usage.

`MRB_METHOD_TABLE_INLINE` is turned on by default for linux.
2017-11-20 18:33:41 +09:00
Yukihiro "Matz" Matsumoto 6c06e77446 Add MRB_METHOD_CACHE description to include/mrbconf.h 2017-11-20 06:04:27 +09:00
Yukihiro "Matz" Matsumoto 6a9efd6849 Invoke mrb_full_gc() before ObjectSpace.count_objects. 2017-11-19 12:19:46 +09:00
Yukihiro "Matz" Matsumoto 9b2454c94d Leave hash->ht to be NULL if initial capacity is zero. 2017-11-19 03:46:58 +09:00
Yukihiro "Matz" Matsumoto 7405821f5a doc/limitaions.md: Remove infinite recursion entry.
It's fixed since 1.3.0
2017-11-18 21:16:22 +09:00
Yukihiro "Matz" Matsumoto 86f9254df0 doc/limitaions.md: Remove Kernel.binding entry.
Since no ISO classes/methods are not provided by mruby, there's
no use mentioning `Kernel.binding` here.
2017-11-18 21:14:19 +09:00
Yukihiro "Matz" Matsumoto 825e93eba4 Assign operands to local variables. 2017-11-18 00:03:59 +09:00
Yukihiro "Matz" Matsumoto 31ce73ddc3 Merge pull request #3853 from ukrainskiysergey/variable_c_cosmetic_changes
Removed useless condition
2017-11-18 00:03:50 +09:00
Ukrainskiy Sergey a2d0ee59c6 Removed useless condition 2017-11-17 22:30:22 +09:00
Yukihiro "Matz" Matsumoto 269f9f2125 Merge pull request #3852 from dabroz/feature-array-transpose
implement Array.transpose
2017-11-17 21:50:34 +09:00
Tomasz Dąbrowski e65fa4d7a2 implement Array.transpose 2017-11-17 12:39:34 +01:00
Yukihiro "Matz" Matsumoto d01003ce3a Merge pull request #3851 from ukrainskiysergey/variable_c_cosmetic_changes
Cosmetic changes in variable.c
2017-11-17 20:04:37 +09:00
Ukrainskiy Sergey ddd32d74e1 Changed the assignment of a variable in variable.c 2017-11-17 19:43:57 +09:00
Ukrainskiy Sergey 74714c8fee Changed numbers to TRUE and FALSE for mrb_bool in variable.c 2017-11-17 19:16:29 +09:00
Yukihiro "Matz" Matsumoto c8da602752 Need to save stack space by number of registers from the current proc,
Not from the execution ensure proc; fix #3849
2017-11-17 01:08:46 +09:00
Yukihiro "Matz" Matsumoto 03a3bd9178 The number of argument should be retrieved by mrb_get_argc; fix #3848
You should not access `mrb->c->ci->argc` directly.
2017-11-13 16:16:38 +09:00
Yukihiro "Matz" Matsumoto c210a8adf9 Fixed wrong stack extend size; fix #3847 2017-11-11 17:55:32 +09:00
Yukihiro "Matz" Matsumoto 181f980b6c Need to clear stack region for local variables in eval; fix #3844 2017-11-10 21:53:12 +09:00
Yukihiro "Matz" Matsumoto 41c8c419cf Use proper target_class to define class/module; fix #3843
The outer class of the class/module definition should be taken from
`MRB_TARGET_CLASS(mrb->c->ci->proc)` not `mrb->c->ci->target_class`
which is the target of constant lookups.
2017-11-09 00:14:21 +09:00
Yukihiro "Matz" Matsumoto f723832ebc Should allocate memory region before updating len; fix #3842
Otherwise half-baked string object will be allocated.
2017-11-08 08:46:55 +09:00
Yukihiro "Matz" Matsumoto 7ae20e0785 Simplify MRB_WITHOUT_FLOAT condtion 2017-11-08 08:45:59 +09:00
Yukihiro "Matz" Matsumoto 37f6e42293 Removed redundant function prototype. 2017-11-04 17:59:00 +09:00
Yukihiro "Matz" Matsumoto d6cb4f9cf2 Merge branch 'pandax381-mrb_without_float' 2017-11-04 12:33:07 +09:00
Yukihiro "Matz" Matsumoto a751f7f196 Make mirb to print warnings; ref #3827 2017-11-04 12:32:34 +09:00
Yukihiro "Matz" Matsumoto fef4b394a7 Avoid compiling fmt_fp.c if MRB_WITHOUT_FLOAT is set; #3827 2017-11-04 12:12:52 +09:00
Yukihiro "Matz" Matsumoto de2363a9f0 Merge branch 'mrb_without_float' of https://github.com/pandax381/mruby into pandax381-mrb_without_float 2017-11-04 11:49:25 +09:00
Yukihiro "Matz" Matsumoto 388d26d770 Reimplement block_given?; ref #3841
Make `block_given?` to search for the top of the scope first.
The top of the scope means either:

* the top method body
* the enclosing class body
* the top-level

The special case is the method defined by `define_method` with a
block as in #3841. In cases like this, the method body (given by
a block) is not considered as the top of the scope. You need to use
`&block` in the block parameter if you want to know if a block is
given to the method.

This commit also changes the behavior of `MRB_PROC_SCOPE` flag.
Now it is only set if the `proc` is either a class body or a method
body defined in Ruby. It is no longer set for a block that given to
`define_method`.
2017-11-04 11:20:04 +09:00
Yukihiro "Matz" Matsumoto ab27abe083 The bidx saved in env may be useless; fix #3841
When `block_given?` is called from a block given to `define_method`
as a method body, the `bidx` may not be within `env` saved closure.
In this case, it causes heap buffer overflow.
2017-11-04 03:01:37 +09:00
YAMAMOTO Masaya 625f9f6fa3 Merge branch 'master' of github.com:mruby/mruby 2017-11-04 01:23:12 +09:00
Yukihiro "Matz" Matsumoto e7fe6ee263 Avoid pointer arithmetic in backtrace.c; #3816 2017-11-04 00:35:50 +09:00
Yukihiro "Matz" Matsumoto 12e38597c8 Always check division-by-zero to avoid undefined behavior; fix #3816
Also removed the code to normalize NaN value for `MRB_NAN_BOXING`.
Tha code was added to fix #1712 but no longer required after 249f05e7d.
2017-11-03 09:35:55 +09:00
Yukihiro "Matz" Matsumoto d489b41c31 Reduce memory leaks from mirb. 2017-11-03 08:24:47 +09:00
Yukihiro "Matz" Matsumoto e4662d77e7 Should not use FSHARED state for string from irep pools; fix #3829
This strings in `irep` pools may be freed forcefully in `mrb_irep_free`.
This commit probably fixes #3817 as well.
2017-11-03 08:24:47 +09:00
Yukihiro "Matz" Matsumoto 13a318b0c7 Merge pull request #3840 from iij/keep-backtrace-rethrown-exc
don't strip away backtrace info when an exception is re-thrown
2017-11-02 21:36:26 +09:00
Tomoyuki Sahara f6896751b4 don't overwrite backtrace info. 2017-11-02 15:44:05 +09:00
Yukihiro "Matz" Matsumoto ddfb24908c Fixed constant (and class variable) reference bug; fix #3839
Unlike method definition, constant reference should start from
`MRB_PROC_TARGET_CLASS(ci->proc)`, not `ci->target_class`.
In addition, `MRB_PROC_TARGET_CLASS(ci->proc)` is always set.
2017-10-31 09:10:08 +09:00
Yukihiro "Matz" Matsumoto 022570ab8d Call stack may not reference the destination proc; fix #3838
The destination `proc` may be an orphan.
2017-10-31 09:10:08 +09:00
Yukihiro "Matz" Matsumoto b6598e052f Need to mark fibers referenced from env; fix #3837
The issue #3837 is a regression of #3819. I was mistakenly removed
a important code to mark fibers from `env`.
2017-10-31 09:10:08 +09:00
Yukihiro "Matz" Matsumoto 77edafb04c Need to check number of argument of Struct#new; fix #3823 2017-10-29 00:25:45 +09:00
Yukihiro "Matz" Matsumoto 59dc7d0763 Removed a debug printf; fix #3834 2017-10-28 23:39:21 +09:00
Yukihiro "Matz" Matsumoto 1b45e034ba Remove one of the lines that did the same thing; fix #3836
The change is suggested by `ukrainskiysergey` in #3836.
I deleted the other line for clarity. I also updated comment lines.
2017-10-28 23:35:01 +09:00
Yukihiro "Matz" Matsumoto 6316e0c75d Should clear ensure stack at OP_RETURN break; #3715
This is a resurrection of d0a7e01, which is accidentally
removed by 93f5f22; Fix #3715
2017-10-28 23:27:07 +09:00
Yukihiro "Matz" Matsumoto 92e24f809b Should check if callinfo stack is popped before updating the stack.
This is a resurrection of 75c374c, which is accidentally removed by
93f5f22; Fix #3507 #3512 #3518 #3521
2017-10-28 23:10:28 +09:00
Yukihiro "Matz" Matsumoto c7c9543bed Fixed UPVAR gotchas; fix #3835
Both `uvenv` function and `env` generation in `create_proc_from_string`
function have bugs to handling enclosed environment objects.
2017-10-28 23:08:31 +09:00
Yukihiro "Matz" Matsumoto 57dad6e3fd Remove a debug variable 2017-10-28 01:37:51 +09:00
Yukihiro "Matz" Matsumoto 23d18bbd62 Add parentheses to pacify a warning. 2017-10-28 01:32:25 +09:00
Yukihiro "Matz" Matsumoto 93f5f22577 Heavily refactored how lexical scope links are implemented; fix #3821
Instead of `irep` links, we added a `upper` link to `struct RProc`.
To make a space for the `upper` link, we moved `target_class` reference.
If a `Proc` does not have `env`, `target_class` is saved in an `union`
shared with `env` (if a `Proc` has env, you can tell it by `MRB_PROC_ENV_P()).
Otherwise `target_class` is referenced from `env->c`. We removed links
in `env` as well.

This change removes 2 members from `mrb_irep` struct, thus saving 2
words per method/proc/block. This also fixes potential memory leaks
due to the circular references caused by a link from `mrb_irep`.
2017-10-28 00:29:30 +09:00
Yukihiro "Matz" Matsumoto 3f9d00ded3 comment out bench build from standard build_config.rb 2017-10-28 00:29:30 +09:00
Yukihiro "Matz" Matsumoto 4614b9d632 remove inline from replacement memcpy&memset 2017-10-28 00:29:30 +09:00
Yukihiro "Matz" Matsumoto 5405b47f41 Update test for Kernel#local_variables 2017-10-28 00:29:30 +09:00
Yukihiro "Matz" Matsumoto 14877469d1 Remove MRB_API from mrb_env_unshare() 2017-10-28 00:29:30 +09:00
Yukihiro "Matz" Matsumoto 07cf7b16f3 Add some peephole optimizations 2017-10-28 00:29:30 +09:00
Yukihiro "Matz" Matsumoto 6c966a1f86 Change the order of "expected" and "actual" in test 2017-10-28 00:29:30 +09:00
Yukihiro "Matz" Matsumoto 0cf5a0ee37 Use alias to implement attr method 2017-10-28 00:29:30 +09:00
Yukihiro "Matz" Matsumoto fda64be996 Flush stdout after every print from tests 2017-10-28 00:29:30 +09:00
Yukihiro "Matz" Matsumoto 71eeb86a99 Format codedump for OP_{LE,LT,GE,GT}. 2017-10-28 00:29:30 +09:00
Yukihiro "Matz" Matsumoto d08205b40d Merge pull request #3833 from bggd/appveyor_winbison_ruby24
Appveyor Improvements
2017-10-25 00:31:44 +09:00
bggd 7f4cc0de51 Turn on method cache for AppVeyor CI 2017-10-24 21:39:05 +09:00
bggd 7a13e89509 Use Ruby 2.4 instead of AppVeyor's Default(Ruby 1.9) 2017-10-24 21:37:36 +09:00
bggd 8a9b6c4352 Use win_bison instead of Cygwin's bison. Use YACC environment variable instead of global PATH 2017-10-24 21:31:37 +09:00
Yukihiro "Matz" Matsumoto 0c3ee0ba66 Add `Array#{permutation,combination}. 2017-10-20 10:38:58 +09:00
Yukihiro "Matz" Matsumoto f2394859e3 Add main.define_method 2017-10-19 10:39:06 +09:00
Tomoyuki Sahara 3c8e1f94c4 Merge pull request #94 from kazuho/kazuho/rename-compatibility
make `rename` behavior consistent with MRI
2017-10-18 13:22:22 +09:00
Yukihiro "Matz" Matsumoto fc930700b7 Add Kernel#itself; CRuby2.2 2017-10-18 10:21:54 +09:00
Yukihiro "Matz" Matsumoto ce916b99b8 Add Hash#to_proc; CRuby2.3 2017-10-18 10:18:43 +09:00
Yukihiro "Matz" Matsumoto b5dfbce767 Add Numeric#{positive?,negative?}; CRuby2.3 2017-10-18 10:10:37 +09:00
Yukihiro "Matz" Matsumoto 44f07045d1 Add Hash#fetch_values; CRuby2.3 2017-10-18 10:05:39 +09:00
Yukihiro "Matz" Matsumoto 913b83d579 Merge branch 'dabroz-fix-get-argc' 2017-10-17 15:24:00 +09:00
Yukihiro "Matz" Matsumoto 3c20c96f84 Use a new function: mrb_get_argc(); ref #3826 2017-10-17 15:23:32 +09:00
Yukihiro "Matz" Matsumoto b890528a18 Remove mrb_vm_get_argc; ref #3826 2017-10-17 15:22:45 +09:00
Yukihiro "Matz" Matsumoto 344a7ce20c Merge branch 'fix-get-argc' of https://github.com/dabroz/mruby into dabroz-fix-get-argc 2017-10-17 15:07:05 +09:00
Yukihiro "Matz" Matsumoto 4122c320bb Add {String,Symbol}#casecmp?; CRuby2.4 2017-10-17 13:26:37 +09:00
Yukihiro "Matz" Matsumoto db8265f428 Add Comparable#uniq; CRuby2.4 2017-10-17 12:46:51 +09:00
Yukihiro "Matz" Matsumoto 4e365156d1 Add Comparable#clamp; CRuby2.4 2017-10-17 11:19:12 +09:00
Yukihiro "Matz" Matsumoto 061d804a59 Add Numeric#{finite?,infinite?}; CRuby2.4 2017-10-17 11:19:12 +09:00
Yukihiro "Matz" Matsumoto 332d8d2a1c Add String#delete_{prefix,suffix}; CRuby2.5 2017-10-17 11:19:12 +09:00
Yukihiro "Matz" Matsumoto 1519616ecb Add Kernel#yield_self; CRuby2.5 2017-10-17 09:10:13 +09:00
Yukihiro "Matz" Matsumoto c96def7c96 Remove top-level constant lookup; CRuby2.5 2017-10-17 08:45:06 +09:00
Yukihiro "Matz" Matsumoto e59ad60327 do/end blocks to work with rescue/ensure/else; CRuby2.5 2017-10-17 08:17:31 +09:00
Yukihiro "Matz" Matsumoto fb85855fa1 Add more checks before accessing struct pointer; ref #3831 2017-10-17 07:43:35 +09:00
Yukihiro "Matz" Matsumoto be2c1592ed Check struct-array pointer before accessing; fix #3831 2017-10-16 22:53:36 +09:00
Yukihiro "Matz" Matsumoto 1988bec23e Need to adjust the stack length of the top-level environment; fix #3819 2017-10-16 22:35:25 +09:00
Yukihiro "Matz" Matsumoto c3710dbb96 Fix a compile error on zero mrbgem case. 2017-10-16 18:46:15 +09:00
Yukihiro "Matz" Matsumoto 6b0c22e395 Merge pull request #3830 from dearblue/fix-alias-for-struct-accessors
fix alias for Struct accessors
2017-10-16 18:45:52 +09:00
YAMAMOTO Masaya b70d69de09 Support MRB_WIHTOUT_FLOAT to mruby-kernel-ext 2017-10-16 18:15:47 +09:00
YAMAMOTO Masaya 9afd376fa4 Support MRB_WIHTOUT_FLOAT to mruby-object-ext 2017-10-16 18:15:25 +09:00
YAMAMOTO Masaya b0cdb93a3a Support MRB_WIHTOUT_FLOAT to mruby-numeric-ext (test only) 2017-10-16 18:14:34 +09:00
YAMAMOTO Masaya 9c1f21aaa1 Support MRB_WIHTOUT_FLOAT to mruby-string-ext 2017-10-16 18:09:56 +09:00
dearblue 44e2c97152 fix alias for Struct accessors 2017-10-15 23:43:55 +09:00
YAMAMOTO Masaya 5d781312ca Support MRB_WIHTOUT_FLOAT to mruby-sprintf 2017-10-13 16:42:35 +09:00
Yukihiro "Matz" Matsumoto fa974a1f6a Merge pull request #3828 from asfluido/master
Correct a small error in parse.y
2017-10-12 20:19:24 +09:00
Carlo Prelz af3d5d6c8a Correct a small error in parse.y, which causes the reading of unassigned memory (triggers an error when address sanitizer is active) 2017-10-12 09:54:02 +02:00
Kazuho Oku 0d92431061 make the behavior consistent with MRI 2017-10-12 15:23:52 +09:00
YAMAMOTO Masaya 81ea81e05c Fix typo 2017-10-11 19:52:21 +09:00
YAMAMOTO Masaya 3eebe81b35 Upadte AUTHORS 2017-10-11 19:44:34 +09:00
YAMAMOTO Masaya dcd5d0ffec Test for MRB_WITHOUT_FLOAT 2017-10-11 17:58:11 +09:00
YAMAMOTO Masaya acdc2d1f24 Add MRB_WITHOUT_FLOAT 2017-10-11 17:58:11 +09:00
YAMAMOTO Masaya 679dfd75a8 Use division expression instead of some floating point literals 2017-10-11 17:58:11 +09:00
Tomasz Dąbrowski be86d8b45f correctly handle *splat arguments in mrb_get_argc, also add mrb_vm_get_argc and mrb_get_argv
Fixes #3825
2017-10-10 18:40:38 +02:00
Yukihiro "Matz" Matsumoto 80e03f3ffb Merge pull request #3824 from nobu/bug/paren_arg
Bug/paren arg
2017-10-09 12:39:13 +09:00
Nobuyoshi Nakada 82983330a3 Fix parse error on TRICK2013/yhara 2017-10-09 08:56:46 +09:00
Nobuyoshi Nakada 1c2a2827b3 Replace lvar_defined with local_var_p 2017-10-09 08:54:25 +09:00
Tomoyuki Sahara f8121953e7 Merge pull request #92 from palkan/master
Handle shared/frozen strings in IO#sysread
2017-10-05 21:27:58 +09:00
Vladimir Dementyev 43795cb1f1 Remove useless mrb_str_modify 2017-10-05 15:22:57 +03:00
Vladimir Dementyev 4c255c7739 Handle shared/frozen strings in IO#sysread
See https://github.com/mruby/mruby/commit/7edbe428caca6814841195a3f2720745cf04353e
2017-10-05 14:40:43 +03:00
Yukihiro "Matz" Matsumoto c3c882f681 Use uint32_t to avoid signed integer overflow warning; #3816 2017-10-01 17:53:10 +09:00
Yukihiro "Matz" Matsumoto 8c408379aa Add cscope.files to .gitignore. 2017-10-01 16:24:43 +09:00
Yukihiro "Matz" Matsumoto 7edbe428ca Add new type of shared string: RSTR_FSHARED.
`RSTR_FSHARED` use frozen strings as shared body instead of
`struct mrb_shared_string`. This reduces allocation from
literal strings.
2017-10-01 16:24:43 +09:00
Yukihiro "Matz" Matsumoto 473b7d0efd Cut links from irep in heaps finalization. 2017-09-29 00:18:55 +09:00
Yukihiro "Matz" Matsumoto 7b01b969f5 codedump to display OP_CALL. 2017-09-29 00:18:55 +09:00
Yukihiro "Matz" Matsumoto 29a9e698e3 Merge pull request #3815 from dabroz/fix-warnings
Fix MSVC 14.0 warnings
2017-09-29 00:18:39 +09:00
Tomasz Dąbrowski 999ce87129 fix: src\vm.c(2631): warning C4244: '=': conversion from 'mrb_int' to 'int', possible loss of data 2017-09-27 22:22:05 +02:00
Tomasz Dąbrowski 77d6a953ff fix: src\vm.c(1757): warning C4244: '=': conversion from 'mrb_int' to 'int', possible loss of data 2017-09-27 22:22:05 +02:00
Tomasz Dąbrowski ebd45b1072 fix: src\vm.c(1744): warning C4244: '=': conversion from 'mrb_int' to 'int', possible loss of data 2017-09-27 22:22:05 +02:00
Tomasz Dąbrowski 0bff4b6a09 fix: src\vm.c(1702): warning C4244: '=': conversion from 'mrb_int' to 'int', possible loss of data 2017-09-27 22:22:05 +02:00
Tomasz Dąbrowski 885916c84b fix: src\vm.c(708): warning C4244: '=': conversion from 'mrb_int' to 'int', possible loss of data 2017-09-27 22:22:05 +02:00
Tomasz Dąbrowski e88fc10679 fix: src\vm.c(704): warning C4244: '=': conversion from 'mrb_int' to 'int', possible loss of data 2017-09-27 22:22:05 +02:00
Tomasz Dąbrowski ec7f478eda fix: src\vm.c(457): warning C4244: '=': conversion from 'mrb_int' to 'int', possible loss of data 2017-09-27 22:22:05 +02:00
Tomasz Dąbrowski 67ab8406b8 fix: src\vm.c(445): warning C4244: '=': conversion from 'mrb_int' to 'int', possible loss of data 2017-09-27 22:22:05 +02:00
Tomasz Dąbrowski 23cc698134 fix: src\vm.c(438): warning C4244: '=': conversion from 'mrb_int' to 'int', possible loss of data 2017-09-27 22:22:05 +02:00
Tomasz Dąbrowski 5ede90cdf4 fix: src\vm.c(438): warning C4244: '=': conversion from 'mrb_int' to 'int', possible loss of data 2017-09-27 22:22:05 +02:00
Tomasz Dąbrowski 53f934a7ee fix: src\string.c(2219): warning C4244: 'function': conversion from 'mrb_int' to 'int', possible loss of data 2017-09-27 22:22:05 +02:00
Tomasz Dąbrowski ef8df492e9 fix: src\string.c(1924): warning C4244: '=': conversion from 'mrb_int' to 'int', possible loss of data 2017-09-27 22:22:05 +02:00
Tomasz Dąbrowski 027b8d8377 fix: src\string.c(1130): warning C4244: '=': conversion from 'mrb_int' to 'int', possible loss of data 2017-09-27 22:22:05 +02:00
Tomasz Dąbrowski 46ccabacf0 fix: src\string.c(497): warning C4244: '=': conversion from 'mrb_int' to 'long', possible loss of data 2017-09-27 22:22:05 +02:00
Tomasz Dąbrowski 6cde950017 fix: src\state.c(66): warning C4200: nonstandard extension used: zero-sized array in struct/union 2017-09-27 22:22:05 +02:00
Tomasz Dąbrowski 0e2976bf93 fix: src\range.c(136): warning C4244: '=': conversion from 'mrb_int' to 'int', possible loss of data 2017-09-27 22:22:05 +02:00
Tomasz Dąbrowski b7e71e4cef fix: src\proc.c(96): warning C4244: 'function': conversion from 'mrb_int' to 'int', possible loss of data 2017-09-27 22:22:05 +02:00
Tomasz Dąbrowski 490de9dbe1 fix: src\print.c(22): warning C4244: 'initializing': conversion from 'mrb_int' to 'int', possible loss of data 2017-09-27 22:22:05 +02:00
Tomasz Dąbrowski 220c628210 fix: src\pool.c(33): warning C4200: nonstandard extension used: zero-sized array in struct/union 2017-09-27 22:22:05 +02:00
Tomasz Dąbrowski f0c1074b07 fix: src\numeric.c(1215): warning C4244: 'function': conversion from 'mrb_int' to 'int', possible loss of data 2017-09-27 22:22:05 +02:00
Tomasz Dąbrowski 4a0c9c9e31 fix: src\numeric.c(954): warning C4334: '<<': result of 32-bit shift implicitly converted to 64 bits (was 64-bit shift intended?) 2017-09-27 22:22:05 +02:00
Tomasz Dąbrowski 332a04af73 fix: src\numeric.c(897): warning C4244: 'function': conversion from 'mrb_int' to 'mrb_float', possible loss of data 2017-09-27 22:22:05 +02:00
Tomasz Dąbrowski 971a4f9122 fix: src\kernel.c(874): warning C4244: 'function': conversion from 'mrb_int' to 'int', possible loss of data 2017-09-27 22:22:05 +02:00
Tomasz Dąbrowski 0e0c96096d fix: src\kernel.c(861): warning C4244: '=': conversion from 'mrb_int' to 'int', possible loss of data 2017-09-27 22:22:05 +02:00
Tomasz Dąbrowski 7d98055862 fix: src\hash.c(139): warning C4244: 'function': conversion from 'mrb_int' to 'khint_t', possible loss of data 2017-09-27 22:22:05 +02:00
Tomasz Dąbrowski 8cef3f946c fix: src\hash.c(40): warning C4244: '=': conversion from 'mrb_int' to 'khint_t', possible loss of data 2017-09-27 22:22:05 +02:00
Tomasz Dąbrowski 3e1d60ae0b fix: src\hash.c(27): warning C4244: '=': conversion from 'mrb_int' to 'khint_t', possible loss of data 2017-09-27 22:22:05 +02:00
Tomasz Dąbrowski c7b663f2cf fix: src\gc.c(1425): warning C4244: '=': conversion from 'mrb_int' to 'int', possible loss of data 2017-09-27 22:22:04 +02:00
Tomasz Dąbrowski b406e9f795 fix: src\gc.c(1392): warning C4244: '=': conversion from 'mrb_int' to 'int', possible loss of data 2017-09-27 22:22:04 +02:00
Tomasz Dąbrowski 1dcf8ba488 fix: src\gc.c(559): warning C4244: '=': conversion from 'mrb_int' to 'int', possible loss of data 2017-09-27 22:22:04 +02:00
Tomasz Dąbrowski 7a2391b120 fix: src\error.c(76): warning C4244: '=': conversion from 'mrb_int' to 'int', possible loss of data 2017-09-27 22:22:04 +02:00
Tomasz Dąbrowski 4d6b8dbcb9 fix: src\dump.c(710): warning C4244: 'function': conversion from 'mrb_int' to 'uint16_t', possible loss of data 2017-09-27 22:22:04 +02:00
Tomasz Dąbrowski f4a17dd7b5 fix: src\dump.c(657): warning C4244: 'function': conversion from 'mrb_int' to 'uint16_t', possible loss of data 2017-09-27 22:22:04 +02:00
Tomasz Dąbrowski 5ed76e381c fix: src\class.c(949): warning C4244: '=': conversion from 'mrb_int' to 'int', possible loss of data 2017-09-27 22:22:04 +02:00
Tomasz Dąbrowski 9c5db48d1f fix: src\class.c(949): warning C4244: '=': conversion from 'mrb_int' to 'int', possible loss of data 2017-09-27 22:22:04 +02:00
Tomasz Dąbrowski d8b37d0381 fix: src\class.c(583): warning C4244: '=': conversion from 'mrb_int' to 'int', possible loss of data 2017-09-27 22:22:04 +02:00
Tomasz Dąbrowski 4146b5c2b5 fix: src\backtrace.c(83): warning C4244: '=': conversion from 'mrb_int' to 'int', possible loss of data 2017-09-27 22:22:04 +02:00
Tomasz Dąbrowski 7507d46992 fix: src\array.c(86): warning C4244: '=': conversion from 'mrb_int' to 'uint32_t', possible loss of data 2017-09-27 22:22:04 +02:00
Tomasz Dąbrowski be81504770 fix: mrbgems\mruby-time\src\time.c(641): warning C4244: '=': conversion from 'mrb_int' to 'int', possible loss of data 2017-09-27 22:22:04 +02:00
Tomasz Dąbrowski 0848407ee5 fix: mrbgems\mruby-time\src\time.c(372): warning C4244: 'function': conversion from 'mrb_int' to 'double', possible loss of data 2017-09-27 22:22:04 +02:00
Tomasz Dąbrowski d713f8d761 fix: mrbgems\mruby-test\driver.c(67): warning C4244: '=': conversion from 'mrb_int' to 'int', possible loss of data 2017-09-27 22:22:04 +02:00
Tomasz Dąbrowski 2640896911 fix: mrbgems\mruby-string-ext\src\string.c(49): warning C4244: '=': conversion from 'mrb_int' to 'int', possible loss of data 2017-09-27 22:22:04 +02:00
Tomasz Dąbrowski 8d816fa142 fix: mrbgems\mruby-string-ext\src\string.c(30): warning C4244: '=': conversion from 'mrb_int' to 'long', possible loss of data 2017-09-27 22:22:04 +02:00
Tomasz Dąbrowski d3819620ce fix: mrbgems\mruby-string-ext\src\string.c(38): warning C4244: '=': conversion from 'mrb_int' to 'char', possible loss of data 2017-09-27 22:22:04 +02:00
Tomasz Dąbrowski a94525d4ea fix: mrbgems\mruby-sprintf\src\sprintf.c(1052): warning C4244: '+=': conversion from 'mrb_int' to 'int', possible loss of data 2017-09-27 22:22:04 +02:00
Tomasz Dąbrowski 1e2c962fa5 fix: mrbgems\mruby-sprintf\src\sprintf.c(623): warning C4244: 'function': conversion from 'mrb_int' to 'int', possible loss of data 2017-09-27 22:22:04 +02:00
Tomasz Dąbrowski 897eabb1bb fix: mrbgems\mruby-sprintf\src\sprintf.c(646): warning C4244: 'function': conversion from 'mrb_int' to 'int', possible loss of data 2017-09-27 22:22:04 +02:00
Tomasz Dąbrowski e10b329fa3 fix: mrbgems\mruby-sprintf\src\sprintf.c(618): warning C4244: 'initializing': conversion from 'mrb_int' to 'int', possible loss of data 2017-09-27 22:22:04 +02:00
Tomasz Dąbrowski 861077f779 fix: mrbgems\mruby-sprintf\src\sprintf.c(516): warning C4244: 'function': conversion from 'mrb_int' to 'int', possible loss of data 2017-09-27 22:22:04 +02:00
Tomasz Dąbrowski 553dbad2c6 fix: mrbgems\mruby-math\src\math.c(660): warning C4244: 'function': conversion from 'mrb_int' to 'int', possible loss of data 2017-09-27 22:22:04 +02:00
Tomasz Dąbrowski 49e96a2e19 fix: mrbgems\mruby-math\src\math.c(491): warning C4244: '=': conversion from 'mrb_int' to 'int', possible loss of data 2017-09-27 22:22:04 +02:00
Tomasz Dąbrowski 536b95eb48 fix: mrbgems\mruby-kernel-ext\src\kernel.c(114): warning C4244: 'function': conversion from 'mrb_int' to 'int', possible loss of data 2017-09-27 22:22:04 +02:00
Tomasz Dąbrowski 9d89f8c00b fix: mrbgems\mruby-fiber\src\fiber.c(215): warning C4244: '=': conversion from 'mrb_int' to 'int', possible loss of data 2017-09-27 22:22:04 +02:00
Tomasz Dąbrowski 377d6a47ac fix: mrbgems\mruby-exit\src\mruby-exit.c(10): warning C4244: 'function': conversion from 'mrb_int' to 'int', possible loss of data 2017-09-27 22:22:04 +02:00
Tomasz Dąbrowski f632baddb1 fix: mrbgems\mruby-eval\src\eval.c(301): warning C4244: 'function': conversion from 'mrb_int' to 'int', possible loss of data 2017-09-27 14:42:27 +02:00
Tomasz Dąbrowski 49db1db81f fix: mrbgems\mruby-eval\src\eval.c(214): warning C4244: '=': conversion from 'mrb_int' to 'short', possible loss of data 2017-09-27 14:42:27 +02:00
Tomasz Dąbrowski 2e239a296e fix: mrbgems\mruby-compiler\core\parse.y(3455): warning C4244: 'function': conversion from 'intptr_t' to 'int', possible loss of data 2017-09-27 14:42:27 +02:00
Tomasz Dąbrowski f1a02dff58 fix: include\mruby/gc.h(43): warning C4200: nonstandard extension used: zero-sized array in struct/union 2017-09-27 14:42:27 +02:00
Yukihiro "Matz" Matsumoto 381850280c The [] special method call should be able to take a block. 2017-09-25 20:44:50 +09:00
Yukihiro "Matz" Matsumoto e98823f189 The lex_state after literals should be EXPR_ENDARG. 2017-09-25 20:44:04 +09:00
Yukihiro "Matz" Matsumoto e01d35ef79 The symbols should not take brace blocks. 2017-09-25 20:22:36 +09:00
Yukihiro "Matz" Matsumoto 298177fd6a Merge pull request #3813 from dabroz/feature-fix-date
Change DISABLE_STDIO to MRB_DISABLE_STDIO in mruby-time/time.c
2017-09-25 20:19:13 +09:00
Tomasz Dabrowski e00b48be4a change DISABLE_STDIO to MRB_DISABLE_STDIO in mruby-time/time.c 2017-09-25 13:11:20 +02:00
Yukihiro "Matz" Matsumoto 7450a774a5 The first instruction was skipped mistakenly in ensure clause; fix #3811 2017-09-23 10:12:04 +09:00
Yukihiro "Matz" Matsumoto 0ceaa0960a OP_EPOP operand may be bigger than mrb->c->eidx; fix #3810 2017-09-22 13:00:58 +09:00
Yukihiro "Matz" Matsumoto 5760226e71 Remove temporary limitation of OP_EPOP.
After f68f5f6, the operand of `OP_EPOP` should have been `1`.
Now we have removed the limitation.
2017-09-12 12:41:02 +09:00
Tomoyuki Sahara ab54185005 receiver variables must be "mrb_int" for mrb_get_args("i").
Otherwise, it can cause a segfault on the platforms where the
size of "int" and "mrb_int" differs.
2017-09-12 12:32:12 +09:00
Tomoyuki Sahara a809d42f5a remove whitespaces at the end of line. 2017-09-12 11:43:21 +09:00
Yukihiro "Matz" Matsumoto d6e41c3e51 The callinfo stack may be reallocated in cipush; fix rest of #3809
fix #3809
2017-09-11 23:13:47 +09:00
Yukihiro "Matz" Matsumoto 3d8c1a7e97 The ensure stack may be empty at OP_EPOP; fix 1st part of #3809 2017-09-11 22:46:34 +09:00
Yukihiro "Matz" Matsumoto 2a1e616e4d Avoid calling mrb_funcall to invoke #initialize from Class.new.
If `#initialize` is implemented in C, we don't need stack consuming
`mrb_funcall`.
2017-09-06 14:35:24 +09:00
Yukihiro "Matz" Matsumoto cbfa2b3588 Avoid recursion from mark_context(). 2017-09-05 21:13:16 +09:00
Yukihiro "Matz" Matsumoto f68f5f6b97 Avoid crossing C function boundary from OP_EPOP; ref #3789 2017-09-05 21:12:36 +09:00
Yukihiro "Matz" Matsumoto 7f4b57bb20 Restrict OP_EPOP operand to 1; ref #3789 2017-09-05 21:11:41 +09:00
Tomoyuki Sahara 15f4bdb529 Merge pull request #37 from udzura/fix-types
Fix type int to mrb_int
2017-09-04 23:55:37 +09:00
Uchio KONDO 5b6e4eda2a Fix type int to mrb_int
- mruby's default int size is changed after: https://github.com/mruby/mruby/commit/f0f4a1088a270e339407a24ffe8be748f4764fc2
- implicit cast causes some errors
2017-09-04 16:33:57 +09:00
Yukihiro "Matz" Matsumoto 3acaa44a70 Restructure irep->outer chain; fix #3804
Instead of `irep -> proc` chain, we use `irep -> irep` chain to
avoid GC bugs like #3804. We added `target_class` reference to
`mrb_irep` struct. That means one more word consumption per `irep`.
2017-09-04 06:51:31 +09:00
Yukihiro "Matz" Matsumoto 8a5d783f2e Call initialize only when it's not empty. 2017-09-04 06:49:05 +09:00
Yukihiro "Matz" Matsumoto 5d7e4957e0 Merge pull request #3806 from flaviommedeiros/master
Trying to make the code more readable
2017-09-03 07:51:12 +09:00
Yukihiro "Matz" Matsumoto da97715e11 Merge pull request #3805 from fl0l0u/patch-1
Update print.c
2017-09-03 07:48:33 +09:00
fl0l0u e03042ec19 Update print.c
Strings not containing a newline are not printed synchronously
ex. bin/mruby -e '["a", "b", "c", "\n", "d", "e", "f", "\n"].each {|e| print e ; usleep 200000}'
2017-09-02 18:26:50 +02:00
Flavio Medeiros 9f677b72db Trying to make the source code more understandable by removing mixing of ternary if statements with attributions. 2017-09-02 13:25:09 -03:00
Yukihiro "Matz" Matsumoto 476af3c647 Merge pull request #3802 from christopheraue/proc_break_tests
Tested local jump errors caused by break in a proc
2017-09-02 22:19:15 +09:00
Yukihiro "Matz" Matsumoto ab99e2c293 Avoid copying over initialized procs using initialize_copy; fix #3803
It may be better to raise exceptions, but CRuby doesn't.
2017-09-01 06:51:59 +09:00
Yukihiro "Matz" Matsumoto 57610091ce Update method cache clearing. 2017-09-01 06:51:59 +09:00
Yukihiro "Matz" Matsumoto f0f4a1088a Make the default integer size to be MRB_INT64 on 64bit systems; close #3800
Unless `MRB_NAN_BOXING` is specified.
2017-09-01 06:51:59 +09:00
Christopher Aue 35deaae776 Tested LocalJumpErrors caused by break in a proc 2017-08-30 12:25:55 +02:00
Yukihiro "Matz" Matsumoto 71357ff1d8 Merge pull request #3801 from christopheraue/assert_raise_refactoring
Allowed to pass multiple exceptions to assert_raise
2017-08-30 18:56:59 +09:00
Christopher Aue bf32265743 Allowed to pass multiple exceptions to assert_raise 2017-08-30 11:03:51 +02:00
Yukihiro "Matz" Matsumoto fe3227cd5c Set the ORPHAN flag in Proc.new; fix #3798 2017-08-30 16:51:40 +09:00
Yukihiro "Matz" Matsumoto 483a038d39 Fixed a critical typo; ref #3798 2017-08-30 16:51:17 +09:00
Yukihiro "Matz" Matsumoto 2c85213298 Need to mark mrb->range_class; fix #3797 2017-08-30 16:12:12 +09:00
Yukihiro "Matz" Matsumoto 79b4f61b02 Merge pull request #3799 from christopheraue/assert_raise_refactoring
Refactored #assert_raise and #assert_nothing_raised
2017-08-30 14:47:12 +09:00
Christopher Aue 4b0b8f7e1a Refactored #assert_raise and #assert_nothing_raised 2017-08-29 23:25:53 +02:00
Yukihiro "Matz" Matsumoto 8976f47e0a Need to update ci after callinfo stack reallocation; fix #3796 2017-08-29 11:06:34 +09:00
Yukihiro "Matz" Matsumoto c082249838 Exclude the top-level closure from each_object; fix #3793 2017-08-29 09:29:14 +09:00
Yukihiro "Matz" Matsumoto 786cbf06c3 Revert "Clear irep->outer when no Proc reference the irep; fix #3793"
This reverts commit 15d48efa4b.
2017-08-29 09:27:45 +09:00
Yukihiro "Matz" Matsumoto 1260d3b68a Add `__ENCODING__' support.
`__ENCODING__' returns the current encoding name (string), unlike
CRuby that returns the encoding object.
2017-08-28 22:42:06 +09:00
Yukihiro "Matz" Matsumoto f1fa5bf1c6 Remove integer type mismatch warnings from parse.y. 2017-08-28 22:31:02 +09:00
Yukihiro "Matz" Matsumoto 15d48efa4b Clear irep->outer when no Proc reference the irep; fix #3793 2017-08-28 10:06:04 +09:00
Yukihiro "Matz" Matsumoto fd927d786e Merge pull request #3795 from christopheraue/array_refactoring
Array refactorings and speed improvements
2017-08-27 08:56:41 +09:00
Christopher Aue c956e17c02 Replaced Array#each with while loop for performance reasons
Example benchmark:
$ time build/bench/bin/mruby -e "Array.new(2_000_000){ |i| i }.index{ |i| i == 1_999_999 }"

Before:
real    0m0.934s
user    0m0.922s
sys     0m0.003s

After:
real    0m0.590s
user    0m0.583s
sys     0m0.007s
2017-08-26 15:57:25 +02:00
Christopher Aue 6c9013e22b Removed unneeded block check in Array#uniq 2017-08-26 15:57:25 +02:00
Christopher Aue f3fb43c729 Reimplemented Array#flatten with #flatten! 2017-08-26 15:57:25 +02:00
Yukihiro "Matz" Matsumoto ccd555421a Merge pull request #3794 from dabroz/fix-flt-epsilon
Fix building with MRB_USE_FLOAT=1
2017-08-26 22:29:00 +09:00
Tomasz Dąbrowski 01b9b71902 fix mrbgems/mruby-range-ext/src/range.c:142:71: error: use of undeclared identifier 'FLT_EPSILON' 2017-08-26 12:11:57 +02:00
Yukihiro "Matz" Matsumoto 85a400e43d Reimplement Array#shift to be faster. 2017-08-26 02:03:21 +09:00
Yukihiro "Matz" Matsumoto cec53ff77e Array#first to treat 1 argument case specially to improve performance. 2017-08-26 02:03:21 +09:00
Yukihiro "Matz" Matsumoto 1b545a6b63 Check for ability to skip optional argument parsing. 2017-08-26 02:03:21 +09:00
Yukihiro "Matz" Matsumoto 60104ce41d Silence compiler warning regarding float condition; fix #3790 2017-08-26 02:02:45 +09:00
Yukihiro "Matz" Matsumoto 43ec918be1 Remove unused mrb_obj_iv_ifnone() from API. 2017-08-26 02:01:50 +09:00
Yukihiro "Matz" Matsumoto 0e10a23d7a Add checks if iv_tbl is NULL. 2017-08-26 02:01:50 +09:00
Yukihiro "Matz" Matsumoto 0c52112dd4 Keep Range class in mrb_state structure for performance. 2017-08-26 02:01:50 +09:00
Yukihiro "Matz" Matsumoto 04dbbff3c1 Use khash for instance variables tables instead of segment list.
For performance reason. Segmented list consumes slightly less memory
but takes a lot of time especially when there are many slots in the
segment lists (e.g. class constants).
2017-08-26 02:01:50 +09:00
Yukihiro "Matz" Matsumoto f2cc1239a5 Turn on method cache for Travis CI. 2017-08-26 02:01:50 +09:00
Yukihiro "Matz" Matsumoto f7f1aca8b5 Merge pull request #3792 from dabroz/fix-test-int16
Fix string test with 16-bit integers
2017-08-26 02:00:30 +09:00
Yukihiro "Matz" Matsumoto 5f2c7e47bb Merge pull request #3791 from dabroz/fix-msvc-warning
Fix MSVC warnings in fmt_fp.c
2017-08-26 01:54:59 +09:00
Tomasz Dąbrowski 17c249780f fix String#% %d test with MRB_INT16 set 2017-08-25 14:36:05 +02:00
Tomasz Dąbrowski 5d9b84ef40 fix fmt_fp.c(329) : warning C4244: 'return' : conversion from 'ptrdiff_t' to 'int', possible loss of data 2017-08-25 14:18:31 +02:00
Tomasz Dąbrowski 78b13b3955 fix fmt_fp.c(251) : warning C4244: '=' : conversion from '__int64' to 'int', possible loss of data 2017-08-25 14:18:05 +02:00
Tomasz Dąbrowski ef6a762d41 fix fmt_fp.c(224) : warning C4244: '=' : conversion from 'ptrdiff_t' to 'int', possible loss of data 2017-08-25 14:14:17 +02:00
Tomasz Dąbrowski bac37a9f1a fix fmt_fp.c(220) : warning C4244: '=' : conversion from '__int64' to 'int', possible loss of data 2017-08-25 14:13:06 +02:00
Tomasz Dąbrowski b2a16d6bf7 fix fmt_fp.c(206) : warning C4244: 'initializing' : conversion from 'ptrdiff_t' to 'int', possible loss of data 2017-08-25 14:12:08 +02:00
Tomasz Dąbrowski c8341dbf7c fix fmt_fp.c(178) : warning C4244: 'return' : conversion from 'ptrdiff_t' to 'int', possible loss of data 2017-08-25 14:10:43 +02:00
Tomasz Dąbrowski 5d099e40e6 fix fmt_fp.c(123) : warning C4244: 'return' : conversion from 'ptrdiff_t' to 'int', possible loss of data 2017-08-25 14:10:24 +02:00
Yukihiro "Matz" Matsumoto 63f10a1ee5 Merge pull request #3788 from christopheraue/fix_codegen_op_send_nregs
Fixed register windows of OP_SENDs generated during codegen
2017-08-24 14:38:03 +09:00
Christopher Aue 3366894a40 Fixed register windows of OP_SENDs generated by NODE_{DREGX,REGX}; ref #3783 2017-08-23 18:16:05 +02:00
Christopher Aue 499498a6a7 Tested register windows of OP_SENDs generated by NODE_{DXSTR,XSTR}; ref #3783 2017-08-23 18:15:54 +02:00
Christopher Aue 84d8ecc1d7 Fixed register windows of OP_SENDs generated by NODE_OP_ASGN; ref #3783 2017-08-23 18:15:44 +02:00
Christopher Aue 4aca9ef98e Refactored code around generation of OP_SEND in NODE_OP_ASGN 2017-08-23 18:15:38 +02:00
Christopher Aue 1221f7676e Fixed register windows of OP_SENDs generated by NODE_{FOR,SYMBOLS}; ref #3783 2017-08-23 18:15:27 +02:00
Christopher Aue c040c8d92b Tested register windows of OP_SENDs generated by NODE_{RESCUE,HASH,ALIAS}; ref #3783 2017-08-23 18:15:08 +02:00
Christopher Aue c6596cf26a Fixed register windows of OP_SENDs generated by NODE_{SCALL,CASE,YIELD,UNDEF}; ref #3783 2017-08-23 18:12:35 +02:00
Christopher Aue 64e5208404 Asserted bidx < ci->nregs for OP_SEND and OP_SUPER 2017-08-23 15:18:06 +02:00
Yukihiro "Matz" Matsumoto 4c9a604877 Added method cache.
To enable method cache, define `MRB_METHOD_CACHE` or
`MRB_METHOD_CACHE_SIZE`. The cache size must be power of 2.
The default cache size is 128.

The measurement:
I measured simple benchmarks found in benchmark/ directory. With
method cache enabled, we gained 6-8% performance improvement, with
97-99% cache hit rate.
2017-08-22 22:17:01 +09:00
Yukihiro "Matz" Matsumoto a65f4dbb32 Remove possible path that leaves a local variable uninitialized. 2017-08-22 15:50:08 +09:00
Yukihiro "Matz" Matsumoto db437b04a4 mrb_obj_respond_to to use mrb_method_search_vm. 2017-08-22 14:23:46 +09:00
Yukihiro "Matz" Matsumoto 0d865a77d5 c (mrbc_context) may be NULL; fix #3787 2017-08-22 09:47:10 +09:00
Yukihiro "Matz" Matsumoto ab3b6dbd2a strlen returns size_t; need to cast before assigning to int. 2017-08-22 08:14:09 +09:00
Yukihiro "Matz" Matsumoto 3f90af6b42 (Try to) fix mixture of int and size_t in UTF-8 conversion.
This only effects VC.
2017-08-22 07:35:51 +09:00
Yukihiro "Matz" Matsumoto a7d611fb23 Reduce signed/unsigned warnings in dump.c 2017-08-19 21:50:36 +09:00
Yukihiro "Matz" Matsumoto 5d0fc7e57a Reduce signed/unsigned warnings in fmt_fp.c 2017-08-19 17:09:30 +09:00
Yukihiro "Matz" Matsumoto 8cea1f8907 Use ptrdiff_t instead of int. 2017-08-19 15:51:08 +09:00
Yukihiro "Matz" Matsumoto a117ec771b Remove mixed signed/unsigned comparison in debug.c. 2017-08-19 14:42:30 +09:00
Yukihiro "Matz" Matsumoto 834523945e Replace stack pop() by push_n(2); pop_n(3); fix #3783
To calculate correct register windows size. The fix was suggested
by Christopher Aue.
2017-08-19 11:56:04 +09:00
Yukihiro "Matz" Matsumoto db098d3e0e Type check before traversing irep->outer; fix #3782 2017-08-19 11:39:42 +09:00
Yukihiro "Matz" Matsumoto 2294ebdd44 Call mrb_full_gc before gc_each_objects; ref #3782
Otherwise dead object may be seen from `#each_object`.
2017-08-19 11:38:11 +09:00
Yukihiro "Matz" Matsumoto 9146d5c34f Zero width unshift should not touch memory; ref #3780 2017-08-19 11:11:26 +09:00
Yukihiro "Matz" Matsumoto 8b3298b2d6 Unshift pointer move size was wrong (not len but alen); fix #3780 2017-08-19 11:08:46 +09:00
Yukihiro "Matz" Matsumoto 29ad0a7964 capacify' for mrb_str_new_capa should not be 0`. 2017-08-18 23:42:34 +09:00
Yukihiro "Matz" Matsumoto a8bd06904d mrb_str_cat: capa should not be zero to avoid infinite loops. 2017-08-18 23:42:34 +09:00
Yukihiro "Matz" Matsumoto a06adb176f mrb_str_cat: capa should be bigger than total. 2017-08-18 23:42:33 +09:00
Yukihiro "Matz" Matsumoto 8b5be554c7 ARY_CAPA handles capacity for embedded arrays by itself. 2017-08-18 23:42:33 +09:00
Yukihiro "Matz" Matsumoto 8fbc4bef55 Reduce signed/unsigned comparison warnings; ref #3785 2017-08-18 22:54:59 +09:00
Yukihiro "Matz" Matsumoto f1767fd079 Separate mrb_str_buf_new and mrb_str_new_capa.
`mrb_str_buf_new` is an old function that ensures capacity size of
`MRB_STR_BUF_MIN_SIZE` minimum. Usually one need to use
`mrb_str_new_capa` instead.
2017-08-18 22:17:48 +09:00
Yukihiro "Matz" Matsumoto 722d123b87 Remove code duplication in mrb_str_concat. 2017-08-18 22:17:48 +09:00
Yukihiro "Matz" Matsumoto 198c898817 Rename mrb_str_concat2 to mrb_str_concat_m.
According to the naming convention a function that implements
a method should be suffixed by `_m`.
2017-08-18 22:17:47 +09:00
Yukihiro "Matz" Matsumoto 4c25738ac7 Merge str_buf_cat and mrb_str_cat. 2017-08-18 22:17:47 +09:00
Yukihiro "Matz" Matsumoto 2adb0c201e Merge pull request #3786 from christopheraue/3784_fix
Reset ci in OP_SUPER after potential realloc
2017-08-18 22:17:33 +09:00
Yukihiro "Matz" Matsumoto 11c3ad999e Merge pull request #3781 from clayton-shopify/fix-hash-compact-bang
Check whether internal khash is initialized in Hash#compact!
2017-08-18 22:13:33 +09:00
Yukihiro "Matz" Matsumoto f229ed917e Merge pull request #3785 from miura1729/original
Improve Array structure
2017-08-18 20:37:31 +09:00
Miura Hideki 75ec86ed00 Improve Array structure 2017-08-18 20:12:00 +09:00
Christopher Aue 6b0860ce61 Reset ci in OP_SUPER after potential realloc 2017-08-18 13:11:08 +02:00
Clayton Smith 5dc688fb12 Check whether internal khash is initialized in Hash#compact! 2017-08-17 12:13:41 -04:00
Yukihiro "Matz" Matsumoto 0789ec71e0 Merge pull request #3779 from christopheraue/vm_refactoring
Some more vm refactorings
2017-08-13 07:11:21 +09:00
Christopher Aue d5ac785b31 Reintroduced not storing converted proc directly in the stack 2017-08-12 23:59:40 +02:00
Christopher Aue 198df61039 Removed unneeded ci->nregs checks in OP_SEND and OP_SUPER
Because of #3504 `ci->nregs = bidx+1` was introduced in b64f08784c.
This led to the follow up error #3551 whose fix introduced the `if (bidx >= ci->nregs)`
check in 071164b799 and the `stack_extend(mrb, ci->nregs)`
in 93d802987e.

Then, the code causing #3504 reappeared again in #3590. The fix for it moved the code
dealing with the block in OP_SUPER from below the `cipush`  to above the `cipush`
in d9fb8b69b0. The `if (bidx >= ci->nregs) { ... }` from
then on works with the original callinfo and not the pushed one. `ci->nregs` needed to
be modified for the pushed one because it is initialized to 0. But for the original ci
it is propertly set and a check is not needed.
2017-08-12 23:27:17 +02:00
Christopher Aue f2d4640998 Extended stack always based on ci->nregs 2017-08-12 14:47:22 +02:00
Christopher Aue 3f591d71c6 Refactored variable usage in OP_SEND and OP_SUPER 2017-08-12 14:31:18 +02:00
Yukihiro "Matz" Matsumoto 8bf492f127 Reduce integer type mismatch warnings in VC. 2017-08-12 09:35:35 +09:00
Yukihiro "Matz" Matsumoto baa5d2e3f7 Remove some empty lines; ref #3778 2017-08-11 22:39:31 +09:00
Yukihiro "Matz" Matsumoto 0828a962c0 Merge pull request #3778 from christopheraue/vm_refactoring
Refactored OP_SEND and OP_SUPER and calculate argc right at the top
2017-08-11 22:38:32 +09:00
Yukihiro "Matz" Matsumoto 42f9af41fb Merge pull request #3777 from christopheraue/super_method_missing_test
Added basic test for calling a missing method through super
2017-08-11 22:35:40 +09:00
Christopher Aue 731dd78aa0 Added basic test for calling a missing method through super 2017-08-11 14:09:22 +02:00
Christopher Aue 58f5115b22 Refactored OP_SEND and OP_SUPER and calculate argc right at the top 2017-08-11 13:42:06 +02:00
Yukihiro "Matz" Matsumoto d077a5f0a6 scan_hex may be used to parse both unicode and hex escape.
The error checks for both usage should be separated; ref #3774
2017-08-11 14:25:02 +09:00
Yukihiro "Matz" Matsumoto 56d4e41d76 Fixed a wrong condition in scan_hex; fix #3774 2017-08-11 14:14:30 +09:00
Yukihiro "Matz" Matsumoto 96d4c2d385 Remove an unused argument from each_backtrace_func. 2017-08-11 13:52:24 +09:00
Yukihiro "Matz" Matsumoto 1d781da8a6 Should not include float.h here. 2017-08-11 13:52:01 +09:00
Yukihiro "Matz" Matsumoto db72cdae28 Merge branch 'christopheraue-super_method_missing_fix' 2017-08-11 13:16:40 +09:00
Yukihiro "Matz" Matsumoto ab39ed4f82 Defer mid update after unshift; ref #3776 2017-08-11 13:15:50 +09:00
Yukihiro "Matz" Matsumoto 9feb069124 Merge branch 'super_method_missing_fix' of https://github.com/christopheraue/mruby into christopheraue-super_method_missing_fix 2017-08-11 13:14:32 +09:00
Yukihiro "Matz" Matsumoto 0ff28c9e60 Silence integer type conversion warnings. 2017-08-11 13:10:31 +09:00
Yukihiro "Matz" Matsumoto ef0b239704 Remove unnecessary inline function ary_elt.
And the function does not conform the naming convention anyway.
2017-08-11 12:57:37 +09:00
Yukihiro "Matz" Matsumoto 67e2dddb82 Remove mrb_ary_len function. Use RARRAY_LEN instead. 2017-08-11 12:52:36 +09:00
Yukihiro "Matz" Matsumoto 8f6b2121d9 Update document comment of array C API functions. 2017-08-11 12:51:45 +09:00
Yukihiro "Matz" Matsumoto 4e2f4f4280 Avoid possible data loss by using ptrdiff_t. 2017-08-11 12:12:11 +09:00
Yukihiro "Matz" Matsumoto ae04005092 The type of ARY_EMBED_LEN should be mrb_int. 2017-08-11 12:09:37 +09:00
Yukihiro "Matz" Matsumoto 3e075a7b6c Should not call to_str in mrb_vformat; fix #3773 2017-08-11 09:21:47 +09:00
Yukihiro "Matz" Matsumoto 68470bef86 Check method existence in `to_enum'; ref #3773 2017-08-11 09:21:09 +09:00
Christopher Aue 2249551c63 Fixed calling missing method through super with 126 args 2017-08-10 23:26:39 +02:00
Yukihiro "Matz" Matsumoto ac42ccc1fc Merge pull request #3772 from vvakame/add2authors
Updated AUTHORS
2017-08-10 09:50:08 +09:00
vvakame a8658b0f2c Updated AUTHORS 2017-08-10 09:21:40 +09:00
Yukihiro "Matz" Matsumoto a7462a7f42 Remove redundant flo_hash function.
`flo_hash` implemented `15.2.8.3.18` but `Kernel#hash` (15.3.1.3.15)
now works for numbers.
2017-08-10 08:47:01 +09:00
Yukihiro "Matz" Matsumoto 3d288ef0d8 Use standard hash functions in mrb_hash_ht_hash_func. 2017-08-10 08:47:01 +09:00
Yukihiro "Matz" Matsumoto 78be0172f7 Normalize float numbers before calculating a hash value. 2017-08-10 08:36:09 +09:00
Yukihiro "Matz" Matsumoto 9826ca54f2 VM stack may be reallocated during mrb_hash_get; fix #3771 2017-08-10 08:21:43 +09:00
Yukihiro "Matz" Matsumoto 9e0c48ddc6 Merge pull request #3770 from christopheraue/tabs_to_spaces
Replaced tabs with spaces
2017-08-10 07:59:49 +09:00
Christopher Aue 2fadddcd20 Replaced tabs with spaces 2017-08-09 21:56:27 +02:00
Yukihiro "Matz" Matsumoto 24c345fe5c Merge branch 'vvakame-add-hash-compact' 2017-08-09 21:21:31 +09:00
Yukihiro "Matz" Matsumoto 6c61a60609 Implement Hash#compact! in C; ref #3769 2017-08-09 21:20:50 +09:00
vvakame 4d46f366ac add method(compact, compact!) and test of Hash to mruby-hash-ext 2017-08-09 19:18:02 +09:00
Yukihiro "Matz" Matsumoto f9c3ebd29d Wrong blkargs pos for vararg; ref #3768 2017-08-09 15:23:20 +09:00
Yukihiro "Matz" Matsumoto 0a61df1c34 The block argument offset saved in the env was wrong; fix #3768
When the method takes variable number of argument (`argc = -1`),
the block argument offset should be `-1` not `0`.
2017-08-09 12:57:55 +09:00
Yukihiro "Matz" Matsumoto 8f62957888 Support break within rescue clauses; fix #3767 ref #3721 2017-08-09 12:25:20 +09:00
Yukihiro "Matz" Matsumoto 66e2928bd4 Float values divided by zero should honor signs; fix #3766
It also fixes unexpected resurrection of #3745 by #3752
2017-08-08 02:13:11 +09:00
Yukihiro "Matz" Matsumoto 8494557006 Set the current pc as the error position in OP_ERR; ref #3765 2017-08-08 01:55:46 +09:00
Yukihiro "Matz" Matsumoto e910cf6169 Check if ptr is NULL before calling memset; fix #3765 2017-08-08 01:54:43 +09:00
Yukihiro "Matz" Matsumoto 1358725738 Merge pull request #3764 from christopheraue/new_hash_perf
Improved speed of creating new hash tables
2017-08-07 01:48:39 +09:00
Christopher Aue ec7475d88b Prevented resizing just created hashes in specific size ranges 2017-08-05 20:59:26 +02:00
Christopher Aue 0e5c3c4ebd Improved speed of creating new hash tables 2017-08-04 22:08:29 +02:00
Yukihiro "Matz" Matsumoto 1b9c4855a3 proc->body.irep may be NULL; fix #3761 2017-08-05 01:28:11 +09:00
Yukihiro "Matz" Matsumoto 006661394d Fixed heap buffer overflow in mrb_ary_unshift_m; fix #3760 2017-08-05 01:18:52 +09:00
Yukihiro "Matz" Matsumoto 36dbfd9bda Change return type of scan_oct from int to int32_t. 2017-08-05 01:06:36 +09:00
Yukihiro "Matz" Matsumoto e86c252a99 Left shift of signed integers is undefined behavior in C; fix #3762 2017-08-05 01:06:36 +09:00
Yukihiro "Matz" Matsumoto 8095754e28 Merge pull request #3763 from mimaki/fix-mrdb-source-path
Fixed a invalid source path name on mruby debugger.
2017-08-04 23:41:14 +09:00
Hiroshi Mimaki 7bdc709da0 Fixed a invalid source path name on mruby debugger. 2017-08-04 17:25:03 +09:00
Yukihiro "Matz" Matsumoto 7b88c1a8e5 Now local_variables works when for closures; fix #3710 2017-08-02 07:44:58 +09:00
Yukihiro "Matz" Matsumoto da24af34b9 Better class name management.
The change removes several internal instance variables used by
class name management. The variables `__classid__` and `__classpath__`
are no longer available. `__outer__` is used only for unnamed outer
classes/modules (and will be removed after they are named).

[Important note]
Along with this change we removed several public functions.

 - mrb_class_outer_module()
 - mrb_class_sym()

We believe no one have used those functions, but if you do, please
ask us for the workaround.
2017-08-01 22:25:49 +09:00
Yukihiro "Matz" Matsumoto 2170fad406 Cosmetic changes (removing spaces before * in return types). 2017-08-01 16:31:18 +09:00
Yukihiro "Matz" Matsumoto 648e9ea51b Move naming unnamed classes/modules
From `mrb_mod_const_set` to `mrb_const_set`.
2017-08-01 16:25:09 +09:00
Yukihiro "Matz" Matsumoto 3f6a098626 Reimplement constant look-up rule to follow lexical scoping.
This update fix CRuby scoping incompatibility; close #600; close #3200
2017-08-01 15:57:32 +09:00
Yukihiro "Matz" Matsumoto 9e10afe1d0 Implements `Module::nesting' (15.2.2.3.2); ref #600, #3200 2017-08-01 15:37:21 +09:00
Yukihiro "Matz" Matsumoto 16aafdd866 Merge pull request #3759 from christopheraue/authors_update
Updated AUTHORS
2017-07-31 07:27:04 +09:00
Yukihiro "Matz" Matsumoto facf5f99d4 Merge pull request #3758 from christopheraue/enumeration_perf
Improved speed of enumeration methods
2017-07-31 07:26:46 +09:00
Christopher Aue a4ff31eaf6 Updated AUTHORS 2017-07-30 16:19:24 +02:00
Christopher Aue 3359b86ec7 Improved speed of enumeration methods 2017-07-30 13:19:31 +02:00
Yukihiro "Matz" Matsumoto c8fdab8725 Merge branch 'udzura-move-task-class-definitions' 2017-07-29 07:15:10 +09:00
Yukihiro "Matz" Matsumoto e821c25d38 Merge branch 'move-task-class-definitions' of https://github.com/udzura/mruby into udzura-move-task-class-definitions 2017-07-29 07:09:53 +09:00
Yukihiro "Matz" Matsumoto b290e98f3b Merge pull request #3757 from christopheraue/module_const_get_class_path
Extended Module#const_get to support class paths
2017-07-29 07:05:37 +09:00
Yukihiro "Matz" Matsumoto cf23a85333 Merge pull request #3755 from christopheraue/array_bsearch_index
Added Array#bsearch_index
2017-07-29 07:01:53 +09:00
Yukihiro "Matz" Matsumoto dda73da640 Merge pull request #3756 from christopheraue/fix_mod_include_ret_val
Fixed return value of Module#include and #prepend
2017-07-29 06:53:06 +09:00
Christopher Aue a3bfd735a0 Added Array#bsearch_index 2017-07-28 23:51:49 +02:00
Christopher Aue 451574f142 Refactored Array#bsearch 2017-07-28 23:51:40 +02:00
Christopher Aue f937af5745 Extended Module#const_get to support class paths 2017-07-28 23:19:49 +02:00
Christopher Aue c7018ea962 Added mrb_str_index to the mrb API 2017-07-28 21:07:20 +02:00
Christopher Aue b499ad6749 Fixed return value of Module#include and #prepend 2017-07-28 17:38:40 +02:00
Christopher Aue 8a6ce74b4d Tested Array#bsearch more thoroughly 2017-07-28 17:15:35 +02:00
Yukihiro "Matz" Matsumoto 4696093673 Rename MRB_SEGMENT_SIZE to MRB_IV_SEGMENT_SIZE. 2017-07-27 16:14:03 +09:00
Yukihiro "Matz" Matsumoto 1e41026b28 Always use MRB_USE_IV_SEGLIST. 2017-07-27 16:14:03 +09:00
Yukihiro "Matz" Matsumoto f26d00d9e8 Embed small size array elements in the heap.
It reduces the memory consumption and sometimes improve the
performance as well.  For example, the consumed memory size
of `bench/bm_ao_render.rb` is reduced from 1.2GB to 1GB, and
its total execution time become 18.795 sec from 22.229 sec.
2017-07-27 16:13:06 +09:00
Yukihiro "Matz" Matsumoto 5d44f8582e Remove loop from OP_POPERR. 2017-07-27 10:30:43 +09:00
Yukihiro "Matz" Matsumoto 7d5cf8749a (0).div(0.0) should be NaN; fix #3754 2017-07-26 15:48:50 +09:00
Yukihiro "Matz" Matsumoto 46ab8fdf07 (0.0).div(0) should not be infinity; fix #3753 2017-07-25 15:28:41 +09:00
Yukihiro "Matz" Matsumoto 9fa3d77114 0/0 should not be infinity; fix #3752 2017-07-25 15:11:31 +09:00
Yukihiro "Matz" Matsumoto 7b8d784040 Reimplement sort method to reduce array copying. 2017-07-25 14:42:38 +09:00
Yukihiro "Matz" Matsumoto 7f9e333647 Should not update @objs from mruby-bin-mruby mrbgem.rake; fix #3751 2017-07-24 16:53:20 +09:00
Yukihiro "Matz" Matsumoto 308341b990 Clear mrb_callinfo struct by zero initializer. 2017-07-24 16:47:11 +09:00
Yukihiro "Matz" Matsumoto 1fc9a3019d Initialize potentially uninitialized local variable. 2017-07-24 16:46:27 +09:00
Yukihiro "Matz" Matsumoto 1c360965e7 Need to unshare env on OP_R_BREAK too. 2017-07-21 10:57:21 +09:00
Yukihiro "Matz" Matsumoto 5fee3f5869 Move NULL check to mrb_env_unshare(); ref #3750 2017-07-21 10:14:15 +09:00
Yukihiro "Matz" Matsumoto e2c9a30571 Should not raise LocalJumpError on funcall'ed frame; fix #3750 2017-07-21 07:17:21 +09:00
Yukihiro "Matz" Matsumoto 04c21d9d6b Merge pull request #3749 from christopheraue/fix_spec_rbfiles
Fixed setting custom rbfiles in gemspec
2017-07-20 23:14:34 +09:00
Yukihiro "Matz" Matsumoto 25a0a6b038 Need to patch OP_GETUPVAR and OP_SETUPVAR; fix #3732 2017-07-20 22:47:20 +09:00
Christopher Aue 5a9eedf541 Fixed setting custom rbfiles in gemspec 2017-07-19 19:46:36 +02:00
Yukihiro "Matz" Matsumoto aa3cb0466e Avoid C undefined behavior of division by zero; close #3745 2017-07-19 09:49:41 +09:00
Yukihiro "Matz" Matsumoto ca2cfc6fe9 Merge pull request #3746 from christopheraue/mod_singleton_class_p
Implemented Module#singleton_class?
2017-07-19 09:08:11 +09:00
Yukihiro "Matz" Matsumoto 645b0fb58c Merge branch 'christopheraue-const_set_mod_to_s' 2017-07-19 09:03:51 +09:00
Yukihiro "Matz" Matsumoto 14a72b0800 Avoid constant-set duplication; ref #3747 2017-07-19 09:03:07 +09:00
Yukihiro "Matz" Matsumoto a8bffdae50 Merge branch 'const_set_mod_to_s' of https://github.com/christopheraue/mruby into christopheraue-const_set_mod_to_s 2017-07-19 08:58:06 +09:00
Christopher Aue 468cc34c93 Fixed Module#to_s and #name for #const_set modules 2017-07-18 22:55:37 +02:00
Christopher Aue dd52b88101 implemented Module#singleton_class? 2017-07-18 20:47:05 +02:00
Yukihiro "Matz" Matsumoto 329938ef15 Simplify mrb_gc_arena_restore() to reduce overhead.
It will no longer shrink arena region. Instead `vm.c` uses
a static function `mrb_gc_arena_shrink()` to shrink.
2017-07-18 23:26:36 +09:00
Yukihiro "Matz" Matsumoto 52aafcd001 Merge pull request #3743 from christopheraue/sprintf_d_tests
added tests for #3736
2017-07-17 09:17:24 +09:00
Yukihiro "Matz" Matsumoto 59eaad9d78 Merge pull request #3742 from christopheraue/iter_exp_tests
added basic tests for while/until/break/next
2017-07-17 09:16:25 +09:00
Christopher Aue 2730231e50 added tests for #3736 2017-07-16 22:34:23 +02:00
Christopher Aue 8fe2a6ce0f added basic tests for while/until/break/next 2017-07-16 22:25:48 +02:00
Yukihiro "Matz" Matsumoto 515a093213 Add Hash#transform_keys! and Hash#transform_values. 2017-07-15 08:51:35 +09:00
Yukihiro "Matz" Matsumoto d7fef24a95 Use keys.each instead of unstable each_keys. 2017-07-15 08:50:52 +09:00
Yukihiro "Matz" Matsumoto 460d628490 Remove duplication in mruby-hash-ext test. 2017-07-14 16:10:26 +09:00
Yukihiro "Matz" Matsumoto 1c02b8558f Avoid duplicated width filling for sprintf %d specifier; fix #3736 2017-07-14 15:21:11 +09:00
Yukihiro "Matz" Matsumoto de3edcc170 Add Hash#transform_{keys,values} to mruby-hash-ext. 2017-07-14 15:13:41 +09:00
Yukihiro "Matz" Matsumoto bad807e7f0 Use floor() to implement round() on WIN32 platform.
This change was suggested by Akira Kakuto.
2017-07-13 20:32:34 +09:00
Yukihiro "Matz" Matsumoto 70e99d6b57 Define round() only on WIN32 platform; fix #3741 2017-07-13 00:09:31 +09:00
Yukihiro "Matz" Matsumoto 7fa9321c18 while|until should have the value from break; fix #3735 2017-07-12 14:56:48 +09:00
Yukihiro "Matz" Matsumoto e5fbe350b3 Avoid float operation to shrink arena buffer size. 2017-07-12 14:52:03 +09:00
Yukihiro "Matz" Matsumoto 9501b18362 Add inline modifier to cipush() and cipop() functions. 2017-07-12 14:50:44 +09:00
Yukihiro "Matz" Matsumoto a18904a4c2 Use "$!" specifier of mrb_get_args. 2017-07-12 14:49:55 +09:00
Yukihiro "Matz" Matsumoto e9b57124a0 Update mrb_get_args() document. 2017-07-12 14:49:06 +09:00
Yukihiro "Matz" Matsumoto adf453a584 Add "*!" argument specifier to avoid stack copying. 2017-07-12 14:48:23 +09:00
Yukihiro "Matz" Matsumoto 059d707e3a Add ary_modify_check() to Array#unshift; ref #3737 2017-07-12 14:44:36 +09:00
Yukihiro "Matz" Matsumoto e1de86134d Merge pull request #3740 from christopheraue/fix_test_output
fixed printing failed assertions
2017-07-12 08:24:02 +09:00
Christopher Aue 495a2e605d fixed printing failed assertions 2017-07-11 12:53:48 +02:00
Yukihiro "Matz" Matsumoto fc666bfe20 POSFIXABLE and NEGFIXABLE should take one argument. 2017-07-11 09:02:24 +09:00
Yukihiro "Matz" Matsumoto 46dee5716f Resurrect POSFIXABLE and NEGFIXABLE; ref 9186828 2017-07-10 09:42:48 +09:00
Yukihiro "Matz" Matsumoto 01fce3dc35 Merge pull request #3739 from ksss/array-shift
Should only check frozen fix #3737
2017-07-09 19:58:11 +09:00
ksss bf48473cf6 Should only check frozen for Array#pop 2017-07-09 18:05:21 +09:00
ksss c76dc33116 Add frozen test for Array#shift 2017-07-09 17:53:12 +09:00
ksss e581f2ed97 Should only check frozen fix #3737 2017-07-09 17:47:10 +09:00
Yukihiro "Matz" Matsumoto ce6c05600a Add fallback definitions of DBL_EPSILPN and LDBL_EPSILON; fix #3733
This is a workaround for mingw-w64 (5.3.1) bug.
2017-07-07 22:47:49 +09:00
Yukihiro "Matz" Matsumoto 718a9ceb6e Reduce allocation size of backtrace arrays. 2017-07-06 09:33:53 +09:00
Yukihiro "Matz" Matsumoto 542f0f7b16 Avoid out-of-bounds access of the backtrace array. 2017-07-06 09:32:28 +09:00
Yukihiro "Matz" Matsumoto 91868286be FIXABLE_FLOAT() fails sometimes in MRB_INT64 environment. 2017-07-06 09:05:46 +09:00
Yukihiro "Matz" Matsumoto cc04f03393 print("%d", 0) should not print -0; fix #3731 2017-07-05 23:31:50 +09:00
Yukihiro "Matz" Matsumoto 2ef5d22b60 Put a space between error position and error message.
For readability's sake.
2017-07-05 18:34:27 +09:00
Yukihiro "Matz" Matsumoto b68e7a605c Negation was not a good way to handle negative integers; fix #3729
There's a number that negation does not work (-2147483648 in 32bit
environment).
2017-07-05 18:13:37 +09:00
Yukihiro "Matz" Matsumoto b643a1a8bc In Ruby, sprintf specifier %u should behave as %d; fix #3730
Since there's no unsigned integer in Ruby. Binary, octal and
hexadecimal negative numbers can be represented by using 2's
compliment. But decimal (not being power of 2) cannot be use
that kind of format.
2017-07-05 17:48:40 +09:00
Yukihiro "Matz" Matsumoto bd66c5d716 Check stack size before accessing env stack; fix #3727 2017-07-05 09:19:06 +09:00
Yukihiro "Matz" Matsumoto cc01dedc65 Avoid undefined behavior of left shifting negative integer; #3728 2017-07-05 03:11:39 +09:00
Yukihiro "Matz" Matsumoto c377d504f6 Avoid undefined behavior of signed integer overflow; fix #3728 2017-07-05 03:11:39 +09:00
Yukihiro "Matz" Matsumoto c6bd8ceab7 Merge pull request #3726 from mruby/stable
mruby-1.3.0
2017-07-04 15:46:38 +09:00
Hiroshi Mimaki 277391e1b2 Set the mruby-1.3.0 release date to 2017-7-4. 2017-07-04 09:15:16 +09:00
Yukihiro "Matz" Matsumoto e9cdc88008 Refactor sprintf() code. 2017-07-04 08:50:39 +09:00
Yukihiro "Matz" Matsumoto 31bc2b0009 Initialize flags for each loop. 2017-07-04 08:46:33 +09:00
Hiroshi Mimaki ba1cd56ffa Fixed an unit test to work on Cygwin. 2017-07-03 16:01:01 +09:00
Yukihiro "Matz" Matsumoto 9b8956cdd0 break should not cross fiber-context boundary; fix #3724 2017-07-01 12:45:27 +09:00
Yukihiro "Matz" Matsumoto 7d99830211 super may be called from a block; fix #3723 2017-07-01 12:45:27 +09:00
Yukihiro "Matz" Matsumoto 466a18b0d3 Remove redundant use of Object#to_s in interpolation. 2017-06-28 23:28:24 +09:00
Yukihiro "Matz" Matsumoto aee1476ebd Provide better way to check compile errors.
Now you can just call `mrb_load_*` functions then check
`context->parser_nerr > 0` if the return value is `undef`,
instead of calling `mrb_parse_*` functions independently.
ref #3248 #3331
2017-06-28 16:04:40 +09:00
Yukihiro "Matz" Matsumoto 15945e14b9 Revert "Make mrb_load_exec a static function."
This reverts commit 7944d9a6d4.
Because it voids #3248 and #3331. But we should add better way
to check whether compile errors occur without duplicated callings.
2017-06-28 16:00:59 +09:00
Yukihiro "Matz" Matsumoto f0abd4241f Avoid mrb_funcall() unless absolutely necessary; ref #3722
As a result, `#chr` is not called for ch < 0x80, so we need to
update the "invalid chr" test.
2017-06-28 12:03:53 +09:00
Yukihiro "Matz" Matsumoto 3554a41a54 Remove unnecessary initialization of a local variable. 2017-06-27 22:48:06 +09:00
Yukihiro "Matz" Matsumoto 877e16501c No longer need to copy argv from mrb_get_args; ref #3722 2017-06-27 22:47:26 +09:00
Yukihiro "Matz" Matsumoto 1a3b32343e Copy argv from VM stack to avoid use-after-free; fix #3722 2017-06-27 22:43:37 +09:00
Yukihiro "Matz" Matsumoto b30eba6a13 Make LocalJumpError a subclass of ScriptError.
It's incompatible with CRuby, but it is required for mruby because
it cannot detect `break` outside of loops in the parsing time, but
in the code generation time where it cannot raise `SyntaxError`.
2017-06-23 18:08:38 +09:00
Yukihiro "Matz" Matsumoto d0717efda6 Should raise an exception if break called in ensure; fix #3721 2017-06-23 18:08:04 +09:00
Yukihiro "Matz" Matsumoto 7944d9a6d4 Make mrb_load_exec a static function. 2017-06-23 17:56:12 +09:00
Yukihiro "Matz" Matsumoto 9a59cd7af8 Silence mrbmemcpy and mrbmemset warnings. 2017-06-23 17:54:02 +09:00
Yukihiro "Matz" Matsumoto b200c7475a No need to mark stacks of terminated fibers; fix #3720 2017-06-22 02:05:14 +09:00
Yukihiro "Matz" Matsumoto c41e262667 Add write barrier to protect singleton class from GC; fix #3717 2017-06-22 01:20:22 +09:00
Yukihiro "Matz" Matsumoto af0bef6dd8 Silence rubocop warnings. 2017-06-22 00:27:17 +09:00
Yukihiro "Matz" Matsumoto e8a4e4262a Add write barrier to protect proc reference from fiber; fix #3719 2017-06-21 17:59:14 +09:00
Yukihiro "Matz" Matsumoto 464d3fc0a3 Use alias enum_for to_enum instead of alias :enum_for :to_enum. 2017-06-21 11:13:43 +09:00
Yukihiro "Matz" Matsumoto 057be5ffb5 use unless instead of if not. 2017-06-21 11:13:33 +09:00
Yukihiro "Matz" Matsumoto d0a7e01d9c Should call ecall() before callinfo adjustment; fix #3715 2017-06-21 02:51:55 +09:00
Yukihiro "Matz" Matsumoto bf1cb87b34 Array size can be cause integer overflow; fix #3710 2017-06-20 20:19:37 +09:00
Yukihiro "Matz" Matsumoto 39779b339e Merge pull request #3718 from miura1729/original
#3711 fix
2017-06-20 16:18:07 +09:00
Miura Hideki 0fa94f9ead #3711 fix 2017-06-20 12:50:00 +09:00
Yukihiro "Matz" Matsumoto 615e7e44e3 Avoid using snprintf(3) in case MRB_DISABLE_STDIO; fix #3714 2017-06-20 09:39:33 +09:00
Yukihiro "Matz" Matsumoto 455f3954dc Merge pull request #3713 from Asmod4n/patch-2
Save gc_arena after buffer got allocated
2017-06-20 09:16:38 +09:00
Asmod4n abca63c73b Save gc_arena after buffer got allocated
Latest fix was freeing the buffer while it was still in use.
Fixes #3712
2017-06-19 20:27:38 +02:00
Yukihiro "Matz" Matsumoto 0de7eec628 Fixed disclosure of local variables by eval; ref #3710
This patch fixes the latter part of #3710. We need to change
`struct REnv` to fix the former part of the issue.
2017-06-19 22:00:16 +09:00
Yukihiro "Matz" Matsumoto 4d3027b08e Increment the version number to 1.3.0. 2017-06-19 16:47:25 +09:00
Yukihiro "Matz" Matsumoto ea250d5f52 Increment RITE_BINARY_FORMAT_VER.
The behavior of `OP_RAISE` has been changed.
2017-06-19 09:23:03 +09:00
Yukihiro "Matz" Matsumoto 667e788159 Use mrb_int instead of int as argument to mrb_hash_new_capa. 2017-06-19 09:21:07 +09:00
Yukihiro "Matz" Matsumoto b0f918d1bd Use mrb_int instead of int. 2017-06-17 10:51:23 +09:00
Yukihiro "Matz" Matsumoto 4b55174fc5 Merge pull request #3706 from MasahikoSawada/fix_typo
Fix a typo in gc.c.
2017-06-17 08:40:57 +09:00
Yukihiro "Matz" Matsumoto 08c385ff66 Mark the GC arena in final_marking_phase.
Arena can be modified during the marking phase.
2017-06-17 08:39:43 +09:00
Yukihiro "Matz" Matsumoto 819ccd3b85 Mark the root context in final_marking_phase.
Because the root context cannot be marked from fibers.
2017-06-17 08:39:43 +09:00
Yukihiro "Matz" Matsumoto 8daabe7115 Mark global variables in final_marking_phase; fix #3704 2017-06-17 08:39:43 +09:00
Yukihiro "Matz" Matsumoto a985847224 Store operands to local variables.
Mostly for debugging purpose.
2017-06-17 08:39:43 +09:00
Yukihiro "Matz" Matsumoto 497a0a791e Correct comments in gc.c 2017-06-17 08:39:43 +09:00
Yukihiro "Matz" Matsumoto aa8121cf3a Use mrb_int instead of size_t for array capacity and length. 2017-06-17 08:39:43 +09:00
Masahiko Sawada 4f0900ef6e Fix a typo in gc.c. 2017-06-17 00:06:16 +09:00
Yukihiro "Matz" Matsumoto 0411cea2df Use MRB_PRId instead of d for mrb_int decimal specifier; ref #3701 2017-06-16 11:50:38 +09:00
Yukihiro "Matz" Matsumoto 6fdf2b035d Merge branch 'ksss-string-upto' 2017-06-16 11:48:32 +09:00
Yukihiro "Matz" Matsumoto e96f254ead Use mrb_str_new() instead of malloc(); ref #3701
Otherwise the function may terminate and cause memory leaks.
2017-06-16 11:46:40 +09:00
Yukihiro "Matz" Matsumoto 473b2bb20d Should not use sizeof(buf) when buf is char*; #3701 2017-06-16 11:42:51 +09:00
Yukihiro "Matz" Matsumoto a7770a39aa Merge branch 'string-upto' of https://github.com/ksss/mruby into ksss-string-upto 2017-06-16 11:35:42 +09:00
Yukihiro "Matz" Matsumoto d4d99dd6d7 Allow break from a block called by mrb_yield; close #3359
This means #3701 is now OK to merge.
2017-06-16 11:34:11 +09:00
Yukihiro "Matz" Matsumoto 9e6a3f6c95 Use MRB_THROW instead of mrb_exc_raise. 2017-06-16 11:22:17 +09:00
Yukihiro "Matz" Matsumoto 6a66ce10b3 Need to unshare env from top callinfo; fix #3685 2017-06-16 08:25:34 +09:00
Yukihiro "Matz" Matsumoto ebd6636a1e Call write barriers for stack-modified fibers; fix #3699 2017-06-15 23:20:36 +09:00
Yukihiro "Matz" Matsumoto d7e09ffa5f Print the file name along with line number on syntax errors; fix #3698 2017-06-15 15:46:03 +09:00
Yukihiro "Matz" Matsumoto 47bd44fce1 Prevent Fiber#initialize to be called twice; fix #3705 2017-06-15 15:16:56 +09:00
Yukihiro "Matz" Matsumoto b298e241c8 Protect the last exception object from GC in ecall; fix #3702 2017-06-15 14:57:18 +09:00
Yukihiro "Matz" Matsumoto 357e478e2c Mark the exception object in the final marking phase; ref #3702 2017-06-15 14:53:49 +09:00
Yukihiro "Matz" Matsumoto 52443c80e2 Save the register value in a local variable for ease of debugging. 2017-06-15 14:52:58 +09:00
Yukihiro "Matz" Matsumoto 988e2ced03 Ensure size of the stack before handling exceptions; fix #3693 2017-06-15 13:37:27 +09:00
Yukihiro "Matz" Matsumoto af6041f1d0 Ensure size of the stack in OP_CALL. 2017-06-15 13:36:36 +09:00
Yukihiro "Matz" Matsumoto bb1bfaa2fb Add helper functions to use gdb reverse-next.
On my machine, gdb reverse-next does not work with memcpy and memset.
Add naive implementation of those functions to override.
2017-06-15 13:32:15 +09:00
Tomoyuki Sahara 04774e5bf2 remove unused exception variables. 2017-06-15 11:00:26 +09:00
Tomoyuki Sahara 7c62d89348 Merge pull request #88 from christopheraue/master
Fix for IO#read(n) with n > IO::BUF_SIZE
2017-06-15 10:53:01 +09:00
ksss 4d9ca27ba6 Use malloc instead of dynamic allocation 2017-06-14 18:28:39 +09:00
ksss 432a813905 Fix arena overflow error 2017-06-14 18:12:56 +09:00
ksss 19785f43d1 Reimplement String#upto 2017-06-14 17:30:31 +09:00
Christopher Aue 3642fe4013 fixed #87: IO#read(n) with n > IO::BUF_SIZE 2017-06-13 21:40:36 +02:00
Yukihiro "Matz" Matsumoto b979226871 Clear stack in OP_CALL; fix #3694 2017-06-14 02:49:07 +09:00
Yukihiro "Matz" Matsumoto 7830b841c7 Fixed uninitialized local variable bug; ref #3692 2017-06-14 01:55:05 +09:00
Yukihiro "Matz" Matsumoto b32ad1307f The out-of-memory error should not be an instance of RuntimeError.
And arena-overflow error as well.  They should not be caught by
`rescue` by default.
2017-06-14 01:01:36 +09:00
Yukihiro "Matz" Matsumoto edb5b3672b Avoid out-of-bound access of VM stack in OP_SENDB; fix #3692 2017-06-14 00:46:21 +09:00
Tomoyuki Sahara 81a0dcdb7a sizeof(optval) must be 1 for IP_MULTICAST_TTL & IP_MULTICAST_LOOP. fixes #34. 2017-06-13 12:13:04 +09:00
Tomoyuki Sahara fe99819bc9 Merge pull request #85 from ksss/read
Support outbuf argument for IO#read
2017-06-12 16:17:53 +09:00
Tomoyuki Sahara c279f00109 Merge pull request #86 from ksss/write
Reseek when write
2017-06-12 16:15:31 +09:00
Tomoyuki Sahara 0b41066e83 Merge pull request #84 from ksss/pos
To accurate `pos`
2017-06-12 15:43:44 +09:00
ksss 051d7bc8db Reseek when write 2017-06-12 09:57:18 +09:00
ksss 1ebe1c8b1f Support outbuf argument for IO#read 2017-06-12 09:43:02 +09:00
ksss 27f422880f To accurate pos
pos shouldn't cache because it's not controllable
2017-06-11 23:22:04 +09:00
Yukihiro "Matz" Matsumoto b9f771dc50 Handles exceptions from code generation phase; fix #3695 2017-06-07 13:29:08 +09:00
Tomoyuki Sahara 3a73a58493 mruby 1.2.0 assumes test blocks return their results. master does not. 2017-06-07 11:36:37 +09:00
Tomoyuki Sahara 383a9c79e1 Merge pull request #13 from ksss/unpack-utf8
Support unpack template "U"
2017-06-07 11:09:43 +09:00
Tomoyuki Sahara dab87cf960 Merge pull request #80 from ksss/sysread
IO#sysread Check for readable
2017-06-05 16:21:30 +09:00
Yukihiro "Matz" Matsumoto fc7096f18a Limit recursion level of codegen(); fix #3690 2017-06-05 13:18:31 +09:00
Yukihiro "Matz" Matsumoto 788cea2b43 Revert "Simplify rescue stack management; ref #3683"
This reverts commit eb5a606fe2 and
079f310fbc.
The rescue stack works differently from ensure stack, so the change
caused #3686 and #3688. It might take long to solve the problems,
so that I would revert the changes for now. Fix #3688
2017-06-03 23:32:15 +09:00
Yukihiro "Matz" Matsumoto c9a4f8a63b Prohibit changing generational mode during GC disabled; fix #3689 2017-06-03 16:35:20 +09:00
Yukihiro "Matz" Matsumoto 935649b844 Check if a block is a lambda before marking it orphan; ref #3640 2017-06-03 13:48:09 +09:00
Yukihiro "Matz" Matsumoto c041206ad1 Add checks for break from proc-closure; fix #3640 2017-06-03 12:44:29 +09:00
Yukihiro "Matz" Matsumoto ab85d3c814 Make break in lambdas work as return according to CRuby behavior. 2017-06-02 14:22:18 +09:00
Yukihiro "Matz" Matsumoto 7f417ade42 Revert "Update NODE_BLOCK check logic in void_expr_error."
This reverts commit 31e30686b0.
2017-06-02 13:31:03 +09:00
Yukihiro "Matz" Matsumoto a8bf3742c6 Fixed a bug that make a loop in singleton_class clone; fix #3687 2017-06-02 13:25:15 +09:00
Yukihiro "Matz" Matsumoto 31e30686b0 Update NODE_BLOCK check logic in void_expr_error. 2017-06-02 13:01:29 +09:00
Yukihiro "Matz" Matsumoto 563036eaba Restore test/t/codegen.rb 2017-06-02 12:19:36 +09:00
Yukihiro "Matz" Matsumoto 0f2f021330 Fixed a bug in void_expr_error. 2017-06-02 12:06:40 +09:00
Yukihiro "Matz" Matsumoto b59d244c0d Add more precise void expression checks; ref #3686 2017-06-02 11:53:26 +09:00
Yukihiro "Matz" Matsumoto e0fbf25f90 Remove tests which can not be compiled on CRuby. 2017-06-02 11:51:59 +09:00
Yukihiro "Matz" Matsumoto 079f310fbc Adjust ridx if mrb_yield terminated by break; fix #3686
This issue is related to #3640.
2017-06-02 11:26:32 +09:00
Yukihiro "Matz" Matsumoto 51e0e690c2 Avoid invoking GC when disabled or iterating; fix #3681 2017-06-01 19:47:33 +09:00
Yukihiro "Matz" Matsumoto 87cc0344cd Call stack_clear() after stack_extend(); fix #3682 2017-06-01 19:35:15 +09:00
Yukihiro "Matz" Matsumoto eb5a606fe2 Simplify rescue stack management; ref #3683 2017-06-01 19:18:24 +09:00
Yukihiro "Matz" Matsumoto 7ff90b52d8 Simplify ensure stack management; fix #3683 2017-06-01 19:17:48 +09:00
Yukihiro "Matz" Matsumoto 72b635f7d2 Hide OP_EXEC lambda body from ObjectSpace#each_object; fix #3680 2017-06-01 15:40:07 +09:00
Yukihiro "Matz" Matsumoto 90fb4dd5b3 Print most recent call last as CPython does. 2017-06-01 09:48:04 +09:00
Yukihiro "Matz" Matsumoto a893877b0d Check for super using OP_ARGARY; fix #3678
It generates a wasted empty array for each `super` call though.
It should be fixed in the future, if possible.
2017-06-01 09:38:42 +09:00
Yukihiro "Matz" Matsumoto b0f2bc39db Clear VM stack in OP_EXEC; ref #3678 2017-06-01 08:45:56 +09:00
Yukihiro "Matz" Matsumoto eb69eebfd7 Simplify code since OP_EXEC never takes CFUNC Proc; #3678 2017-06-01 08:28:38 +09:00
Yukihiro "Matz" Matsumoto ff7df939ba Restore MRB_API function mrb_exc_backtrace(mrb, exc); ref 9644ad5 2017-05-31 23:15:17 +09:00
Yukihiro "Matz" Matsumoto 2837de95fe Prevent splicing big recursive arrrays; ref #3679
We know this is not perfect, but this change makes hack like #3679
bit harder. Harmless for useful cases.
2017-05-31 23:03:39 +09:00
Yukihiro "Matz" Matsumoto b4a4e3c09a Simplify the logic in mrb_realloc; ref #3679 2017-05-31 23:02:59 +09:00
Yukihiro "Matz" Matsumoto 7dbbd77407 Revert 4566c80; fix #3679
The patch deallocate the memory in `mrb_default_allocf` but that
hinders GC in `mrb_realloc`.
2017-05-31 23:01:04 +09:00
Yukihiro "Matz" Matsumoto 877f9d02e6 Avoid infinite loop on negative exponent; fix #3677 2017-05-31 09:53:19 +09:00
Yukihiro "Matz" Matsumoto acd3ac62a8 Reduce the size of VM stack clear window; ref #3676 2017-05-31 06:39:12 +09:00
Yukihiro "Matz" Matsumoto 2599c1932e Clear VM stack for top level; fix #3676
Top-level local variables contained junk after ab25eaea2
2017-05-31 00:18:32 +09:00
Yukihiro "Matz" Matsumoto ef1158485b Check env context before jump from OP_RETURN; fix #3673 2017-05-30 15:42:10 +09:00
Yukihiro "Matz" Matsumoto 27a5e10454 Avoid using C++ style comments (//). 2017-05-30 11:47:59 +09:00
Yukihiro "Matz" Matsumoto 4b15d5d1e3 Initialize String before Exception; fix #3672
The old order generated some strings with their class set to NULL.
2017-05-30 11:38:54 +09:00
Yukihiro "Matz" Matsumoto 650cfb9e4c Exceptions in fibers must be re-raised via #resume; fix #3675 2017-05-30 11:06:00 +09:00
Yukihiro "Matz" Matsumoto cbd4aae41c Mark the proc object representing top-level as an internal object; #3621 2017-05-29 14:13:17 +09:00
Yukihiro "Matz" Matsumoto abed375ea6 Mark proc objects representing methods as internal objects; fix #3621 2017-05-29 14:12:23 +09:00
Yukihiro "Matz" Matsumoto 02670ffa8d Protect the returning value in OP_RETURN; fix #3669
Even though the returning value is retrieved from the stack,
it may be freed if GC is caused during stack rewinding
(e.g. ensure calls).
2017-05-29 10:33:43 +09:00
Yukihiro "Matz" Matsumoto 9f634a6f8b Mark the current context (not root) in final marking. 2017-05-29 10:32:42 +09:00
Yukihiro "Matz" Matsumoto 8e390cccae Fixed rounding functions (round,ceil,floor,truncate) in MRB_INT64.
They didn't work well with inexact numbers (inf,nan). Fix #3671
2017-05-27 23:51:22 +09:00
Yukihiro "Matz" Matsumoto 34dd258c63 Unwind callinfo (mrb->c->ci) when a fiber termitates with error.
Fix #3668
2017-05-27 18:42:08 +09:00
Yukihiro "Matz" Matsumoto 57ffa1c150 Avoid unsharing env when context (mrb->c) differs; ref #3668 2017-05-27 18:40:15 +09:00
ksss a3a4f4d061 IO#sysread Check for readable 2017-05-27 13:34:11 +09:00
Yukihiro "Matz" Matsumoto 54b45f6a1b Use RData instead of String to represent backtrace. 2017-05-26 22:30:27 +09:00
Yukihiro "Matz" Matsumoto f269d1eb40 Distinguish OP_R_NORMAL and OP_R_RETURN. 2017-05-26 11:23:27 +09:00
Yukihiro "Matz" Matsumoto e3438f404a Invoke ensure clauses on Fiber termination; fix #3666
Related to #3662
2017-05-26 10:50:51 +09:00
Yukihiro "Matz" Matsumoto 83fc915213 Add new range check macro FIXABLE_FLOAT(); ref #3652
When MRB_INT64, valid value range of mrb_int is bigger than double,
which only has 53 bits significant precision.
2017-05-26 09:54:10 +09:00
Yukihiro "Matz" Matsumoto 3c31278236 Fix indentation in mrb_init_numeric() 2017-05-26 09:31:45 +09:00
Yukihiro "Matz" Matsumoto 535f13f3d7 fixup! Let Fixnum#{ceil,floor,round,truncate} to return itself; #3652 2017-05-26 09:29:39 +09:00
Yukihiro "Matz" Matsumoto c80696fcd3 Let Fixnum#{ceil,floor,round,truncate} to return itself; #3652 2017-05-26 09:25:16 +09:00
Yukihiro "Matz" Matsumoto 06c4933f90 Try our own ipow() if both base and exp are fixnums; fix #3652 2017-05-26 02:19:07 +09:00
Yukihiro "Matz" Matsumoto 9e40586d43 Add cast to mrb_int in mrb_fixnum() when MRB_WORD_BOXING.
Without this cast, `long int:63` can cause warnings.
2017-05-26 02:16:18 +09:00
Yukihiro "Matz" Matsumoto 7e4731655f Fixed off-by-one error in fiber_switch(); ref #3641 2017-05-26 01:24:28 +09:00
Yukihiro "Matz" Matsumoto f75f506181 Revert 01f7825; fix #3650
Redundant `mark_context() is far better than crashes.
2017-05-25 21:58:15 +09:00
Yukihiro "Matz" Matsumoto ac442bc1df Raise an exception when transfer arguments are too many; fix #3641
The fix was proposed by @block8437.  Thank you.
2017-05-25 21:39:13 +09:00
Yukihiro "Matz" Matsumoto de48d95c6d Avoid marking possibly freed stack; #3550 #3612 2017-05-25 19:58:06 +09:00
Yukihiro "Matz" Matsumoto c53747dbdf Revert "Use env preserved in Proc structure in ecall(); fix #3612"
This reverts commit e26e118604.
Fix #3664
2017-05-25 19:57:46 +09:00
Yukihiro "Matz" Matsumoto 517cd51cea Invoke ensure clauses before switching context from fibers; fix #3662 2017-05-25 14:36:25 +09:00
Yukihiro "Matz" Matsumoto ed16535c73 Clear top level env in mrb_top_run(); fix #3643 2017-05-25 14:13:54 +09:00
Yukihiro "Matz" Matsumoto f88cb88073 Avoid unsharing stack if env refers top-level; ref #3643 2017-05-25 14:13:16 +09:00
Yukihiro "Matz" Matsumoto e0931126ff Check env stack length before OP_SETUPVAR; ref #3643 2017-05-25 14:12:16 +09:00
Yukihiro "Matz" Matsumoto e969229b77 Check backtrace info may not be set (esp. NoMemError); fix #3663 2017-05-25 12:56:19 +09:00
Yukihiro "Matz" Matsumoto 5e1a6a2cc2 Make gen_assignment() to support NODE_SCALL; ref #3658 2017-05-25 12:40:49 +09:00
Yukihiro "Matz" Matsumoto 4566c80d7b Free given pointer if realloc() fails; fix #3658 2017-05-25 12:36:38 +09:00
Yukihiro "Matz" Matsumoto ff46957ef0 Avoid using mrb_raise() in mrb_vm_exec(); ref #3660 2017-05-25 11:11:40 +09:00
Yukihiro "Matz" Matsumoto 3ef97e3dd9 Under MRB_INT64, width may be bigger than INT_MAX; fix #3665 2017-05-25 10:40:35 +09:00
Yukihiro "Matz" Matsumoto 9bca887ac4 Preserve the current pc before method_missing(); fix #3660 2017-05-25 10:31:48 +09:00
Yukihiro "Matz" Matsumoto 9644ad51b4 Simplify backtrace mechanism; fix #3633 #3634 #3644
Instead of preserving a backtrace in `mrb_state`, `mrb_exc_set`
keeps packed backtrace in an exception object. `#backtrace` unpacks
it to an array of strings.
2017-05-23 23:50:42 +09:00
Yukihiro "Matz" Matsumoto d2458e66c2 Remove class info from backtrace lines. 2017-05-23 23:50:42 +09:00
Yukihiro "Matz" Matsumoto 497b19ce22 Support the case when the backtrace is not an array. 2017-05-23 23:50:42 +09:00
Yukihiro "Matz" Matsumoto a1ea2a670c Use index in each_object. 2017-05-23 23:50:42 +09:00
Yukihiro "Matz" Matsumoto 24a24a41dd Type check before print_backtrace() 2017-05-23 23:50:42 +09:00
Yukihiro "Matz" Matsumoto bb0b52a568 Update comments regarding Exception#to_str 2017-05-23 23:50:42 +09:00
Tomoyuki Sahara 0c0b34136e Merge pull request #78 from ksss/syswrite
Should raise SyscallError on IO#syswrite
2017-05-23 15:09:04 +09:00
Tomoyuki Sahara 87771ecf92 Merge pull request #79 from ksss/ioerror
Fix some spec for IO#sysread
2017-05-23 15:06:15 +09:00
ksss 0bbd60b523 IO#sysread should raise error when invalid pos 2017-05-22 11:47:45 +09:00
ksss 86edc9ab85 IO#sysread should raise IOError when closed 2017-05-21 22:54:46 +09:00
ksss 844b2c368f IO#sysread with 0 always return empty string 2017-05-21 22:54:12 +09:00
Yukihiro "Matz" Matsumoto 1bb6964db6 Merge pull request #3661 from ksss/string-concat
String#concat: Try to convert when not string
2017-05-21 22:53:01 +09:00
ksss c43795c664 Should raise SyscallError on IO#syswrite
instead of IOError
2017-05-21 17:10:15 +09:00
ksss 98f9c33fe0 String#concat: Try to convert when not string 2017-05-21 10:30:27 +09:00
Tomoyuki Sahara 6836f424c5 "open" error message should include pathname. fixes #77. 2017-05-19 17:14:43 +09:00
Yukihiro "Matz" Matsumoto 78add72812 Merge pull request #3659 from craiglrock/master
Avoid call to_s during backtrace traversal
2017-05-16 10:04:19 +09:00
Craig Lehmann 3de2da409b Avoid call to_s during backtrace traversal 2017-05-15 20:40:47 -04:00
Yukihiro "Matz" Matsumoto 82bc036a59 Merge pull request #3657 from ksss/str-embed
Make string embad from shared
2017-05-14 00:28:32 +09:00
ksss bdb36b3404 Make string embad from shared 2017-05-13 22:44:52 +09:00
Yukihiro "Matz" Matsumoto 171e732dc7 Merge pull request #3656 from clayton-shopify/fix-codegen-default
Change return back to break in the default case.
2017-05-13 09:37:34 +09:00
Clayton Smith bf30b8e8bf Change return back to break in the default case. 2017-05-12 14:43:12 -04:00
Yukihiro "Matz" Matsumoto 011e0bb0d9 Merge pull request #3649 from ksss/sprintf
Fix segmentation fault ref: #3648
2017-05-09 07:40:08 +09:00
ksss 30df7c8762 Fix segmentation fault ref: #3648 2017-05-08 23:18:14 +09:00
Yukihiro "Matz" Matsumoto ef305305b4 Merge pull request #3647 from ksss/split
Adjust to the optimum type
2017-05-05 21:34:59 +09:00
ksss 8cba9a9e42 Adjust to the optimum type 2017-05-05 14:20:21 +09:00
Yukihiro "Matz" Matsumoto 964a02f1fa Merge pull request #3645 from nobu/sprintf-refactor
Sprintf refactor
2017-04-29 13:10:34 +09:00
Nobuyoshi Nakada ef6e14ee2b Better error message
Raise argument error with the better message, at the only place
where the size to fill can be negative.
2017-04-29 10:17:24 +09:00
Nobuyoshi Nakada e05c30738e Use FILL and PUSH
Instead of loop or `memcpy` after `CHECK`, use dedicated macros,
`FILL` and `PUSH`, respectively.
2017-04-29 10:10:31 +09:00
Yukihiro "Matz" Matsumoto 3c10783769 Merge pull request #3639 from Asmod4n/patch-1
Add macOS support to mrb_ro_data_p
2017-04-26 07:49:14 +09:00
Asmod4n 9057a3f3be Add macOS support to mrb_ro_data_p
This adds macOS support to mrb_ro_data_p, fixes #3636
2017-04-25 20:34:07 +02:00
Yukihiro "Matz" Matsumoto cef523cc19 Avoid duplicated envadjust() of env stacks; fix #3637 2017-04-25 22:31:02 +09:00
Yukihiro "Matz" Matsumoto a3d80e8e73 Merge pull request #3637 from dabroz/fix-32-bit
Restore 32-bit OSX builds
2017-04-25 22:03:50 +09:00
Yukihiro "Matz" Matsumoto 3e07a2d77c Silence warnings caused by implicit type casting. 2017-04-25 21:00:16 +09:00
Yukihiro "Matz" Matsumoto 92dcfbaab3 Add explicit cast from double to long. 2017-04-25 17:43:03 +09:00
Yukihiro "Matz" Matsumoto b08dced2a6 Stop invoking GC before each_object to avoid test failure; #3616 2017-04-25 17:39:06 +09:00
Yukihiro "Matz" Matsumoto aa8e490fd5 Prevent GC during each_object; fix #3616 2017-04-25 17:25:48 +09:00
Tomoyuki Sahara 728d313b2c Merge pull request #76 from yyamano/issue-75
Make backquote work with the latest mruby. Fixed #75
2017-04-25 11:19:07 +09:00
Yukihiro "Matz" Matsumoto 88cd807379 Avoid use of snprintf() when DISABLE_STDIO is set; fix #3632
ref #3492 #3515 #3517
2017-04-25 10:41:50 +09:00
Yukihiro "Matz" Matsumoto 03cdb8e9dd Should terminate nested iterations in each_object; ref #3359 2017-04-25 10:41:50 +09:00
Yukihiro "Matz" Matsumoto 058da1fed2 Revert "Disable GC during gc_each_objects(); fix #3616"
This reverts commit d2cad9ac5b.
2017-04-25 10:41:50 +09:00
Yukihiro "Matz" Matsumoto 01f7825852 Use fiber marking instead of mark_context.
To avoid redundant `mark_context()`.
2017-04-25 10:41:50 +09:00
Tomasz Dąbrowski b1120464e0 Revert "Simplify pointer calculation in envadjust."
This reverts commit a1d32af916.
2017-04-24 23:57:39 +02:00
Yuji Yamano 311f4a230f Make backquote work with the latest mruby. Fixed #75 2017-04-24 02:40:01 -04:00
Yukihiro "Matz" Matsumoto 6088276cc8 Merge pull request #3630 from nobu/bug/sprintf-sp3inf
Fix space flag with inf/nan
2017-04-24 09:06:57 +09:00
Yukihiro "Matz" Matsumoto 72bdb6a93f Merge pull request #3631 from nobu/bug/embeddoc-terminator-word
Fix embedded document with unterminated terminator
2017-04-24 09:06:12 +09:00
Nobuyoshi Nakada d54f9f8f78 Fix embedded document with unterminated terminator
`skips()` is `mrb_bool` function, should return `FALSE` at EOF, not
`EOF`.
2017-04-23 11:41:00 +09:00
Nobuyoshi Nakada cd4e9a0518 Refactor "%f" % Inf/NaN
As for non-finite float, calculate the exact needed size with the
space flag.
2017-04-23 09:54:44 +09:00
Nobuyoshi Nakada 7314423bd1 Fix space flag when Inf/NaN and width==3
While `"% 2f"` and `"% 4f"` result in `" Inf"` and `" Inf"`
respectively, `"% 3f"` results in `"Inf"` (no space).
2017-04-23 09:54:20 +09:00
Yukihiro "Matz" Matsumoto 809b7ca3f4 Merge pull request #3628 from yyamano/libmruby-path
Add --libmruby-path support to mruby-bin-mruby-config.
2017-04-22 15:16:57 +09:00
Yukihiro "Matz" Matsumoto a4dfaaf1e8 Small cosmetic changes. 2017-04-22 15:09:41 +09:00
Yukihiro "Matz" Matsumoto e26e118604 Use env preserved in Proc structure in ecall(); fix #3612 2017-04-22 15:08:18 +09:00
Yukihiro "Matz" Matsumoto 5513fcee22 Keep reference to mrb_context from env; fix #3619 2017-04-22 14:35:36 +09:00
Yuji Yamano 52a03800d3 Add --libmruby-path support to mruby-bin-mruby-config. 2017-04-22 14:09:06 +09:00
Yukihiro "Matz" Matsumoto 3b0a36d399 Alias should push() extra stack space for blocks. 2017-04-22 12:03:56 +09:00
Yukihiro "Matz" Matsumoto a1d32af916 Simplify pointer calculation in envadjust. 2017-04-21 22:29:28 +09:00
Yukihiro "Matz" Matsumoto ad3b61f47b Revert e8dca6b03; fix #3550
Reopens #3612.
2017-04-21 22:29:28 +09:00
Yukihiro "Matz" Matsumoto 5d67d9b10d Fixed a possible memory leak. 2017-04-21 22:29:28 +09:00
Yukihiro "Matz" Matsumoto 15fba69710 Revert ae4217e81; fix #3619
Reopens #3550. Those 2 issues are exclusive.
2017-04-21 22:29:28 +09:00
Yukihiro "Matz" Matsumoto 95229ee164 Assign to local variable first; cosmetic change. 2017-04-21 22:29:28 +09:00
Yukihiro "Matz" Matsumoto c900fff9a1 Merge pull request #3623 from take-cheeze/struct_freeze
Support `freeze` method in `Struct`.
2017-04-21 22:28:32 +09:00
Yukihiro "Matz" Matsumoto c73da29aee Merge pull request #3624 from yyamano/fix-typo
Fix typo in usage message.
2017-04-21 22:27:52 +09:00
Yukihiro "Matz" Matsumoto 00770e2d3d Merge pull request #3625 from take-cheeze/pool_64bit
Align pool allocator with 8 byte in 64-bit environment.
2017-04-21 22:27:33 +09:00
Yukihiro "Matz" Matsumoto 02df2539df Merge pull request #3626 from take-cheeze/string_get_args_bug
Add missing `arg_i++` to fix bug of `s!` in mrb_get_args.
2017-04-21 22:27:07 +09:00
take_cheeze 3ce42a04e3 Add missing arg_i++ to fix bug of s! in mrb_get_args. 2017-04-21 17:52:29 +09:00
take_cheeze b2dc04393a Align pool allocator with 8 byte in 64-bit environment.
To avoid warnings from undefined sanitizer.
( https://clang.llvm.org/docs/UndefinedBehaviorSanitizer.html )
2017-04-21 17:34:31 +09:00
Yuji Yamano 33d09e4ad0 Fix typo in usage message. 2017-04-21 04:32:41 -04:00
take_cheeze da5b7fa769 Support freeze in Struct. 2017-04-21 17:23:54 +09:00
Yukihiro "Matz" Matsumoto 94bcdca64f VM stack may be reallocated in mrb_convert_type(); fix #3622 2017-04-21 09:11:28 +09:00
Yukihiro "Matz" Matsumoto 262fbaf566 mrb_int may overflow in bit-shifting; fix #3620 2017-04-21 08:55:19 +09:00
Yukihiro "Matz" Matsumoto 3567b26222 Bit-shifting zero should be zero; ref #3620 2017-04-21 08:36:29 +09:00
Yukihiro "Matz" Matsumoto d2cad9ac5b Disable GC during gc_each_objects(); fix #3616 2017-04-20 15:50:52 +09:00
Yukihiro "Matz" Matsumoto 62dae09bf6 Allow mrb_objspace_each_objects() to break iteration; ref #3359 2017-04-20 15:44:56 +09:00
Yukihiro "Matz" Matsumoto edd9fc6e75 Do not raise an exception for living closure; ref #3359 2017-04-20 13:14:01 +09:00
Yukihiro "Matz" Matsumoto 6a0b68f8b8 Use trampoline technique for instance_exec; ref #3359
A new function `mrb_yield_cont()` is provided. You have to call it
at the end of a C defined method, e.g. `return mrb_yield_cont()`.
2017-04-19 19:54:55 +09:00
Yukihiro "Matz" Matsumoto 77c2aa7b8a Need to raise "break from proc-closure" error; fix #3359 fix #3495
Some examples in #3359 still behave differently from CRuby.
2017-04-19 19:38:57 +09:00
Yukihiro "Matz" Matsumoto 283d145d3e Fixed a bug caused by last minute change; fix #3610
Omitted `goto L_RAISE` to raise an exception.
2017-04-19 09:28:58 +09:00
Yukihiro "Matz" Matsumoto fe3fe8fccc Merge pull request #3615 from clayton-shopify/fix-copy-class-null-pointer-deref
Check if sc->mt is initialized before copying it.
2017-04-19 07:07:03 +09:00
Clayton Smith de96994233 Check if sc->mt is initialized before copying it. 2017-04-18 11:18:58 -04:00
Yukihiro "Matz" Matsumoto 79e0314337 Call envadjust() before updating VM stack. 2017-04-18 16:49:43 +09:00
Yukihiro "Matz" Matsumoto ae4217e813 Fixed a wrong condition; fix #3550
Shared TT_ENV should be unshared. Reversed condition.
2017-04-18 16:49:14 +09:00
Yukihiro "Matz" Matsumoto e8dca6b034 Revert 6dd1a57; fix #3612; ref #3550
The fix was wrong. It causes a new problem #3612.
2017-04-18 16:48:50 +09:00
Yukihiro "Matz" Matsumoto a0143e148d Make mrb_codedump_all() to print type of Proc. 2017-04-18 12:40:36 +09:00
Yukihiro "Matz" Matsumoto f4119f518f Changed evaluation order of yield; ref #3613
So that `yield expr_with_error` will cause the error from the
argument rather than `LocalJumpError` when no block is given.
2017-04-18 12:00:52 +09:00
Yukihiro "Matz" Matsumoto f6c70bc6e8 super may call context switching method like send; fix #3611 2017-04-18 11:52:16 +09:00
Yukihiro "Matz" Matsumoto 05fceb5992 Call exc_debug_info() in mrb_exc_set(); ref #3610
Otherwise line number information is lacked from exceptions
raised in VM, e.g. "super called outside of method".
2017-04-18 10:28:49 +09:00
Yukihiro "Matz" Matsumoto 82ab46139e Add "no super" check to OP_ARGARY; fix #3610 2017-04-18 10:28:49 +09:00
Yukihiro "Matz" Matsumoto c3961847cf Hash#dup didn't check if internal khash is initialized; fix #3609 2017-04-18 09:55:32 +09:00
Yukihiro "Matz" Matsumoto 761493934e Mark whole root objects in final_marking_phase(); fix #3603
ref #1359 #1362
2017-04-17 16:06:18 +09:00
Yukihiro "Matz" Matsumoto 323121925a Merge pull request #3608 from clayton-shopify/fix-mirb-off-by-one
Fix an off-by-one causing a buffer overflow in mirb.
2017-04-14 07:07:52 +09:00
Clayton Smith 8e2279d1ff Fix an off-by-one causing a buffer overflow in mirb. 2017-04-13 10:51:26 -04:00
Yukihiro "Matz" Matsumoto 045e78c844 Proc#call needs to reserve at least 2 registers; fix #3606
One for the receiver, the other for the block.
2017-04-13 11:02:02 +09:00
Yukihiro "Matz" Matsumoto 17377af984 Struct may not be initialized in #to_h; fix #3607 2017-04-13 10:51:16 +09:00
Yukihiro "Matz" Matsumoto aec121f755 Update NODE_XSTR, NODE_DSXTR tests; ref #3605 2017-04-13 07:54:51 +09:00
Yukihiro "Matz" Matsumoto c0a4b1a0c6 Merge pull request #3604 from keizo042/fix_issue3598
Find Class/Module in nested singleton class; fix #3598
2017-04-13 00:42:26 +09:00
Yukihiro "Matz" Matsumoto 3123549bcb Fixed a bug in NODE_XSTR code generation; fix #3605 2017-04-13 00:38:47 +09:00
Kouichi Nakanishi d4205c9b20 Use while statement instead of for statement 2017-04-12 23:27:09 +09:00
Kouichi Nakanishi 4fca570a74 Find Class/Module in nested singleton class; fix #3598 2017-04-12 22:41:36 +09:00
Yukihiro "Matz" Matsumoto 4e84bdb507 Let 'mrb_vm_run()` to restore the calling fiber; ref #3537 2017-04-12 11:01:23 +09:00
Yukihiro "Matz" Matsumoto 0fb05eb55f Should not unshare env stack repeatedly; fix #3601 2017-04-12 10:41:06 +09:00
Yukihiro "Matz" Matsumoto 2a4db1a4be method_missing might have updated stack beyond boundary; fix #3599 2017-04-12 10:28:57 +09:00
Yukihiro "Matz" Matsumoto 326e043a64 Exceptions may be raised in yyparse(); fix #3600 2017-04-12 10:23:34 +09:00
Yukihiro "Matz" Matsumoto 918e7bb187 Refactor check before mrb_class_ptr(); ref #3602 2017-04-12 09:20:57 +09:00
Yukihiro "Matz" Matsumoto a25404c305 The attached object may not be a class; fix #3602 2017-04-12 09:18:44 +09:00
Yukihiro "Matz" Matsumoto 6dd1a570c2 Shared TT_ENV may need to be marked; fix #3550 2017-04-11 12:40:26 +09:00
Yukihiro "Matz" Matsumoto fff4a4ed34 OP_LAMBDA generation should honor VAL/NOVAL; fix #3580 2017-04-11 02:30:24 +09:00
Yukihiro "Matz" Matsumoto db47ae5de5 Fixed a bug in mrb_convert_to_integer(); fix #3581
Did not update the result from `mrb_check_string_type()` before
string-to-integer conversion.
2017-04-11 02:00:02 +09:00
Yukihiro "Matz" Matsumoto 03c849338f Fiber#yield should check C function boundary; fix #3582 2017-04-11 01:51:25 +09:00
Yukihiro "Matz" Matsumoto 9094415acf An object attached to a singleton class may not be a class; fix #3587
The fix for #3539 was incomplete.
2017-04-10 22:02:51 +09:00
Yukihiro "Matz" Matsumoto 0048dd118a Protect arguments from GC; fix #3597
GC may be called with OP_ENTER (especially when GC_STRESS is set).
2017-04-10 21:12:41 +09:00
Yukihiro "Matz" Matsumoto a55b237d89 Callinfo may be changed in ecall(); fix #3589 2017-04-10 20:39:49 +09:00
Yukihiro "Matz" Matsumoto ab25eaea23 Avoid clearing VM stack every time to gain performance.
VM stack is cleared by 5c114c9, 0cb501 and c063641.
2017-04-10 09:59:36 +09:00
Yukihiro "Matz" Matsumoto 5c114c91d4 Clear unused stack region that may refer freed objects; fix #3596 2017-04-10 09:46:09 +09:00
Yukihiro "Matz" Matsumoto 491d68bb30 Skip stack marking at all if c->stack is NULL. 2017-04-10 09:28:36 +09:00
Yukihiro "Matz" Matsumoto 0cb501545c Fill omitted arguments by nil for non-strict Proc. 2017-04-10 09:24:42 +09:00
Yukihiro "Matz" Matsumoto c063641ab0 Clear local (but non-argument) variables in OP_ENTER.
Otherwise, the following script prints an uninitialized value.

def f(*a)
  if false
    b = 15
  end
  p b
end
f(1,2,3)
2017-04-10 08:25:44 +09:00
Yukihiro "Matz" Matsumoto 47f181519f Avoid updating regs[] from function calls; ref #3588 2017-04-08 17:47:35 +09:00
Yukihiro "Matz" Matsumoto 1fd3cc9e1d Merge pull request #3595 from keizo042/name_stack_size
Attach a name to  embbeded value of rescue/ensure stack size
2017-04-08 17:47:20 +09:00
Kouichi Nakanishi 15b55c32e9 Attach a name to embbeded value of rescue/ensure stack size 2017-04-08 11:22:41 +09:00
Yukihiro "Matz" Matsumoto 7e28510725 Merge pull request #3594 from keizo042/fix_isssue_3575
Get constant of parent class even if child class is defined in signle…
2017-04-07 11:39:11 +09:00
Kouichi Nakanishi fd0f79ca67 Get constant of parent class even if child class is defined in signleton class; fix #3575 2017-04-06 23:31:34 +09:00
Tomoyuki Sahara 7e014efe45 Merge pull request #14 from ksss/to_int
Should use `to_int` instead of `to_i`
2017-04-06 10:25:06 +09:00
Yukihiro "Matz" Matsumoto e5b61d34f6 Fixed possible SEGV in Kernel#block_given?; ref #3593 2017-04-06 10:07:53 +09:00
Yukihiro "Matz" Matsumoto 5e79bc9377 Make String#replace to check equality before modifying flags.
ref #3588
2017-04-06 08:25:25 +09:00
Yukihiro "Matz" Matsumoto a7b0ab3769 Save block argument position in e->cioff; fix #3593 2017-04-05 22:30:39 +09:00
Yukihiro "Matz" Matsumoto d9fb8b69b0 Fixed a bug in OP_SUPER block conversion; fix #3590 2017-04-05 18:22:26 +09:00
Yukihiro "Matz" Matsumoto bd7bf260e8 Should specify instance type of Structs; fix #3591 2017-04-05 17:52:26 +09:00
Yukihiro "Matz" Matsumoto 2daebfb6a7 Fixed a bug when method_missing take 126 args; fix #3592 2017-04-05 14:41:34 +09:00
Yukihiro "Matz" Matsumoto 60d20e1848 Should restore to the root fiber for each interaction; fix #3537 2017-04-05 13:53:43 +09:00
Yukihiro "Matz" Matsumoto 7f37c2fc57 Use stderr for debug prints in DEBUG(); fix #3584 2017-04-05 12:38:38 +09:00
Yukihiro "Matz" Matsumoto 74712c73ac Need to insert write barriers in struct updates; fix #3547 2017-04-05 11:53:20 +09:00
Uchio KONDO 38db5e550f Some adjustments 2017-04-04 12:16:53 +09:00
Uchio KONDO 9c2db2e134 Move class/module definitions to normal .rb files 2017-04-04 12:03:43 +09:00
Uchio KONDO 86b69d7c5d Initial skelton for class/module def 2017-04-04 11:57:17 +09:00
ksss d83e15e866 Should use to_int instead of to_i
For CRuby compatibility
2017-04-04 11:19:43 +09:00
Yukihiro "Matz" Matsumoto bdeb803f04 Merge pull request #3579 from clayton-shopify/fix-time-alloc-usec
Correctly handle large negative usec value.
2017-04-04 11:17:10 +09:00
ksss 0dbd1d5992 Add "U" template to doc 2017-04-04 11:07:15 +09:00
ksss f691a73c26 Should raise RangeError 2017-04-04 11:07:14 +09:00
ksss a80a745b69 Support unpack template "U" 2017-04-04 10:06:30 +09:00
Clayton Smith dc4fba28c5 Correctly handle large negative usec value. 2017-04-03 14:22:26 -04:00
Yukihiro "Matz" Matsumoto e2e2edae51 Merge pull request #3578 from bggd/appveyor_clone_depth
Change AppVeyor's clone_depth
2017-04-03 21:48:24 +09:00
bggd de114eb38d Change AppVeyor's clone_depth 2017-04-03 20:16:14 +09:00
Yukihiro "Matz" Matsumoto 12f6496ff8 Revert "Adjust VM stack window size; fix #3547"
This reverts commit 6dabb33635.
2017-04-03 19:49:42 +09:00
Yukihiro "Matz" Matsumoto 6dabb33635 Adjust VM stack window size; fix #3547 2017-04-03 19:12:13 +09:00
Yukihiro "Matz" Matsumoto ab63ee61ca Fixed out-of-bounds access of ensure[]; ref #3491 2017-04-03 18:47:38 +09:00
Yukihiro "Matz" Matsumoto b8461c8681 Protect ensure clause lambdas from GC; fix #3491 2017-04-03 18:38:49 +09:00
Yukihiro "Matz" Matsumoto 6a992a2579 Merge pull request #3577 from okkez/fix-return-value-of-each-slice
Change return value of Enumerable#each_slice
2017-04-03 18:04:57 +09:00
Yukihiro "Matz" Matsumoto fea8d00ef2 Merge pull request #3576 from okkez/fix-return-value-of-each-cons
Change return value of Enumberable#each_cons
2017-04-03 18:04:33 +09:00
Yukihiro "Matz" Matsumoto 0a1f15e57c Insert mrb_field_write_barrier() for GC; fix #3534 2017-04-03 18:01:43 +09:00
Yukihiro "Matz" Matsumoto 246db71139 Add struct REnv to union RVALUE; ref #3534 2017-04-03 18:01:17 +09:00
Yukihiro "Matz" Matsumoto 77331d127b Unify else clause style 2017-04-03 16:56:27 +09:00
Yukihiro "Matz" Matsumoto fbf4089d2f Remove spaces around parens 2017-04-03 16:49:18 +09:00
Kenji Okimoto cff54ab2f3 Change return value of Enumerable#each_slice
More compatibility to CRuby.
2017-04-03 16:46:47 +09:00
Kenji Okimoto 4975aa4c1c Change return value of Enumberable#each_cons
More compatibility to CRuby.
2017-04-03 16:42:53 +09:00
Yukihiro "Matz" Matsumoto 666787beb2 Adjust exit point in loop_pop(); fix #3541 2017-04-03 12:41:27 +09:00
Yukihiro "Matz" Matsumoto d35fcf1ea2 NODE_SPLAT to pass VAL/NOVAL; fix #3532 2017-04-03 12:02:39 +09:00
Yukihiro "Matz" Matsumoto f5632f2f12 Restrict recursion levels in method_missing(); fix #3556
Note this is a temporary fix. Error message generation
(including `inspect`) should be deferred until its use.
2017-04-03 10:50:31 +09:00
Yukihiro "Matz" Matsumoto d27a3d47cd String#initialize to make a string empty; ref #3574 2017-04-03 10:22:38 +09:00
Yukihiro "Matz" Matsumoto a14a930c80 Remove unnecessary indirection; ref #3557 2017-04-03 10:03:58 +09:00
Yukihiro "Matz" Matsumoto 8193c0b566 Check before generating special operators (e.g. OP_ADD); fix #3557 2017-04-03 10:01:44 +09:00
Yukihiro "Matz" Matsumoto a49c9f86e7 Update callinfo->target_class in mrb_exec_irep(); fix #3543 2017-04-03 00:05:16 +09:00
Yukihiro "Matz" Matsumoto 081535bf02 Merge pull request #3573 from ksss/parameters
Fix parameters when noname rest
2017-04-02 23:54:30 +09:00
ksss 7f983928b9 Reduce object allocation 2017-04-02 23:34:26 +09:00
ksss be5c304b4c Fix parameters when noname rest 2017-04-02 23:30:05 +09:00
Yukihiro "Matz" Matsumoto 5d00e85314 Fixed out of bounds access; fix #3572, ref #3553 2017-04-02 20:32:11 +09:00
Yukihiro "Matz" Matsumoto 5a445f012e Add alias "append" to Array#push, and "prepend" to Array#unshift.
According to CRuby [Feature#12746]
2017-04-01 21:27:23 +09:00
Yukihiro "Matz" Matsumoto 93d802987e Extend VM stack just in case; ref #3551 2017-04-01 21:21:57 +09:00
Yukihiro "Matz" Matsumoto 071164b799 Should not shrink VM stack; fix #3551 2017-04-01 18:54:37 +09:00
Yukihiro "Matz" Matsumoto 56322cd5dd Pacify signed warning; ref #3565 2017-04-01 18:41:55 +09:00
Yukihiro "Matz" Matsumoto dcbfe71625 NODE_ASGN arguments may be 127 (CALL_MAXARGS) accidentally; fix #3559 2017-04-01 14:11:15 +09:00
Yukihiro "Matz" Matsumoto e22f37a166 Argument order of __case_eqq was wrong; fix #3567 2017-04-01 13:42:44 +09:00
Yukihiro "Matz" Matsumoto 1e87dfdf48 The stack may be reallocated in the func call; fix #3560 2017-04-01 13:20:19 +09:00
Yukihiro "Matz" Matsumoto 8d9d7c929e Improve Time.new() performance using division; fix #3561 2017-04-01 13:03:34 +09:00
Yukihiro "Matz" Matsumoto 195af525fb Expand stack for method_missing; fix #3528 2017-04-01 12:42:11 +09:00
Yukihiro "Matz" Matsumoto 9eb2ed0879 Merge pull request #3571 from keizo042/fix_get_constant_of_module_from_sigleton
Modify to get constant of parent module in singleton class; fix #3568
2017-03-31 16:39:21 +09:00
Kouichi Nakanishi 507e00e86f Modify to get constant of parent module in singleton class; fix #3568 2017-03-31 13:43:20 +09:00
Yukihiro "Matz" Matsumoto 39ca4ef3bc Avoid crash if hv.n is greater than kh_size(h); fix #3565
The resulting behavior is different from CRuby, but modifying
hash key afterwards is undefined behavior in ISO spec.
2017-03-31 13:02:01 +09:00
Yukihiro "Matz" Matsumoto 952207d243 small cosmetic change; ref #3570 2017-03-30 17:10:44 +09:00
Yukihiro "Matz" Matsumoto 669b18383d Merge pull request #3570 from keizo042/fix_cv_definition_in_singleton
Modify class variable definition in singleton class; fix #3539
2017-03-30 17:09:43 +09:00
Kouichi Nakanishi 5efe77fede Modify class variable definition in singleton class; fix #3539 2017-03-30 16:29:47 +09:00
Yukihiro "Matz" Matsumoto 898077a2c2 Merge pull request #3566 from okkez/fix-enumerator-each-with-index
Fix Enumerator#each_with_index with block
2017-03-30 14:49:34 +09:00
Kenji Okimoto d93a5c1a84 Fix Enumerator#each_with_index with block
In previous version,

```
a = [3, 2, 1]
e = a.each
e.sort_by(&:to_i) # => []
```

In this version,

```
a = [3, 2, 1]
e = a.each
e.sort_by(&:to_i) # => [1, 2, 3]
```
2017-03-30 10:53:55 +09:00
Yukihiro "Matz" Matsumoto 905f46a129 Merge pull request #3558 from ksss/domain
Should raise FloatDomainError
2017-03-29 12:50:42 +09:00
ksss db3573e0bf Should raise FloatDomainError 2017-03-29 11:59:19 +09:00
Yukihiro "Matz" Matsumoto 1f6bf0e14f Merge pull request #3563 from clayton-shopify/dup-renumber-keys
Renumber hash keys during dup since there may be duplicates.
2017-03-29 09:43:33 +09:00
Yukihiro "Matz" Matsumoto 506c05f01d Merge pull request #3564 from okkez/set-proper-class-to-subclass-of-array
Set proper class to subclass of Array
2017-03-29 09:40:44 +09:00
okkez 6dbe2272cf Set proper class to subclass of Array
More compatibility to CRuby.
2017-03-29 08:02:21 +09:00
Clayton Smith a6e25f73a0 Renumber hash keys during dup since there may be duplicates. 2017-03-28 16:31:19 -04:00
Yukihiro "Matz" Matsumoto 5ec051fc34 Avoid inline local variable declarations; fix #3554 2017-03-28 18:22:05 +09:00
Yukihiro "Matz" Matsumoto 1bdaf9c840 Merge pull request #3553 from okkez/add-array-slice-bang
Implement Array#slice!
2017-03-28 15:24:52 +09:00
Kenji Okimoto 33f77fe367 Implement Array#slice! 2017-03-28 15:07:57 +09:00
Yukihiro "Matz" Matsumoto 0f5289326f Merge pull request #3552 from ksss/time
Fix infinity loop ref #3546
2017-03-28 14:47:23 +09:00
ksss 397f1fc946 Fix infinity loop
And some cases should raise FloatDomainError
2017-03-28 10:58:18 +09:00
Yukihiro "Matz" Matsumoto 66980493ae Merge pull request #3544 from ksss/lineno
Fix lost lineno
2017-03-27 11:50:18 +09:00
Yukihiro "Matz" Matsumoto f688de5803 Merge pull request #3545 from keizo042/ignore_tags
Ignore file generated by ctags
2017-03-27 11:49:37 +09:00
Kouichi Nakanishi d0e42eff00 Ignore file generated by ctags 2017-03-26 12:51:48 +09:00
ksss b1c5c3b0a5 Fix lost lineno 2017-03-25 15:56:27 +09:00
Yukihiro "Matz" Matsumoto 051e40c049 Use MRB_PRId for NODE_NTH_REF; ref #3530 2017-03-23 01:52:52 +09:00
Yukihiro "Matz" Matsumoto 9eb0c11afd Cast to mrb_int to silence a warning; fix #3530 2017-03-23 01:20:45 +09:00
Yukihiro "Matz" Matsumoto 41f5c5b2c7 Merge pull request #3529 from kou/hash-ext-sub-class
Hash sub class creates new sub class objects instead of Hash
2017-03-23 01:14:46 +09:00
Yukihiro "Matz" Matsumoto 8ca9823196 Merge pull request #3536 from ksss/string-sub
Fix result if pattern is empty
2017-03-23 00:49:06 +09:00
ksss 63c0044b11 Fix result if pattern is empty 2017-03-22 22:19:34 +09:00
Kouhei Sutou e72e50b5d5 Hash sub class creates new sub class objects instead of Hash 2017-03-21 23:25:36 +09:00
Yukihiro "Matz" Matsumoto 3703aed7ab Use snprintf() to stringify fixnum numbers; ref #3492 2017-03-20 11:47:15 +09:00
Yukihiro "Matz" Matsumoto 339c6aed64 Add explicit cast from float to mrb_int. 2017-03-20 02:54:21 +09:00
Yukihiro "Matz" Matsumoto 631de65e0c Merge pull request #3527 from ksss/string-gsub
Update String#gsub and String#gsub!
2017-03-20 02:23:11 +09:00
Yukihiro "Matz" Matsumoto dcf6a413ca Use snprintf() to stringify fixnum numbers; fix #3492 2017-03-20 01:39:33 +09:00
Yukihiro "Matz" Matsumoto cea6a16cf4 Fixed some compiler errors regarding PRId. 2017-03-19 23:42:49 +09:00
ksss 7a74a617ea Callback should yield with pattern every time 2017-03-19 23:04:22 +09:00
ksss 67a6982710 Support to return Enumerator for String#gsub,gsub! 2017-03-19 22:45:14 +09:00
Yukihiro "Matz" Matsumoto 09574922a9 Should not check/call to_str for immediate objects; ref #3515 2017-03-19 20:59:30 +09:00
Yukihiro "Matz" Matsumoto 527dcd5247 super class error formats the superclass by inspect; rerf #3515 2017-03-19 20:58:34 +09:00
Yukihiro "Matz" Matsumoto ef105b5ca4 Use MRB_PRId instead of "%d"; fix #3515 2017-03-19 20:43:25 +09:00
Yukihiro "Matz" Matsumoto 4cf38eb903 Fixed OP_RESCUE code generation bug; fix #3519
916b8e let code executed with mrb->exc set, and may cause a crash
like #3519. Instead modified OP_RESCUE again. To retrieve the exception
object, we use `OP_RESCUE R(A), 0, 0` (old behavior). To compare the
exception object and the class, we use `OP_RESCUE R(A), R(B), 1`.

The reason we use OP_RESCUE for two instruction switched by operand
C is to save the instruction space.

As a result, the following code:
```ruby
begin
  raise "a"
rescue TypeError
  p 1
rescue RuntimeError
  p 2
end
```
will be compiled as:
```
irep 0x55cd1f565cb0 nregs=4 nlocals=1 pools=1 syms=4 reps=0
file: -
    2 000 OP_ONERR	005
    2 001 OP_LOADSELF	R1
    2 002 OP_STRING	R2	L(0)	; "a"
    2 003 OP_SEND	R1	:raise	1
    2 004 OP_JMP	023
    2 005 OP_RESCUE	R1
    3 006 OP_GETCONST	R2	:TypeError
    3 007 OP_RESCUE	R1	R2	cont
    3 008 OP_JMPIF	R2	010
    3 009 OP_JMP	014
    4 010 OP_LOADSELF	R1
    4 011 OP_LOADI	R2	1
    4 012 OP_SEND	R1	:p	1
    4 013 OP_JMP	024
    5 014 OP_GETCONST	R2	:RuntimeError
    5 015 OP_RESCUE	R1	R2	cont
    5 016 OP_JMPIF	R2	018
    5 017 OP_JMP	022
    6 018 OP_LOADSELF	R1
    6 019 OP_LOADI	R2	2
    6 020 OP_SEND	R1	:p	1
    6 021 OP_JMP	024
    6 022 OP_RAISE	R1
    6 023 OP_POPERR	1
    6 024 OP_STOP
```
2017-03-19 18:42:53 +09:00
Yukihiro "Matz" Matsumoto d01118d261 OP_RESCUE refactored; ref #3519 2017-03-19 18:40:58 +09:00
Yukihiro "Matz" Matsumoto 8d1468eab4 Remove cname duplication from exc_inspect(). 2017-03-19 08:05:19 +09:00
Yukihiro "Matz" Matsumoto e6b5c75ec5 Avoid possible infinite recursion in mrb_print_error(); ref #3517 2017-03-19 07:20:44 +09:00
Yukihiro "Matz" Matsumoto 2cbbeba0e0 Check call depth when mrb_yield_class() is called; ref #3521 2017-03-19 00:28:52 +09:00
Yukihiro "Matz" Matsumoto 75c374cad3 Update stack only when callinfo is popped; fix #3521 2017-03-19 00:28:52 +09:00
Yukihiro "Matz" Matsumoto 6db38c3768 Need not to call mrb_obj_as_string() is sep is nil. 2017-03-19 00:28:52 +09:00
Yukihiro "Matz" Matsumoto ce8697523f Merge pull request #3526 from ksss/sprintf
sprintf: Should use mrb_int for any object
2017-03-18 23:30:35 +09:00
ksss 2005bf997f Should use mrb_int for any object
o=Object.new
def o.to_int
  1
end
p "%*d" % [o, 1]
2017-03-18 22:06:01 +09:00
Yukihiro "Matz" Matsumoto fa502b498e Need to setup singleton_class chain; fix #3509 2017-03-18 18:06:37 +09:00
Yukihiro "Matz" Matsumoto 38a3b89d39 Small cosmetic change ("* " -> "*"). 2017-03-18 17:38:07 +09:00
Yukihiro "Matz" Matsumoto 6ea26aafd5 Save/restore GC arena index to avoid arena overflow error. 2017-03-18 17:37:24 +09:00
Yukihiro "Matz" Matsumoto 00427d45f5 Fixed access of uninitialized C local variable; fix #3525 2017-03-18 17:34:29 +09:00
Yukihiro "Matz" Matsumoto b2916f1b5c Avoid mrb_check_string_type() in raising exception; fix #3506
The change may reduce flexibility, but I believe no one wants
that level of flexibility here.
2017-03-18 02:34:56 +09:00
Yukihiro "Matz" Matsumoto 27fc76f6c6 Merge pull request #3524 from ksss/timestamp
MiniRake::Task#timestamp should use Time.now only
2017-03-17 16:00:50 +09:00
Yukihiro "Matz" Matsumoto fca17b41c7 Avoid trampoline when #eval is called from mrb_funcall(); fix #3522 2017-03-17 15:55:18 +09:00
ksss f99e100187 MiniRake::Task#timestamp should use Time.now only 2017-03-17 12:41:06 +09:00
Yukihiro "Matz" Matsumoto 9ecebebf3e Merge pull request #3510 from ksss/string-each_line
Some update for `String#each_line`
2017-03-16 22:18:15 +09:00
Yukihiro "Matz" Matsumoto 47cc5d66e3 Singleton classes do not have outer class set; fix #3505 2017-03-16 22:13:58 +09:00
Yukihiro "Matz" Matsumoto b64f08784c Protect stack region before calling mrb_convert_type(); fix #3504 2017-03-16 21:40:22 +09:00
ksss 4ee79a8777 Support to return enumerator when no block given 2017-03-15 16:58:29 +09:00
ksss 673ce237c4 Suuport custom separator 2017-03-15 16:58:28 +09:00
ksss 6eb02a892d Use duplicated object for block args 2017-03-15 16:58:28 +09:00
Yukihiro "Matz" Matsumoto f8b31a0db6 instance_eval method does not introduce C function boundary; fix #3508 2017-03-15 09:00:03 +09:00
Yukihiro "Matz" Matsumoto 4b1e5d47b3 Merge pull request #3503 from nobu/bug/sprintf-oob
Fix out-of-bound access
2017-03-14 09:07:06 +09:00
Nobuyoshi Nakada d8c4fe7bcb Fix out-of-bound access
Get rid of out-of-bound access when single % at the end.
2017-03-13 23:56:33 +09:00
Yukihiro "Matz" Matsumoto 191ee2596c Need to copy argv since it may be reallocated; fix #3500
The argv for `mrb_yield_with_class()` should not be on mruby stack.
Note the result from `mrb_get_args("*")` is on the stack.
2017-03-13 22:51:53 +09:00
Yukihiro "Matz" Matsumoto 877f43bca5 OP_BLKPUSH is invalid outside of methods; fix #3501 2017-03-13 22:03:31 +09:00
Yukihiro "Matz" Matsumoto 916b8ed5c8 Generate new OP_RESCUE; fix #3487
The old OP_RESCUE took one operand A, which specifies a class
to match with the exception. The new OP_RESCUE takes tree operands:

A: the register to hold exception
B: the matching exception; the match result will be stored here.
C: the continuation; if C is zero, the exception will be stored to R(A)
   otherwise, the value from R(A) is used as a exception.

Thus,
```ruby
begin
  raise "a"
rescue TypeError
  p 1
rescue RuntimeError
  p 2
end
```
will be compiled as
```
irep 0x557a06667aa0 nregs=4 nlocals=1 pools=1 syms=4 reps=0
file: /tmp/e.rb
2 000 OP_ONERR  005
2 001 OP_LOADSELF R1
2 002 OP_STRING R2  L(0)  ; "a"
2 003 OP_SEND R1  :raise  1
2 004 OP_JMP  022
3 005 OP_GETCONST R2  :TypeError
3 006 OP_RESCUE R1  R2
3 007 OP_JMPIF  R2  009
3 008 OP_JMP  013
4 009 OP_LOADSELF R1
4 010 OP_LOADI  R2  1
4 011 OP_SEND R1  :p  1
4 012 OP_JMP  023
5 013 OP_GETCONST R2 :RuntimeError
5 014 OP_RESCUE R1 R2  cont
5 015 OP_JMPIF  R2  017
5 016 OP_JMP  021
6 017 OP_LOADSELF R1
6 018 OP_LOADI  R2  2
6 019 OP_SEND R1  :p  1
6 020 OP_JMP  023
6 021 OP_RAISE  R1
6 022 OP_POPERR 1
6 023 OP_STOP
```

The new VM can accept old OP_RESCUE. The mruby compatible VM (namely
mruby/c) should be updated to support the new OP_RESCUE behavior.
2017-03-12 01:10:20 +09:00
Yukihiro "Matz" Matsumoto 92f5becabe Update VM to support new OP_RESCUE behavior; ref #3487 2017-03-12 00:58:00 +09:00
Yukihiro "Matz" Matsumoto 26169f9e25 Enhance OP_RESCUE to take B operand fas matching exception; ref #3487 2017-03-12 00:50:38 +09:00
Yukihiro "Matz" Matsumoto 000c68da97 OP_RETRUN to take B as matching exception; ref #3487 2017-03-11 16:32:29 +09:00
Yukihiro "Matz" Matsumoto 4ab70294ea Revert 642ab8e; ref #3422
Also fix #3499.  The issue was solved by #3462.
2017-03-11 16:03:04 +09:00
Yukihiro "Matz" Matsumoto 94395e81c1 The width printf specifier may be negative; fix #3498 2017-03-11 15:22:54 +09:00
Yukihiro "Matz" Matsumoto f30ec2dfb0 fixup! Check return value from snprintf(); ref #3498 2017-03-11 15:22:42 +09:00
Yukihiro "Matz" Matsumoto e3922318bd Check return value from snprintf(); ref #3498 2017-03-11 15:18:41 +09:00
Yukihiro "Matz" Matsumoto f9ed15d899 Merge pull request #3496 from ksss/string-gsub
Avoid infinity loop when empty string pattern
2017-03-11 10:22:34 +09:00
Yukihiro "Matz" Matsumoto 7590482d48 Merge branch 'master' into string-gsub 2017-03-11 10:22:17 +09:00
Yukihiro "Matz" Matsumoto 431f474ba3 Merge pull request #3497 from ksss/subreplace
\1 sequences as empty strings
2017-03-11 10:19:59 +09:00
ksss b56ad8d122 \1 sequences as empty strings 2017-03-10 22:22:06 +09:00
ksss 4b3e6cf169 Avoid infinity loop when empty string pattern 2017-03-10 13:26:15 +09:00
Yukihiro "Matz" Matsumoto ff262f2133 Update ci->mid according to surrounding scope; fix #3490 2017-03-10 12:37:19 +09:00
Yukihiro "Matz" Matsumoto 2f299cf4dc Simplify expression; ref #3490 2017-03-10 12:36:58 +09:00
Yukihiro "Matz" Matsumoto e8f09f9393 Raise special Exception when exception class is redefined; fix #3493 2017-03-10 11:43:25 +09:00
Yukihiro "Matz" Matsumoto c6e5659fec Use string#upto() if available; fix #3489
Terminate loop if the value is longer than the last otherwise.
2017-03-10 10:39:43 +09:00
Yukihiro "Matz" Matsumoto 4763312fb8 Terminate loop if generated string longer than the last; ref #3489 2017-03-10 10:38:28 +09:00
Yukihiro "Matz" Matsumoto 63dbed0094 __FILE__ should not update p->filename; fix #3485 2017-03-07 15:01:09 +09:00
Yukihiro "Matz" Matsumoto 513f4fbf14 Merge pull request #3484 from ksss/string-frozen
Check modifiable for String `bang' methods
2017-03-06 07:38:56 +09:00
Yukihiro "Matz" Matsumoto 8a15abdac2 Avoid trampoline code if mrb_f_send is called from funcall; fix #3383 2017-03-06 07:35:41 +09:00
ksss eba4b1fd76 Check modifiable for String `bang' methods 2017-03-05 23:04:22 +09:00
Yukihiro "Matz" Matsumoto d050694580 Merge pull request #3483 from ksss/string-index
String#index shouldn't return nil when "".index ""
2017-03-05 20:27:28 +09:00
ksss 76e10351fa String#index shouldn't return nil when "".index "" 2017-03-05 14:15:18 +09:00
Yukihiro "Matz" Matsumoto 4f43db862a Unshare popped TT_ENV objects. 2017-03-04 22:45:44 +09:00
Yukihiro "Matz" Matsumoto 3b40a2f6b5 Limit ecall() recursion levels; fix #3466 2017-03-04 18:56:20 +09:00
Yukihiro "Matz" Matsumoto ecee8c51b0 Avoid tracing shared TT_ENV object. 2017-03-04 18:53:36 +09:00
Yukihiro "Matz" Matsumoto c789acbc36 Save/restore arena index in the loop. 2017-03-04 18:52:51 +09:00
Yukihiro "Matz" Matsumoto ffdf7be723 Define jmpbuf_id outside of extern "C"; ref #3470 2017-03-02 20:42:06 +09:00
Yukihiro "Matz" Matsumoto 2d858cab3d Use C++ ABI only when MRB_ENABLE_CXX_ABI is set; ref #3470 2017-03-02 20:37:21 +09:00
Yukihiro "Matz" Matsumoto 1ab7e7e4dc Fixed a bug in register size calculation; fix #3479 2017-03-02 18:14:36 +09:00
Yukihiro "Matz" Matsumoto 3390020fd0 The method_missing removal condition in a76dc04a was wrong. 2017-03-02 17:59:27 +09:00
Yukihiro "Matz" Matsumoto 27ec2437fd Fix possible stack overflow for method_missing; fix #3478
Instead of shifting mruby VM stack, we always use CALL_MAXARGS.
2017-03-02 17:55:15 +09:00
Yukihiro "Matz" Matsumoto 0bcf9e28fc Reorganize C++ exceptions; ref #3470
There are 3 levels of C++ exception handling:
* default - no C++ exception (use setjmp/longjmp)
* enable_cxx_exception (use C++ exceptions with C ABI)
* enable_cxx_abi (use C++ ABI including exceptions)
2017-03-02 10:58:26 +09:00
Yukihiro "Matz" Matsumoto fdd92750fe Create NoMethodError instance using mrb_obj_new(). 2017-03-02 10:56:23 +09:00
Yukihiro "Matz" Matsumoto 9b176a1ca8 Avoid using <mruby/throw.h> in mruby.c 2017-03-02 10:51:44 +09:00
Yukihiro "Matz" Matsumoto eca35df4ff ci may be moved during mrb_convert_type(); ref #3474 2017-03-01 12:06:18 +09:00
Yukihiro "Matz" Matsumoto 8b089c09f7 Keep space for safe navigation operator; fix #3475 2017-03-01 10:37:43 +09:00
Yukihiro "Matz" Matsumoto cd0ac59dd3 Newlines in strings should be counted; fix #3477 2017-03-01 00:05:54 +09:00
Yukihiro "Matz" Matsumoto 1a1f834ade Compile C files by C compiler when C++ files mixed.
ref #3267 #3470

By this commit, mruby do not use C++ ABI mode unless
you specify explicitly. It compiles C files by C
compilers, with C++ exception enabled when it sees
C++ files in your configured mrbgems.

I haven't tried visualcpp, so please submit an issue
if you see any problem with C++ gems on Windows.
2017-02-28 23:27:13 +09:00
Tomoyuki Sahara f8a3af8086 Merge pull request #74 from iij/run-test-outside-source-tree
run mrbtest outside of source tree.
2017-02-28 12:34:15 +09:00
Tomoyuki Sahara 3ae5fea2b8 run mrbtest outside of source tree. 2017-02-28 12:10:51 +09:00
Yukihiro "Matz" Matsumoto dc56bbecc8 Ignore empty ensure clause. 2017-02-28 11:51:17 +09:00
Yukihiro "Matz" Matsumoto fb3243e096 return (and break) should handle splat correctly; fix #3472 2017-02-28 11:34:54 +09:00
Yukihiro "Matz" Matsumoto 22eb41ab20 Fix NODE_DREGX dump; ref #3471 2017-02-28 10:56:34 +09:00
Yukihiro "Matz" Matsumoto c52bbe1b4e Fixed a bug in dregex option generation; fix #3471 2017-02-28 10:43:22 +09:00
Yukihiro "Matz" Matsumoto 89eac4f59d Update codegen.c comments 2017-02-28 10:32:40 +09:00
Yukihiro "Matz" Matsumoto 7db0786abd Fix integer overflow; fix #3473
The fix is suggested by https://hackerone.com/lucnguyen
2017-02-28 09:54:56 +09:00
Yukihiro "Matz" Matsumoto 405f5a2d2a Add type check by mrb_get_args(); ref #3476 2017-02-28 09:30:06 +09:00
Yukihiro "Matz" Matsumoto 74dbee8e52 Add check before calling str_substr(); ref #3476 2017-02-28 09:21:24 +09:00
Yukihiro "Matz" Matsumoto bdac7dfae8 Check if the value is fixnum before mrb_funcall(); fix #3476
The issue is reported by https://hackerone.com/aerodudrizzt
2017-02-28 09:14:42 +09:00
Yukihiro "Matz" Matsumoto a76dc04aa8 Remove default Kernel#method_missing.
Internal method_missing works without problems.
2017-02-27 23:11:39 +09:00
Yukihiro "Matz" Matsumoto b563bcb7ff Check if OP_RETURN cross C function boundary; fix #3462 2017-02-27 20:13:01 +09:00
Yukihiro "Matz" Matsumoto 50bbdbb11b Fixed ecall() invoked too early; fix #3464 2017-02-27 18:40:35 +09:00
Yukihiro "Matz" Matsumoto 3fc9bf3d5f Update local variable only after the value is checked. 2017-02-27 18:39:42 +09:00
Yukihiro "Matz" Matsumoto d219e63a74 Clear block arg when method_missing takes *args. 2017-02-27 18:38:56 +09:00
Yukihiro "Matz" Matsumoto 9e93d5dbf0 Stack may be reallocated in mrb_run(); fix #3465 2017-02-27 16:17:57 +09:00
Yukihiro "Matz" Matsumoto 736be0e98b Always keep block argument space in stack; fix #3469 2017-02-27 13:05:26 +09:00
Yukihiro "Matz" Matsumoto 83a6c0e0a4 Merge pull request #3458 from dabroz/gitlab-ci
GitLab.com tests for multiple configurations
2017-02-27 08:59:33 +09:00
Yukihiro "Matz" Matsumoto fecbde328a Merge pull request #3461 from iij/build-with-byacc
Build with byacc
2017-02-24 18:39:20 +09:00
Tomoyuki Sahara da4f8e19fa replace "yylval" with "pylval" to make it compile with byacc. 2017-02-24 11:47:48 +09:00
Tomoyuki Sahara 74fe87c289 Add a travis-ci badge. 2017-02-17 10:33:11 +09:00
Yukihiro "Matz" Matsumoto a9f7b41219 Merge pull request #3460 from AltimitSystems/android.rake-ndk-clang
Additional options for Android build script.
2017-02-17 01:13:37 +09:00
Felix Jones fd08e0ea3a Added example build script for Android armeabi-v7a NEON hardware FPU 2017-02-16 15:07:18 +00:00
Felix Jones 324231a733 Android toolchain separated target architecture compile flags (ctarget) from shared compile flags (cflags). Added support for custom mfpu and float-abi switches for the armeabi-v7a target. 2017-02-16 15:02:10 +00:00
Yukihiro "Matz" Matsumoto 73e5a19c39 Configure callinfo target_class as CRuby; ref #3429 2017-02-16 23:43:02 +09:00
Yukihiro "Matz" Matsumoto 4dae285325 Merge pull request #3457 from dabroz/fix-clang-32-64
Build fix for 32-bit clang 3.8/3.9 with MRB_INT64
2017-02-16 23:21:58 +09:00
Yukihiro "Matz" Matsumoto 097da2399a Avoid executing OP_STOP in eval(); fix #3429 2017-02-16 22:40:31 +09:00
Yukihiro "Matz" Matsumoto 5e3c329c98 Adjust callinfo env and target_class; ref #3429 2017-02-16 22:38:47 +09:00
Felix Jones d83aad8d57 Merge branch 'master' into android.rake-ndk-clang 2017-02-16 13:33:46 +00:00
Tomasz Dabrowski bc721ec45d Gitlab tests for multiple configurations
Gitlab testing is introduced, using GitLab CI, to test many different configurations:
 - 32/64 bit architecture
 - float/double
 - 16/32/64 bit int size
 - none/NaN/word boxing
 - ASCII/UTF8

using various compilers:
 - gcc-4.7
 - gcc-4.8
 - gcc-4.9
 - gcc-5
 - gcc-6
 - clang-3.5
 - clang-3.6
 - clang-3.7
 - clang-3.8
 - clang-3.9
2017-02-16 13:50:27 +01:00
Tomasz Dabrowski bd2b76ea85 Build fix for 32-bit clang 3.8/3.9 with MRB_INT64 2017-02-16 13:39:21 +01:00
Yukihiro "Matz" Matsumoto b165708c8d Move #instance_exec to Kernel module
CRuby defines #instance_exec in BasicObject, but we don't.
It's a small incompatibility that isn't worth accomplish at
the price of implementation complexity.
2017-02-15 13:24:03 +09:00
Yukihiro "Matz" Matsumoto 517e9313bf Move #__id__ to BasicObject; ref #3417 2017-02-15 13:19:21 +09:00
Yukihiro "Matz" Matsumoto 612d636b77 Move #instance_eval to BasicObject; ref #3417 2017-02-15 13:15:58 +09:00
Yukihiro "Matz" Matsumoto 3dbda91788 Move #__send__ to BasicObject; ref #3417 2017-02-15 13:12:05 +09:00
Yukihiro "Matz" Matsumoto 8b4bd3158b Move #== and #!= to BasicObject; ref #3417 2017-02-15 13:07:53 +09:00
Yukihiro "Matz" Matsumoto 3f9450e7b0 Move BasicObject#method_missing to Kernel#method_missing; ref #3417
More compatibility to CRuby.
Updated tests that assume old mruby behavior.
2017-02-15 12:56:27 +09:00
Yukihiro "Matz" Matsumoto 1e5b5b14d7 Prohibit too deep mrb_funcall() recursion; ref #3421
`mrb_funcall()` recursion can cause stack overflow easily,
so recursion depth is now limited to MRB_FUNCALL_DEPTH_MAX,
which default value is 512.
2017-02-15 12:06:32 +09:00
Yukihiro "Matz" Matsumoto 1e57fefbcf Do not funcall() Exception#set_backtrace from runtime.
This change reduce flexibility but makes mruby simpler and faster.
2017-02-15 12:01:52 +09:00
Yukihiro "Matz" Matsumoto 8efa7b00df Preallocate SystemStackError; ref #3421 2017-02-15 11:59:47 +09:00
Yukihiro "Matz" Matsumoto 0376d4d4c6 Merge pull request #3455 from crimsonwoods/fix-android-build-script
Update android build script.
2017-02-15 10:30:27 +09:00
Yukihiro "Matz" Matsumoto dd24f9f5cc Avoid calling hook methods if they are not overridden. 2017-02-15 09:25:09 +09:00
Yukihiro "Matz" Matsumoto 04296925ac Use mrb_funcall_argv() instead of mrb_funcall() 2017-02-15 09:24:35 +09:00
crimsonwoods 5395dbfb3a Add new two build config files. 2017-02-15 09:01:55 +09:00
crimsonwoods a6b1e964a3 Modify default cflags. 2017-02-15 03:03:47 +09:00
crimsonwoods 838fa69aa3 Add '-Wl,--fix-cortex-a8' linker option for 'armeabi-v7a' architecture. 2017-02-15 00:51:10 +09:00
crimsonwoods 83a3da4456 Set default linker 'flags' and 'flags_before_libraries'. 2017-02-15 00:36:02 +09:00
Yukihiro "Matz" Matsumoto ba812d25ad Merge pull request #3453 from palkan/fix/test-gems-setup
Separate compilers setup from config setup
2017-02-14 09:09:34 +09:00
palkan 131566753d Separate compilers setup from config setup
Fixes #3418.
2017-02-13 20:59:07 +03:00
Yukihiro "Matz" Matsumoto 30aa521854 Do not use mrb_funcall() if Hash#default is not overridden; ref #3421
This change reduces the recursion level, but does not solve the stack
overflow issue entirely.
2017-02-14 00:22:12 +09:00
Yukihiro "Matz" Matsumoto 719f700adf Extend mruby stack when keep is bigger than room; fix #3421
But #3421 still cause stack overflow error due to infinite recursion.
To prevent overflow, we need to add different stack depth check.
2017-02-14 00:15:58 +09:00
Yukihiro "Matz" Matsumoto ecb6ac8b4a Fixed codegen error of redo in rescue; fix #3422
The issue (and the fix) was reported by https://hackerone.com/dgaletic
2017-02-13 19:31:06 +09:00
Yukihiro "Matz" Matsumoto c2ddcd4517 Should handle break from funcall(); fix #3434
This issue was reported by https://hackerone.com/d4nny
2017-02-13 18:45:20 +09:00
Yukihiro "Matz" Matsumoto f198530444 Fixed too much value_copy() when block is not given; fix #3440
The issue was reported by https://hackerone.com/titanous
2017-02-13 18:18:09 +09:00
Yukihiro "Matz" Matsumoto b23874777d Merge pull request #3452 from dabroz/fix-kernel-caller-aspec
Fixed aspec for Kernel#caller
2017-02-12 20:46:10 +09:00
Tomasz Dabrowski e4fa59f5ed Fixed aspec for Kernel#caller 2017-02-12 11:15:40 +01:00
Yukihiro "Matz" Matsumoto 60664823ba Merge pull request #3451 from dabroz/revert-string-mul
Revert "Optimization for String#* for 1-byte strings"
2017-02-11 22:49:20 +09:00
Yukihiro "Matz" Matsumoto 1f2d786e32 Avoid direct return from ecall(); fix #3441
There's incompatibility left for mruby.

When you return from `ensure` clause, mruby simply ignores the return
value.  CRuby returns from the method squashing the exception raised.

```
def f
  no_such_method() # NoMethodError
ensure
  return 22
end

p f() # CRuby prints `22`
```
2017-02-11 21:58:47 +09:00
Tomasz Dabrowski 90f262f642 Revert "Optimization for String#* for 1-byte strings"
This reverts commit d1bc7caeca.
2017-02-11 13:02:48 +01:00
Yukihiro "Matz" Matsumoto ff03a9a61c Avoid integer overflow in sprintf(); fix #3439
This issue was reported by https://hackerone.com/aerodudrizzt
2017-02-11 20:35:52 +09:00
Yukihiro "Matz" Matsumoto 642ab8ecda ecall() should preserve stack address referenced from ci[1].
OP_RETURN accesses ci[1]->stackent that might be broken; fix #3442
2017-02-11 18:13:39 +09:00
Yukihiro "Matz" Matsumoto 0b143898c4 Remove historical comment; ref #3450 #3448 2017-02-11 16:52:45 +09:00
Yukihiro "Matz" Matsumoto 0ef51d83c2 Merge pull request #3450 from r-obert/patch-1
remove skip that shouldn't be necessary anymore.
2017-02-11 16:50:06 +09:00
robert b130f43298 remove skip that shouldn't be necessary anymore.
the test should pass after https://github.com/mruby/mruby/commit/8f4a929e1a01c8d6176fb53a9ef5dff6de632959.
2017-02-11 07:40:55 +00:00
Yukihiro "Matz" Matsumoto 8f4a929e1a String#replace should update s->flags for MRB_STR_NO_UTF.
Otherwise String#size may return wrong length; fix #3448
2017-02-11 16:27:07 +09:00
Yukihiro "Matz" Matsumoto 6cb7aef563 Add type cast to pacify warning 2017-02-11 16:00:26 +09:00
Yukihiro "Matz" Matsumoto b36495bcb5 Merge pull request #3449 from dabroz/fix-ljust-ruby
String#ljust and String#rjust reimplemented with optimized Ruby
2017-02-11 10:26:09 +09:00
Tomasz Dabrowski d1bc7caeca Optimization for String#* for 1-byte strings 2017-02-10 15:31:33 +01:00
Tomasz Dabrowski ac9d04f4af String#ljust and String#rjust reimplemented with optimized Ruby 2017-02-10 15:31:33 +01:00
Tomasz Dabrowski 24048cd998 Tests for UTF-8 String#ljust and String#rjust 2017-02-10 15:16:49 +01:00
Yukihiro "Matz" Matsumoto c802cd07ba Merge pull request #3446 from ksss/minirake
Fix build error when trace mode
2017-02-10 21:22:00 +09:00
Yukihiro "Matz" Matsumoto 0dc26f52a0 Merge pull request #3447 from dabroz/fix-ljust
String#ljust and String#rjust reimplementation (fix #3445)
2017-02-10 21:20:26 +09:00
Tomasz Dabrowski 981105b3e6 String#ljust and String#rjust reimplementation (fix #3445)
- String#ljust and String#rjust are now C functions to improve performance
 - infinite loop because of an empty padding argument is now prevented (ArgumentError is raised)
 - extra tests for ljust/rjust added
2017-02-10 12:59:28 +01:00
ksss cd8284fe0b Fix build error when trace mode
Rakefile

```
file "a.txt" do
  system "echo hello > a.txt"
end

file "b.txt" => "a.txt" do
  system "cp a.txt b.txt"
end

task :default => "b.txt"
```

```
$ touch b.txt
$ ruby minirake --trace
Invoke default (already=[], needed=[true])
rake aborted!
No such file or directory @ rb_file_s_stat - a.txt
minirake:241:in `stat'
minirake:241:in `timestamp'
minirake:233:in `block in needed?'
minirake:233:in `collect'
minirake:233:in `needed?'
minirake:91:in `invoke'
minirake:95:in `block in invoke'
minirake:95:in `each'
minirake:95:in `invoke'
minirake:467:in `block in run'
minirake:466:in `each'
minirake:466:in `run'
minirake:484:in `<main>'
```
2017-02-10 13:15:49 +09:00
Tomoyuki Sahara 86d58a2d37 File class does not have to include Enumerable.
Because IO class, which is the superclass of File class, includes it.
2017-02-10 11:22:52 +09:00
Tomoyuki Sahara 88a7fedea4 support "x". 2017-02-09 11:07:55 +09:00
Yukihiro "Matz" Matsumoto d0ecf862d9 Fixed mixture of signed/unsigned integers
in mrbgems/mruby-bin-debugger.
2017-02-08 23:27:17 +09:00
Yukihiro "Matz" Matsumoto 4b32e651a5 Check if irep is NULL before print_backtrace()
According to the valgrind log attached to #3438, proc->body.irep
may be NULL in some cases.
2017-02-08 23:10:25 +09:00
Yukihiro "Matz" Matsumoto af4d74fc7d Add MRB_TT_PROC check to OP_SUPER as well; fix #3432 2017-02-08 21:13:22 +09:00
Tomoyuki Sahara 3dad125a1c TCPSocket.new supports "local_host" and "local_service". 2017-02-08 19:04:11 +09:00
Yukihiro "Matz" Matsumoto 76135e757f Check if m->env is NULL before dereferencing it; fix #3436 2017-02-08 19:01:09 +09:00
Tomoyuki Sahara caab1c203c define IO#hash to override Enumerable#hash. fixes #73.
Current implementation of Enumerable#hash calls #each to collect
hash values of enumerated objects (then calculates the hash value
of the Enumerable object).  But IO#each is a method to read lines.
It is not expected that IO#hash reads all lines from the IO object.
Or even worse, program waits for the IO object to be readable if
it is a socket or something cannot be read immediately.
2017-02-08 18:31:50 +09:00
Yukihiro "Matz" Matsumoto b277c58e78 Mark classes referenced from saved backtrace.
Maybe related to #3438
2017-02-08 16:31:37 +09:00
Yukihiro "Matz" Matsumoto f3d4ff16d3 Fixed a bug in ci address shifting; fix #3423
Dinko Galetic and Denis Kasak reported the issue and the fix.
(via https://hackerone.com/dgaletic).
2017-02-08 16:22:48 +09:00
Yukihiro "Matz" Matsumoto be550f04e4 codedump.c: OP_POPERR does not have register access. 2017-02-08 09:45:55 +09:00
Yukihiro "Matz" Matsumoto 7eebbce42f Merge pull request #3437 from eboda/master
Fix interpolation escaping in String.inspect
2017-02-08 08:58:41 +09:00
Edgar Boda-Majer 46e4e342f4 Fix interpolation escaping in String.inspect 2017-02-07 13:33:53 +01:00
Yukihiro "Matz" Matsumoto 794de3317a Merge pull request #3430 from ksss/local_variables
Kernel#local_variables: Make result array unique
2017-02-06 15:58:53 +09:00
ksss bd72dba8c0 Kernel#local_variables: Make result array unique 2017-02-06 11:16:47 +09:00
Yukihiro "Matz" Matsumoto f2b18a604c Check maximum number of formal arguments.
http://hkdnet.hatenablog.com/entry/2017/02/06/080000 (Japanese)
2017-02-06 09:14:49 +09:00
Yukihiro "Matz" Matsumoto 48e0bbbfee Make eval to use trampoline technique; fix #3415
Now `eval()` can call Fiber.yield etc.
2017-02-04 16:19:31 +09:00
Yukihiro "Matz" Matsumoto bf4e79cc62 argv may be modified when mrb_funcall() is called; fix #3419
Calling `mrb_funcall()` and `mrb_yield()` (and their related
functions) are discouraged unless absolutely necessary, because
it can cause this kind of issues very easily.
2017-02-04 14:10:39 +09:00
Yukihiro "Matz" Matsumoto 8f52b88ee7 No need to make env unshared in the finalization; fix #3425 2017-02-04 13:48:23 +09:00
Yukihiro "Matz" Matsumoto 8e0f231330 Mark mrb->backtrace.exc as GC root; fix #3388 2017-02-04 12:59:08 +09:00
Yukihiro "Matz" Matsumoto 6e0ba0085d Jump address should fit in 16 bits range; fix #3426 2017-02-04 12:37:08 +09:00
Yukihiro "Matz" Matsumoto a746ebe96f Merge pull request #3420 from udzura/patch-1
Fix usage of Class#name in mruby-bin-mruby's bintest
2017-02-03 09:30:22 +09:00
Yukihiro "Matz" Matsumoto e0323dff8c Merge pull request #3427 from clayton-shopify/fix-mrb-random-init
Fetch arguments earlier in mrb_random_init to avoid a crash.
2017-02-03 09:29:46 +09:00
Clayton Smith a8ccda5692 Fetch arguments earlier to avoid a crash. 2017-02-02 16:35:59 -05:00
Uchio KONDO ab5812d0d8 Use standard Module(Class)#to_s 2017-02-02 18:09:27 +09:00
Yukihiro "Matz" Matsumoto 6420951463 Update example lines of mrbgems in build_config.rb; ref #3414 2017-01-25 15:38:25 +09:00
Yukihiro "Matz" Matsumoto ac88f85a9e Copy mrb_float values from pool when MRB_WORD_BOXING; ref #3396 2017-01-25 11:09:15 +09:00
Yukihiro "Matz" Matsumoto 51d7a69ab0 Clear (o).w first for MRB_WORD_BOXING; ref #3396 2017-01-25 11:07:57 +09:00
Yukihiro "Matz" Matsumoto b3ce364537 Outer class may be same as the class; fix #3382 2017-01-24 17:54:05 +09:00
Yukihiro "Matz" Matsumoto 72bff2932b Use size_t to avoid integer overflow in mrb_ary_splice(); fix #3413 2017-01-24 11:36:27 +09:00
Yukihiro "Matz" Matsumoto 28cf7a549d Change return type of mrb_range_beg_len() from int to mrb_int.
ref #3411
2017-01-23 22:18:29 +09:00
Yukihiro "Matz" Matsumoto f0f095bc13 Fix a double free problem in codegen.c; fix #3378
This issue was first reported by https://hackerone.com/geeknik
The fix was proposed by @titanous
2017-01-23 16:53:31 +09:00
Yukihiro "Matz" Matsumoto 3ce82603a5 Fix memory leak; ref #3378
The fix was proposed by @titanous
2017-01-23 16:48:18 +09:00
Yukihiro "Matz" Matsumoto ffb5e5ab08 The ensure clause should keep its ci after its execution; fix #3406
This issue was reported by https://hackerone.com/ston3
2017-01-23 16:44:11 +09:00
Yukihiro "Matz" Matsumoto 324887d0d6 Backtrace list must be an array of strings; fix #3408 2017-01-23 16:23:48 +09:00
Yukihiro "Matz" Matsumoto 28b7b9ec64 Skip non string values in backtraces; ref #3408 2017-01-23 16:22:55 +09:00
Yukihiro "Matz" Matsumoto 40ec03c8c2 Merge pull request #3412 from ksss/mrb_ary_splice
Refactoring: Use array_copy instead of for loop
2017-01-23 15:24:56 +09:00
ksss 78a395d446 Refactoring: Use array_copy instead of for loop 2017-01-23 15:18:48 +09:00
Yukihiro "Matz" Matsumoto 4d38cad31b Add MRB_API to mrb_range_beg_len(); ref #3411 2017-01-23 15:05:12 +09:00
Yukihiro "Matz" Matsumoto 5e1d923381 Changed the behavior of mrb_range_beg_len(); close #3411
The new API is:

int mrb_range_beg_len(mrb, range, &beg, &len, len, trunc)

The new argument `trunc` is a boolean value that specifies
whether the function truncates the range. The new return value
is an integer instead of a boolean, that is:

 0: not a range
 1: range with proper edges
 2: out of range

To get the old behavior, you have to rewrite:

  mrb_range_beg_len(mrb, range, &beg, &len, len)

to:

  mrn_range_beg_len(mrb, range, &beg, &len, len, TRUE) == 1

[Breaking Change]
2017-01-23 14:35:26 +09:00
Yukihiro "Matz" Matsumoto 708088c5fa Should not make empty strings shared; fix #3407 2017-01-23 10:52:40 +09:00
Yukihiro "Matz" Matsumoto 49fd7590df Use mrb_write_barrier() instead of mrb_field_write_barrier_value()
ref #3409
2017-01-23 10:32:33 +09:00
Yukihiro "Matz" Matsumoto fdec607cd0 Remove unnecessary inline declaration; ref #3409 2017-01-23 10:30:14 +09:00
Yukihiro "Matz" Matsumoto 9d0f07e6a7 Merge pull request #3409 from ksss/mrb_ary_splice
Rewrite mrb_ary_splice
2017-01-23 10:28:09 +09:00
Yukihiro "Matz" Matsumoto 39ce9fe585 Merge pull request #3410 from ksss/mrb_ary_aset
Should raise RuntimeError when object frozen
2017-01-23 00:24:00 +09:00
ksss b49bd70f59 Should raise RuntimeError when object frozen 2017-01-22 18:53:20 +09:00
ksss 65c9baae7c Rewrite mrb_ary_splice
Referenced to CRuby's array.c(rb_ary_splice)

fix #3405
2017-01-22 14:06:23 +09:00
Yukihiro "Matz" Matsumoto bd50273bbc Merge pull request #3404 from clayton-shopify/fix-block-params
Fix incorrect parsing of block parameters.
2017-01-21 23:52:26 +09:00
Clayton Smith 797ff625f3 Fix incorrect parsing of block parameters. 2017-01-21 09:08:37 -05:00
Yukihiro "Matz" Matsumoto c48aef0b65 Stack position may be bigger than stack bottom; fix #3401
This issue was reported by https://hackerone.com/titanous
2017-01-21 18:01:12 +09:00
Yukihiro "Matz" Matsumoto 873b96bebc Merge pull request #3402 from clayton-shopify/fix-masgn-optimization
Remove problematic optimization from NODE_MASGN codegen
2017-01-21 11:15:14 +09:00
Clayton Smith 2c0f8f1a23 Remove problematic optimization. 2017-01-20 18:40:18 -05:00
Yukihiro "Matz" Matsumoto b23fb45f9c Integral#step without arg should loop forever as CRuby does. 2017-01-20 17:58:29 +09:00
Yukihiro "Matz" Matsumoto fe0e45505b Initialize callinfo->acc; ref #3243 2017-01-18 17:53:08 +09:00
Yukihiro "Matz" Matsumoto c8536d977d Merge pull request #3362 from ksss/proc
Proc shouldn't have `initialize` method
2017-01-18 00:09:26 +09:00
Yukihiro "Matz" Matsumoto c83069860a Dots is not needed for base 10 negative numbers; fix #3400 2017-01-16 17:21:55 +09:00
Yukihiro "Matz" Matsumoto c59ef59ad9 Merge pull request #3399 from ksss/caller
Implement Kernel.#caller
2017-01-16 17:11:47 +09:00
ksss 59d9f313df Skip when backtrace doesn't get 2017-01-14 22:01:20 +09:00
ksss 6f9cb7406a Implement Kernel.#caller 2017-01-14 22:01:20 +09:00
Yukihiro "Matz" Matsumoto 8d61f2120c Add proper given argument number in the wrong-number-argument error. 2017-01-12 23:14:35 +09:00
Yukihiro "Matz" Matsumoto a3571240e5 Add proper stack size calculation; fix #3398
This issue was reported by https://hackerone.com/ssarong
2017-01-12 23:08:58 +09:00
Yukihiro "Matz" Matsumoto 38acb9ec36 Kernel#initialize should not break existing mt; fix #3397
This issue was reported by https://hackerone.com/icanthack
The solution is suggested by @clayton-shopify.
2017-01-12 21:43:23 +09:00
Yukihiro "Matz" Matsumoto 41eff635bf Merge pull request #3393 from clayton-shopify/fix-exc-initialize
Fix broken MRB_INT64
2017-01-12 15:31:32 +09:00
Yukihiro "Matz" Matsumoto fb1dad82aa Merge pull request #3394 from clayton-shopify/really-fix-nme
Fix 36fc1f14 not checking in the right location
2017-01-12 15:29:02 +09:00
Yukihiro "Matz" Matsumoto a69d92e819 Merge pull request #3395 from hhc0null/fix-typo
Fix a typo in string.h.
2017-01-12 15:04:13 +09:00
hhc0null af4f6e8dc6 Fix a typo. 2017-01-12 00:02:17 +09:00
Bouke van der Bijl 6be5160eb6 Fix 36fc1f14 not checking in the right location 2017-01-11 09:10:12 -05:00
Clayton Smith bc4c90de07 Use mrb_int for argc. 2017-01-11 09:05:02 -05:00
Yukihiro "Matz" Matsumoto db1bd078be Use temporary variable to avoid potential crash; fix #3387
This issue was original reported by https://hackerone.com/icanthack
https://hackerone.com/titanous suggested the solution.
`regs` may be reallocated in the function call.
2017-01-11 17:59:56 +09:00
Yukihiro "Matz" Matsumoto e1ff71029f String#replace should check replacing string; fix #3374
This issue was reported by https://hackerone.com/tunz
2017-01-11 17:51:11 +09:00
Yukihiro "Matz" Matsumoto 06b2e6a76c Check if ci->target_class is NULL before dereferencing
close #3389
This issue was reported by https://hackerone.com/ston3
2017-01-11 11:30:52 +09:00
Yukihiro "Matz" Matsumoto 44edc51612 Raises Exception if raising exception class is redefined
close #3384
This issue was reported by https://hackerone.com/brakhane
2017-01-11 10:29:55 +09:00
Yukihiro "Matz" Matsumoto 7523cdf340 Exception#initialize to take arbitrary number of args; ref #3384 2017-01-11 10:29:55 +09:00
Yukihiro "Matz" Matsumoto c4491e477b Validate tm values before timegm(); close #3368
This issue was reported by https://hackerone.com/volc
2017-01-09 10:42:11 +09:00
Yukihiro "Matz" Matsumoto d3a8ebfadf Merge pull request #3381 from sorah/asn
Put package's libs flag after %{objs}
2017-01-09 10:25:34 +09:00
Sorah Fukumori ee7fc56dd0 Put package's libs flag after %{objs}
In case LDFLAG contains "-Wl,--as-needed" or "--as-needed" is enabled by
default, "-l" flags should appear after objs specifiction.
2017-01-09 10:08:06 +09:00
Yukihiro "Matz" Matsumoto 147c5c5441 Merge pull request #3380 from syucream/fix-assert
Pass when assert returns a false value
2017-01-07 19:37:55 +09:00
Ryo Okubo f085baae06 Pass when assert returns a false value 2017-01-07 17:57:14 +09:00
Yukihiro "Matz" Matsumoto 392d7fbef9 Add ary_modify() checks; close #3379
This issue was reported by https://hackerone.com/an0n-j
2017-01-07 12:26:29 +09:00
Yukihiro "Matz" Matsumoto 8c11b04d5c Merge pull request #3377 from ksss/respond_to
Check intern object returned by mrb_check_string_type
2017-01-06 18:56:39 +09:00
Yukihiro "Matz" Matsumoto 3c2f101aa4 Merge pull request #3376 from bovi/2017-copyright
Update Copyright to 2017
2017-01-06 18:52:22 +09:00
ksss ddcb30d84b Check intern object returned by mrb_check_string_type 2017-01-06 16:27:19 +09:00
Daniel Bovensiepen 2c77dfab04 Update Copyright to 2017
Signed-off-by: Daniel Bovensiepen <daniel@bovensiepen.net>
2017-01-06 14:27:57 +08:00
Yukihiro "Matz" Matsumoto 885d929398 Improve capacity enhancing conditions 2017-01-06 14:53:00 +09:00
Yukihiro "Matz" Matsumoto c6a1172592 Add pointer cast to pacify warnings. 2017-01-06 14:52:04 +09:00
Yukihiro "Matz" Matsumoto 9a76a0bd80 Move mrb_assert() position. 2017-01-06 14:51:21 +09:00
Yukihiro "Matz" Matsumoto 5d0b9459ff Merge pull request #3371 from takjn/removed_unnecessary_escape_charcter
Removed ununnecessary escape character '\' in libmruby.flags.mak
2017-01-06 14:35:10 +09:00
Yukihiro "Matz" Matsumoto f53f73f30c Should not deallocate shared string referring static; fix #3373 2017-01-06 14:25:01 +09:00
Jun Takeda fe0884f37f Removed ununnecessary escape character '\' for MRUBY_XXX in libmruby.flags.mak 2017-01-05 22:42:25 +09:00
Yukihiro "Matz" Matsumoto 36f5b44578 Add new method Kernel#frozen?; ref #3370 2017-01-05 17:49:21 +09:00
Yukihiro "Matz" Matsumoto a10f85f855 Merge pull request #3369 from ksss/fix-str-prepend
Rewrite String#prepend with Ruby
2017-01-05 17:40:38 +09:00
Yukihiro "Matz" Matsumoto 2e0c2b5807 Add mrb_hash_modify() to Hash#{delete,clear}; ref #3370
This issue was reported by https://hackerone.com/an0n-j
2017-01-05 16:46:08 +09:00
ksss eeca6ec8f5 Rewrite String#prepend with Ruby
Fix #3357
2017-01-04 14:00:28 +09:00
Yukihiro "Matz" Matsumoto bc1259de3b add explicit casts 2017-01-02 17:48:44 +09:00
Yukihiro "Matz" Matsumoto f388b6d612 use size_t instead of int 2017-01-02 17:48:44 +09:00
Yukihiro "Matz" Matsumoto 158a6ab2ed Merge pull request #3367 from ksss/str-modify
Fix segv on str_buf_cat
2017-01-02 17:48:27 +09:00
ksss 8a9a24152a Fix memory error on str_buf_cat
Modify from nofree to embed string
2017-01-02 17:32:44 +09:00
ksss 30b6648b9c Small refactoring: should use RSTR_CAPA 2017-01-02 16:33:58 +09:00
Yukihiro "Matz" Matsumoto 07167b8f5e Initialize potentially uninitialized variable tsec. 2017-01-01 00:47:45 +09:00
Yukihiro "Matz" Matsumoto 8b77979667 Initialize potentially uninitialized variable z 2017-01-01 00:45:14 +09:00
Yukihiro "Matz" Matsumoto 1ed4de58d0 str_buf_cat(): better size check added; ref #3342 2016-12-31 23:33:34 +09:00
Yukihiro "Matz" Matsumoto 342b1de65c str_buf_cat(): should allocate at least RSTRING_EMBED_LEN_MAX+1. 2016-12-31 23:31:45 +09:00
Yukihiro "Matz" Matsumoto cfdd1e3cc6 ary_expand_capa(): refine conditions to avoid infinite loop; ref #3353 2016-12-31 23:22:17 +09:00
Yukihiro "Matz" Matsumoto 9d84f0d47b ary_expand_capa(): size calculation by size_t; fix #3353
Also more size checks added.
2016-12-31 23:09:56 +09:00
Yukihiro "Matz" Matsumoto 270ea41b37 method_missing() may have CALL_MAXARGS-1 arguments; fix #3351
The issue was reported by https://hackerone.com/ston3
2016-12-30 22:09:32 +09:00
Yukihiro "Matz" Matsumoto 803bf010ca save/restore arena index around yield; ref #3359 2016-12-28 13:00:28 +09:00
Yukihiro "Matz" Matsumoto 6af8cc36b9 Merge pull request #3366 from ksss/splice
Check array max size
2016-12-28 13:00:14 +09:00
ksss caba1a19dc Check array max size
Fix #3354
2016-12-27 15:48:53 +09:00
Yukihiro "Matz" Matsumoto 30d5424adf Merge pull request #3365 from ksss/freeze
Fix segv when primitive value
2016-12-26 18:12:44 +09:00
Tomoyuki Sahara 69623078a8 Merge pull request #72 from masahino/add_pointer_casting
Add pointer casting
2016-12-26 09:12:19 +09:00
ksss 5c1c002ac2 Fix segv when primitive value
Fix #3352
2016-12-25 16:52:10 +09:00
Yukihiro "Matz" Matsumoto 000a3119ca Merge pull request #3364 from ksss/string2
Check overflow string length
2016-12-25 01:35:44 +09:00
Yukihiro "Matz" Matsumoto ede04d68b3 Merge pull request #3363 from ksss/string
Do nothing when empty string
2016-12-25 00:43:01 +09:00
masahino 1fac605e3f Add pointer casting 2016-12-24 23:32:44 +09:00
ksss c626b823ca Check overflow string length
Fix #3360
2016-12-23 23:31:21 +09:00
ksss 0de65a88d4 Do nothing when empty string
Fix #3361
2016-12-23 23:13:23 +09:00
ksss a68b568911 Should call initialize method if defined 2016-12-22 10:40:13 +09:00
Yukihiro "Matz" Matsumoto 5e3077c00d One less argument for raisef(); fix #3355
This issue was reported by https://hackerone.com/mg36
2016-12-21 16:46:26 +09:00
ksss 3cba13c249 Proc shouldn't have initialize method
Fix #3356
2016-12-21 15:17:05 +09:00
Yukihiro "Matz" Matsumoto 987daa64e3 Merge pull request #3358 from takjn/add-example-rx630
Added example for cross-compiling on Renesas RX630
2016-12-21 04:03:34 +09:00
Jun Takeda 76eb7147a4 Added example for cross-compiling for Renesas RX630 2016-12-21 00:51:18 +09:00
Tomoyuki Sahara 458b517c6f Merge pull request #71 from eagletmt/readlink
Add File.readlink
2016-12-19 09:03:13 +09:00
Yukihiro "Matz" Matsumoto 432570723d Check if width is zero or negative before fill; fix #3347
Reported by https://hackerone.com/haquaman.
2016-12-18 02:02:30 +09:00
Yukihiro "Matz" Matsumoto 2edf15bed8 Prohibit mixture of posarg and nextarg; ref #3347 2016-12-18 02:02:30 +09:00
Yukihiro "Matz" Matsumoto 9781f7f0ea Add "not reached" mark in mrb_ary_concat() 2016-12-18 02:02:30 +09:00
Yukihiro "Matz" Matsumoto c2bbfa5b61 NODE_NEGATE cdr may not be code-node; fix #3348 ref #3324
Reported by Denis Kasak https://hackerone.com/dkasak
2016-12-18 02:02:30 +09:00
Yukihiro "Matz" Matsumoto b0886d5692 Zero length heredoc still crashed; ref Shopify/mruby-internal#81 2016-12-18 02:02:30 +09:00
Kohei Suzuki b31b8022db Fix memory leak in error case 2016-12-17 16:48:02 +09:00
Kohei Suzuki d1c48192cb Add File.readlink 2016-12-17 15:03:52 +09:00
Yukihiro "Matz" Matsumoto 5289b4ba11 Merge pull request #3346 from clayton-shopify/fix-float-read
Fix crash when exponent is -2147483648
2016-12-17 12:18:35 +09:00
Tomoyuki Sahara 7e89736291 Merge pull request #70 from eagletmt/chmod
Add File.chmod
2016-12-16 22:54:20 +09:00
Kohei Suzuki 698378f076 Add File.chmod 2016-12-16 01:20:08 +09:00
Clayton Smith 868d2e528f Fix crash when exponent is -2147483648 2016-12-15 09:36:22 -05:00
Yukihiro "Matz" Matsumoto 73cc08772f remove debug code; ref #3344 2016-12-14 13:34:24 +09:00
Yukihiro "Matz" Matsumoto eb2a52ac98 Merge pull request #3345 from clayton-shopify/fix-range-beg-len
Check type before calling mrb_range_ptr.
2016-12-14 01:19:49 +09:00
Clayton Smith 73ad7395c0 Check type before calling mrb_range_ptr. 2016-12-13 10:04:15 -05:00
Yukihiro "Matz" Matsumoto fead715cef tLABEL should not come after conditional ternary; fix #3344 2016-12-13 23:44:10 +09:00
Yukihiro "Matz" Matsumoto df35076602 Restore callinfo offset in mrb_yield_with_class() 2016-12-13 17:17:47 +09:00
Yukihiro "Matz" Matsumoto d196e4dd04 void_expr_error(): n may be NULL.
Reported from @clayton-shopify.
2016-12-13 11:18:05 +09:00
Yukihiro "Matz" Matsumoto 3bedd22d55 Add assertion to make sure new capacity does not overflow. 2016-12-13 10:50:04 +09:00
Yukihiro "Matz" Matsumoto 3a7c369536 Make sure str->capa is under MRB_INT_MAX; fix #3342 2016-12-13 10:48:36 +09:00
Yukihiro "Matz" Matsumoto 647ad29a7a Fixed wrong condition in new_sym() that breaks symbol data. 2016-12-13 02:33:28 +09:00
Yukihiro "Matz" Matsumoto a4ae22ae0c Failed to realloc irep->syms in certain condition.
Also msym size changed to 512 from 256.
2016-12-13 01:55:08 +09:00
Yukihiro "Matz" Matsumoto 9cef265402 should not try to set classpath for frozen classes; ref #3340 2016-12-12 10:34:21 +09:00
Tomoyuki Sahara f2d4880098 Merge pull request #11 from masahino/add_casting
Add pointer casting
2016-12-12 06:51:03 +09:00
Yukihiro "Matz" Matsumoto 6ac5473494 Merge pull request #3341 from kou/support-pkg-config-in-mrbgem-rake
Support pkg-config in mrbgem.rake
2016-12-12 01:07:27 +09:00
Yukihiro "Matz" Matsumoto 1164463a7c freeze classes/modules; ref #3340 2016-12-12 01:05:07 +09:00
Yukihiro "Matz" Matsumoto 761562b65f freeze instance variables; ref #3340 2016-12-12 01:00:24 +09:00
Yukihiro "Matz" Matsumoto 92c843dd07 rename prefix RBASIC_ to MRB_; ref #3340 2016-12-12 00:54:36 +09:00
Yukihiro "Matz" Matsumoto 1fbad32f8b Merge pull request #3340 from k0kubun/object-freeze
Implement Object#freeze
2016-12-12 00:49:23 +09:00
Kouhei Sutou 237d26fd86 Support pkg-config in mrbgem.rake
Example usage:

    MRuby::Gem::Specification.new('mruby-onig-regexp') do |spec|
      # ...
      if spec.search_package('onigmo')
        # Use onigmo.h when onigmo.pc exist.
        spec.cc.defines += ["HAVE_ONIGMO_H"]
      elsif spec.search_package('oniguruma')
        # Use oniguruma.h when oniguruma.pc exist.
        spec.cc.defines += ["HAVE_ONIGURUMA_H"]
      else
        # Use bundled Onigmo otherwise.
        # ...
      end
    end
2016-12-11 21:35:56 +09:00
Takashi Kokubun 10bb7ad693 Implement Object#freeze 2016-12-11 03:44:15 +09:00
Yukihiro "Matz" Matsumoto 3cc913490b Merge pull request #3329 from bouk/reuse
Mark all the built-in classes during GC sweep
2016-12-10 16:02:47 +09:00
Yukihiro "Matz" Matsumoto d93422315c Merge branch 'bouk-negate' 2016-12-10 15:55:45 +09:00
Yukihiro "Matz" Matsumoto 13979a4376 Merge pull request #3324 from bouk/mruby/bouk-negate
Don't generate code for NODE_NEGATE if the result isn't used
Reported by https://hackerone.com/haquaman
2016-12-10 15:52:41 +09:00
Yukihiro "Matz" Matsumoto 0af170fbec gc.c: dead_slot is boolean; ref #3339 2016-12-10 15:34:32 +09:00
Yukihiro "Matz" Matsumoto 965690c94a Merge pull request #3339 from kazuho/kazuho/retain-page-with-tt-env
do not destroy a page with an active TT_ENV
2016-12-10 15:32:55 +09:00
Kazuho Oku 2ef634edb5 do not destroy a page with an active TT_ENV (e.g. an env referred from TT_FIBER) 2016-12-10 15:11:07 +09:00
Yukihiro "Matz" Matsumoto 7b968ca893 Clear parsing_heredoc at the end of file 2016-12-10 12:35:12 +09:00
Yukihiro "Matz" Matsumoto 8c26efd7ed Merge pull request #3338 from bouk/break-127
Fix segfault in gen_values with NOVAL and more than 127 args
2016-12-10 11:21:54 +09:00
Bouke van der Bijl 1264219832 Fix segfault in gen_values with NOVAL and more than 127 args 2016-12-09 10:30:05 -05:00
masahino 906b516cfa Add pointer casting 2016-12-09 21:57:06 +09:00
Yukihiro "Matz" Matsumoto c85feaec56 Merge pull request #3337 from bouk/undef-127
Fix segfault when undef is called with more than 126 arguments
2016-12-09 16:42:54 +09:00
Bouke van der Bijl c8da3c4df4 Fix segfault when undef is called with exactly 127 arguments
The issue is that when there are more than 126 arguments an array needs
to be created to pass the arguments on with.

Reported by https://hackerone.com/revskills
2016-12-08 15:47:17 -05:00
Yukihiro "Matz" Matsumoto db6b6ff442 Merge pull request #3336 from AltimitSystems/string.const.macro
Removed unnecessary const macro - const keyword is already a dependency
2016-12-09 02:57:03 +09:00
Felix Jones 2827655b9c Removed unnecessary const macro - const keyword is already a dependency 2016-12-08 12:38:00 +00:00
Yukihiro "Matz" Matsumoto b84e005fc3 Merge pull request #3335 from mattn/fix-vs2013
fix build on vs2013-vs2015
2016-12-08 16:48:08 +09:00
Yasuhiro Matsumoto c27dbfedf4 disable define const on VS 2016-12-08 15:56:50 +09:00
Yasuhiro Matsumoto eda6c1dc05 fix build on vs2013-vs2015 2016-12-08 15:38:19 +09:00
Yukihiro "Matz" Matsumoto bcd91856fd Merge pull request #3331 from dabroz/feature-load-exec
Promote load_exec to mruby API as mrb_load_exec (fixes #3248)
2016-12-08 15:22:07 +09:00
Yukihiro "Matz" Matsumoto 0d38ede33b Merge pull request #3333 from kazuho/kazuho/mrb_gc_unregister
fix issues of mrb_gc_unregister introduced in 09b1185
2016-12-08 12:50:39 +09:00
Kazuho Oku c2e749f878 fix issues of mrb_gc_unregister introduced in 09b1185
* fixes partial copy of objects in GC root array (due to missing `* sizeof(mrb_value)`)
* restores the behavior that permitted an unregistered object to be used as an argument
2016-12-08 10:27:07 +09:00
Tomasz Dąbrowski 0360a744b5 Promote load_exec to mruby API as mrb_load_exec (fixes #3248) 2016-12-07 21:21:21 +01:00
Bouke van der Bijl d56a19cbf5 Don't generate code for NODE_NEGATE if the result isn't used
Reported by https://hackerone.com/haquaman
2016-12-07 15:14:17 -05:00
Bouke van der Bijl f7a891fa89 Mark all the built-in classes during GC sweep
Reported by https://hackerone.com/haquaman
2016-12-07 15:14:12 -05:00
Yukihiro "Matz" Matsumoto 5930a6ebc7 Merge pull request #3328 from shugo/hash-dup-default_proc
Copy default_proc by Hash#dup.
2016-12-08 01:04:25 +09:00
Yukihiro "Matz" Matsumoto edf26d4043 Merge pull request #3327 from AltimitSystems/errno.macro
Removed the errno declaration from string.c
2016-12-08 01:02:27 +09:00
Felix Jones fe86cf4c91 Removed the errno declaration from string.c 2016-12-07 14:17:09 +00:00
Shugo Maeda 338e0ff52d Copy default_proc by Hash#dup. 2016-12-07 22:39:20 +09:00
Felix Jones 6187c21bd9 Wrapped string.c errno with ifndef macro for platforms that use inbuilt errno macro 2016-12-07 12:46:47 +00:00
Yukihiro "Matz" Matsumoto 2b0dd1f481 Merge pull request #3325 from kazuho/kazuho/detect-64bit
set `MRB_64BIT` if the sizeof(size_t) is 8
2016-12-07 20:15:36 +09:00
Kazuho Oku b491f4b06a set MRB_64BIT if the sizeof(size_t) is 8 2016-12-07 15:31:32 +09:00
Yukihiro "Matz" Matsumoto dffb4d82dc Add type check for cls before allocation 2016-12-06 11:40:49 +09:00
Yukihiro "Matz" Matsumoto 3623a833a4 Protect exceptions within main() function 2016-12-06 11:23:23 +09:00
Yukihiro "Matz" Matsumoto 9a962ed2c3 Raise an exception in time_update_datetime().
The function used to return NULL on error, but not checked in the
caller site.
2016-12-06 10:27:35 +09:00
Yukihiro "Matz" Matsumoto 6ec14a2173 Merge pull request #3318 from bouk/splat-stack
Fix stack move segfaulting in OP_ARYCAT
2016-12-05 16:51:46 +09:00
Yukihiro "Matz" Matsumoto 43512cc7bd Reorganize heredoc rules; fix #3273
The following codes used to be SyntaxError:

(1)
  a = <<-EOD;
  hello
  EOD

(2)
  <<-EOD.bla begin
  k
  EOD
  end
2016-12-05 02:55:39 +09:00
Yukihiro "Matz" Matsumoto ac561a52f5 Add symbol type check for Module#undef_method 2016-12-04 10:41:01 +09:00
Yukihiro "Matz" Matsumoto 5c651d6ce9 add MRB_API to mrb_float_read(); ref #3270 2016-12-03 18:55:52 +09:00
Yukihiro "Matz" Matsumoto a0fbc46ccd Import locale insensitive strtod() from Ruby1.8; fix #3270
The function was renamed to `mrb_float_read(const char*, char**)`.
2016-12-03 18:47:04 +09:00
Yukihiro "Matz" Matsumoto 802e396466 Merge branch 'bouk-method-missing-segfault' 2016-12-03 18:23:25 +09:00
Yukihiro "Matz" Matsumoto 144006a20e update NoMethodError tests; ref #3291 2016-12-03 18:23:04 +09:00
Yukihiro "Matz" Matsumoto 8f510be211 Merge branch 'method-missing-segfault' of https://github.com/bouk/mruby into bouk-method-missing-segfault 2016-12-03 18:20:29 +09:00
Yukihiro "Matz" Matsumoto f6d199919d Needed to apply block from safe-navigation operators; fix #3310 2016-12-03 16:38:43 +09:00
Yukihiro "Matz" Matsumoto 6b84ff4a44 Print NODE_SCALL (&.) from mrb_parser_dump() 2016-12-03 16:21:15 +09:00
Yukihiro "Matz" Matsumoto c029c6c444 codegen: avoid unnecessary OP_MOVE after CASE 2016-12-03 14:50:36 +09:00
Yukihiro "Matz" Matsumoto 23c4ad0865 Merge pull request #3319 from bouk/apost-splatt
Fix segfault when using result of rest assignment
2016-12-03 12:53:21 +09:00
Yukihiro "Matz" Matsumoto 79a621dd73 Check before retrieving struct RRange pointer; fix #3320
range->edges may be NULL for example when #initialize_copy removed.
2016-12-03 12:30:01 +09:00
Yukihiro "Matz" Matsumoto 9776150263 Merge pull request #3317 from bouk/missing-to-s
Use mrb_ptr instead of mrb_cptr in Kernel#to_s
2016-12-03 12:01:43 +09:00
Yukihiro "Matz" Matsumoto d89cfca02c Merge pull request #3315 from ksss/enumerator-with_index
Fix some incompatibility for Enumerator#with_index
2016-12-03 11:58:39 +09:00
Yukihiro "Matz" Matsumoto e673fbb35a Merge pull request #3321 from clayton-shopify/fix-proc-crash-upstream
Fix segfault in mrb_proc_copy.
2016-12-03 11:54:22 +09:00
Yukihiro "Matz" Matsumoto d7589b10ed Merge pull request #3316 from clayton-shopify/fix-array-size-3
Fix more integer overflows.
2016-12-03 11:52:52 +09:00
Clayton Smith 1ff4b3f800 Fix segfault in mrb_proc_copy. 2016-12-02 09:36:26 -05:00
Bouke van der Bijl fe362c1f26 Fix segfault when using result of rest assignment
Reported by https://hackerone.com/haquaman
2016-12-01 15:49:36 -05:00
Bouke van der Bijl 9c61e1cd87 Use mrb_ptr instead of mrb_cptr in Kernel#to_s
This is to avoid segfault when WORD_BOXING is enabled

Reported by https://hackerone.com/brakhane
2016-12-01 15:23:56 -05:00
Bouke van der Bijl 7d07466b43 Fix stack move segfaulting in OP_ARYCAT
Reported by https://hackerone.com/haquaman

Testcase (couldn't get it to work as a test):

def nil.b
  b *nil
end
nil.b
2016-12-01 15:23:31 -05:00
Clayton Smith 2bc3a5fb78 Fix more integer overflows. 2016-12-01 09:08:38 -05:00
Yukihiro "Matz" Matsumoto 2cca9d3688 avoid comparison between signed and unsigned integer; ref #3312 2016-12-01 18:49:39 +09:00
Yukihiro "Matz" Matsumoto f1cf6ef817 Merge pull request #3312 from nobu/feature/multi-unicode-escape
Feature/multi unicode escape
2016-12-01 18:42:40 +09:00
Yukihiro "Matz" Matsumoto 4d807fc619 Merge pull request #3313 from yhara/add-test
Add test for recently fixed bugs
2016-12-01 18:41:23 +09:00
Yukihiro "Matz" Matsumoto ab4ab7c8a0 Fix compile error by #3309 2016-12-01 18:37:03 +09:00
Nobuyoshi Nakada 0f08914ac0 Support multiple elements \u syntax 2016-12-01 16:48:43 +09:00
Nobuyoshi Nakada fed40b44b8 Extract read_escape_unicode from read_escape 2016-12-01 16:48:43 +09:00
Nobuyoshi Nakada bd9bc7786f Fix assertion argument orders 2016-12-01 16:48:43 +09:00
Nobuyoshi Nakada e4086d4014 Fix compile error by #3309 2016-12-01 16:46:59 +09:00
ksss 2718fed124 Support svalue 2016-12-01 16:13:24 +09:00
ksss 0f774ff4df Support nil argument as no argument 2016-12-01 15:33:27 +09:00
Yutaka HARA 3f83ec64a8 Add test for recently fixed bugs 2016-12-01 14:55:26 +09:00
Yukihiro "Matz" Matsumoto 61ac564c99 Merge pull request #3309 from clayton-shopify/fix-array-size-2
Prevent array size calculation overflows.
2016-12-01 11:46:57 +09:00
Yukihiro "Matz" Matsumoto c37c255f19 Merge pull request #3311 from ksss/enum-generator
Support Enumerable methods
2016-12-01 11:46:10 +09:00
ksss 31f0ffeac8 Support Enumerable methods 2016-12-01 10:42:57 +09:00
Clayton Smith acdddb4f14 Prevent array size calculation overflows. 2016-11-30 13:55:09 -05:00
Yukihiro "Matz" Matsumoto 8461a31cb4 Fixed too much void_expr_error(); fix #3307 2016-11-30 13:04:50 +09:00
Yukihiro "Matz" Matsumoto 0e9c9acc11 Merge branch 'ksss-enumerator-lazy' 2016-11-30 12:54:29 +09:00
Yukihiro "Matz" Matsumoto 779c2629fe resolve conflict; ref #3306 2016-11-30 12:54:20 +09:00
Yukihiro "Matz" Matsumoto 3cf66a8218 Merge pull request #3305 from ksss/lazy-to_enum
Implement Enumerable::Lazy#to_enum and enum_for
2016-11-30 12:48:28 +09:00
ksss 0f90227907 Change Lazy class outer
Lazy class should be under Enumerator instead of Enumerable
2016-11-30 12:36:22 +09:00
ksss 8675975ba2 Implement Enumerable::Lazy#to_enum and enum_for 2016-11-30 11:02:02 +09:00
Yukihiro "Matz" Matsumoto 2bb47addad Prohibit instantiation of immediate objects 2016-11-30 10:36:17 +09:00
Yukihiro "Matz" Matsumoto f7c0024b8e Merge pull request #3278 from bouk/dup-class
Copy over INSTANCE_TT when duping class
2016-11-30 03:52:56 +09:00
Yukihiro "Matz" Matsumoto 5771c9778e add a test for #3296 2016-11-30 03:51:23 +09:00
Yukihiro "Matz" Matsumoto 37743111d9 should not refer Struct class by name; fix #3296 2016-11-30 03:49:56 +09:00
Yukihiro "Matz" Matsumoto 630733f346 check ttype before object allocation; fix #3294 2016-11-30 03:38:55 +09:00
Yukihiro "Matz" Matsumoto 27d166d4e2 Merge pull request #3304 from clayton-shopify/fix-array-size
Use size_t to calculate bytes needed for array.
2016-11-30 03:00:43 +09:00
Yukihiro "Matz" Matsumoto 66f64d4ee8 Merge pull request #3303 from bouk/empty-nil
Interpret argument in 'f ()' as nil instead of nothing
2016-11-30 02:52:39 +09:00
Clayton Smith b633aa9ad4 Use size_t to calculate bytes needed for array. 2016-11-29 10:26:02 -05:00
Bouke van der Bijl 523c267020 Interpret argument in 'f ()' as nil instead of nothing 2016-11-29 09:23:53 -05:00
Yukihiro "Matz" Matsumoto 246a9a8acd ary_concat: support self concatenation; fix #3302 2016-11-29 22:36:11 +09:00
Yukihiro "Matz" Matsumoto 9fc62d28d0 pre-allocate arena overflow error 2016-11-28 09:52:57 +09:00
Yukihiro "Matz" Matsumoto 27ceb84818 parse.y: use opt_paren_args to simplify yield rule 2016-11-27 22:43:46 +09:00
Yukihiro "Matz" Matsumoto 36fc1f1431 Added Exception check in mrb_exc_set(); close #3292
PR #3293 just checks for NoMethodError.
2016-11-27 22:17:51 +09:00
Yukihiro "Matz" Matsumoto 5ea1bb0eea Merge pull request #3301 from dabroz/feature-64-bit-word
Safeguard against using MRB_INT64 with MRB_WORD_BOXING in 32-bit mode
2016-11-27 21:00:34 +09:00
Yukihiro "Matz" Matsumoto f9f19f34dd replace _cstr by _lit for litral C strings; ref #3300 2016-11-27 20:53:25 +09:00
Tomasz Dabrowski 3fdfd8cb4a Safeguard against using MRB_INT64 with MRB_WORD_BOXING in 32-bit mode 2016-11-27 12:49:36 +01:00
Yukihiro "Matz" Matsumoto 3d9aa463f7 Add NULL checks for Time data retrieval 2016-11-27 20:47:20 +09:00
Yukihiro "Matz" Matsumoto c70e206330 Merge pull request #3300 from herwinw/doc
Added documentation on function for globals
2016-11-27 20:46:58 +09:00
Herwin Weststrate afee618c1b Added documentation on function for globals 2016-11-27 09:50:30 +01:00
Tomoyuki Sahara 0eafb089c9 Merge pull request #69 from eagletmt/explicit-cast
Add explicit cast from void* to struct mrb_io*
2016-11-27 13:53:50 +09:00
Yukihiro "Matz" Matsumoto 72915cab52 Merge pull request #3299 from dabroz/feature-16-bit-nan
Fixed NaN boxing when MRB_INT16 is set
2016-11-27 09:27:03 +09:00
Tomasz Dąbrowski 626648dc41 Fixed NaN boxing when MRB_INT16 is set 2016-11-26 13:05:02 +01:00
Kohei Suzuki 905203ef5e Add explicit cast from void* to struct mrb_io*
For compatibility with C++.
2016-11-26 14:18:28 +09:00
Yukihiro "Matz" Matsumoto 277e81a7c9 removed failing test for Time#initialize; ref #3295 2016-11-26 12:02:46 +09:00
Yukihiro "Matz" Matsumoto 4256130ecd Merge pull request #3293 from ksss/enum-first
Fix incompatibility for Enumerable#first
2016-11-26 09:59:50 +09:00
Yukihiro "Matz" Matsumoto f666350694 Merge pull request #3295 from bouk/time-seg
Fix null pointer dereference in mrb_time_initialize
2016-11-26 09:57:48 +09:00
Yukihiro "Matz" Matsumoto 0ee58a0fff Merge pull request #3298 from dabroz/patch-1
Fix typo in istruct.h
2016-11-26 09:50:37 +09:00
Tomasz Dąbrowski be5223371b Fix typo in istruct.h 2016-11-25 23:15:37 +01:00
Bouke van der Bijl b7f9a58757 Fix null pointer dereference in mrb_time_initialize
Reported by https://hackerone.com/raydot
2016-11-25 11:15:57 -05:00
ksss 1bf565ea04 Argument more strictly 2016-11-25 22:25:48 +09:00
ksss c28a963bf4 Like a Enumerable#take 2016-11-25 22:20:33 +09:00
Yukihiro "Matz" Matsumoto 743c1e7be1 stop warnings in the test; ref #3280 2016-11-25 09:44:22 +09:00
Yukihiro "Matz" Matsumoto 1329529f3b Merge branch 'bouk-nested-empty-heredoc' 2016-11-25 09:33:40 +09:00
Yukihiro "Matz" Matsumoto 55842c5a34 resolve conflict; ref #3279 2016-11-25 09:33:20 +09:00
Yukihiro "Matz" Matsumoto d3ff9d31f0 Merge branch 'bouk-struct-array-members' 2016-11-25 09:32:01 +09:00
Yukihiro "Matz" Matsumoto 79e3980a7f resolve conflict; ref #3281 2016-11-25 09:31:51 +09:00
Yukihiro "Matz" Matsumoto 7f05ba86f2 Merge branch 'bouk-127-segfaults' 2016-11-25 09:27:32 +09:00
Yukihiro "Matz" Matsumoto 30f12ba4bc resolve conflict; ref #3283 2016-11-25 09:27:24 +09:00
Yukihiro "Matz" Matsumoto 9f7701e27a Merge branch 'bouk-retry-codegen-misalign' 2016-11-25 09:26:01 +09:00
Yukihiro "Matz" Matsumoto cc2786c84e resolve conflict; ref #3285 2016-11-25 09:25:51 +09:00
Yukihiro "Matz" Matsumoto 0d48a9786f Merge branch 'bouk-empty-ternary' 2016-11-25 09:24:09 +09:00
Yukihiro "Matz" Matsumoto 0b4017fd69 resolve conflict; ref #3286 2016-11-25 09:23:47 +09:00
Yukihiro "Matz" Matsumoto d77b254108 Merge pull request #3287 from bouk/proc-arity
Fix calling .arity on Proc with undefined `initialize`
2016-11-25 09:20:47 +09:00
Yukihiro "Matz" Matsumoto 6905597f5b Merge pull request #3284 from bouk/remove-method-segfault
Fix segfault on remove_method with invalid argument
2016-11-25 09:19:22 +09:00
Yukihiro "Matz" Matsumoto a28fa35ea9 Merge pull request #3282 from bouk/fix-break-instance-class
Fix segfault when defining class inside instance_exec on primitive
2016-11-25 09:17:59 +09:00
Yukihiro "Matz" Matsumoto 1e892c0ffa Merge pull request #3280 from bouk/struct-redefine
Remove constant when a struct is redefined.
2016-11-25 09:15:57 +09:00
Yukihiro "Matz" Matsumoto b4d501750c Merge pull request #3288 from bouk/chomp-bang-len
Get String length after args in String#chomp!
2016-11-25 08:01:41 +09:00
Yukihiro "Matz" Matsumoto 54921aa671 Merge pull request #3289 from bouk/setbyte-len
Read length after args in String#setbyte
2016-11-25 08:01:06 +09:00
Yukihiro "Matz" Matsumoto 99f6de529e Merge pull request #3290 from bouk/unsafe-peep
Fix unsafe peephole optimization
2016-11-25 08:00:33 +09:00
Francois Chagnon a384bcce35 Fix instances where return value of mrb_method_search_vm is unchecked
Reported by @charliesome
2016-11-24 10:51:29 -05:00
Francis Bogsanyi 964427f82c Fix unsafe peephole optimization
Reported by https://hackerone.com/dkasak
2016-11-24 10:32:34 -05:00
Craig Lehmann 83005d83d8 Read length after args in String#setbyte
Prevents RCE
Reported by https://hackerone.com/raydot
2016-11-24 10:31:29 -05:00
Clayton Smith 76a1bdfa29 Get String length after args in String#chomp!
Fixes RCE issue
Reported by @bouk
2016-11-24 10:28:21 -05:00
Francois Chagnon 1ec5994377 Fix calling .arity on Proc with undefined initialize
Reported by @bouk
2016-11-24 10:23:31 -05:00
Bouke van der Bijl 71641bbf73 Fix segfault caused by empty condition in ternary
Reported by https://hackerone.com/jpenalbae
2016-11-24 10:20:42 -05:00
Bouke van der Bijl 1253982577 Fix codegen issue causing misaligned register
Reported by https://hackerone.com/haquaman
2016-11-24 10:18:48 -05:00
Bouke van der Bijl 22f5504054 Fix segfault on remove_method with invalid argument
Reported by https://hackerone.com/jpenalbae
2016-11-24 10:13:47 -05:00
Bouke van der Bijl 75b31d7438 Fix segfault on method call with exactly 127 arguments
Reported by https://hackerone.com/dkasak
2016-11-24 10:09:37 -05:00
Bouke van der Bijl 4523aaec01 Fix segfault when defining class inside instance_exec on primitive 2016-11-24 10:06:15 -05:00
Clayton Smith b60d6c42aa Don't allow array parameter in Struct.new 2016-11-24 10:05:05 -05:00
Clayton Smith 82731d9ee0 Remove constant when a struct is redefined. 2016-11-24 10:04:09 -05:00
Bouke van der Bijl 73e4f069be Fix nested empty heredoc causing segfault
As reported by https://hackerone.com/jpenalbae
2016-11-24 09:54:18 -05:00
Bouke van der Bijl 73bb30c2f4 Copy over INSTANCE_TT when duping class 2016-11-24 09:52:30 -05:00
Yukihiro "Matz" Matsumoto a630c4f413 use MRB_PRId instead of %d for mrb_int 2016-11-24 22:10:54 +09:00
Yukihiro "Matz" Matsumoto 8602789067 Merge pull request #3277 from dabroz/feature-float-tolerance
Fixed float tolerance in tests when MRB_USE_FLOAT is set
2016-11-24 21:48:14 +09:00
Yukihiro "Matz" Matsumoto e289ba3eff Merge pull request #3276 from dabroz/author
Update AUTHORS
2016-11-24 21:28:55 +09:00
Yukihiro "Matz" Matsumoto 22f73250db redo should work well in for statement; fix #3275 2016-11-24 21:25:27 +09:00
Tomasz Dąbrowski 72ed7eebc3 Fixed Range.size to use proper floating point tolerance 2016-11-24 12:50:49 +01:00
Tomasz Dąbrowski a8b8abbd82 Fixed float tolerance in tests when MRB_USE_FLOAT is set 2016-11-24 12:48:41 +01:00
Tomasz Dąbrowski 3943ab5368 Update AUTHORS 2016-11-24 12:34:36 +01:00
Yukihiro "Matz" Matsumoto 0c924b9287 fixed a bug in self modifying Array#[]=; fix #3274 2016-11-24 19:30:21 +09:00
Yukihiro "Matz" Matsumoto cb5c9d3415 always call Hash#default if no key found; fix #3272 2016-11-24 18:09:04 +09:00
Yukihiro "Matz" Matsumoto 23c73ff399 Time#initialize_copy: Check if source time is initialized.
To prevent crash from nasty code like:

  class Time
    def initialize
    end
  end

  a = Time.new
  b = Time.new
  a.initialize_copy b
2016-11-24 13:50:36 +09:00
Yukihiro "Matz" Matsumoto cef7bd5416 Merge pull request #3271 from ksss/enum-take
Fix Enumeable#take some incompatibility
2016-11-24 11:31:28 +09:00
Yukihiro "Matz" Matsumoto 227daa8811 Relax 'void value expression' check that was too strict 2016-11-24 11:22:54 +09:00
ksss 5134734541 Shouldn't call each method if size is 0 2016-11-24 10:35:15 +09:00
ksss 9e2faec8e4 Support object does'n have < method 2016-11-24 10:34:14 +09:00
Yukihiro "Matz" Matsumoto 1c9593954b Add "void value expression" check to the parser. 2016-11-24 10:32:28 +09:00
Yukihiro "Matz" Matsumoto dc4be19aab Add forgotten loop_pop() in NODE_OP_ASGN codegen 2016-11-24 10:01:03 +09:00
Yukihiro "Matz" Matsumoto f5a86ca530 Add pointer casting from mrb_malloc(); ref #3267 2016-11-24 09:28:00 +09:00
Yukihiro "Matz" Matsumoto 798c69d1be Avoid casting from int to unsigned char for C++; ref #3267 2016-11-24 09:28:00 +09:00
Tomasz Dąbrowski d7a6070d22 Fixed language standard mode for GCC (cannot use gnu99 with C++, c++03 used instead) 2016-11-24 09:28:00 +09:00
Tomasz Dąbrowski c2a60eb8af Fix for Windows-specific mruby C++ issues 2016-11-24 09:28:00 +09:00
Tomasz Dąbrowski 44c3859a97 Fix for compiling mruby as C++ on Visual Studio toolchain 2016-11-24 09:28:00 +09:00
Tomasz Dąbrowski 18757c8f7b Different method of compiling C as C++ (-x c++) 2016-11-24 09:28:00 +09:00
Tomasz Dąbrowski 00e6121260 Safeguard against trying to use C++ exception handling in C code 2016-11-24 09:28:00 +09:00
Tomasz Dąbrowski 401ad4586f Add constant export declaration for MRBC output compiled as C++
Otherwise, C++ compilers will skip this constant when producing object files.
2016-11-24 09:28:00 +09:00
Tomasz Dąbrowski 1af9e363f2 Fixes for compiling mruby as C++ 2016-11-24 09:28:00 +09:00
Yukihiro "Matz" Matsumoto 477e12c182 Merge pull request #3269 from bouk/fix-printf-segfault
Fix segfault when Fixnum#chr doesn't return a string
2016-11-24 09:16:43 +09:00
Yukihiro "Matz" Matsumoto 2c28d00356 Merge pull request #3268 from bouk/fix-random-segfault
Fix segfault in Array#sample
2016-11-24 09:13:34 +09:00
Bouke van der Bijl 9bf1c0e1dc Fix segfault when Fixnum#chr doesn't return a string 2016-11-23 15:18:52 -05:00
Bouke van der Bijl c7262be0ae Fix segfault in Array#sample 2016-11-23 11:21:14 -05:00
Yukihiro "Matz" Matsumoto 669bbc70b0 codegen_scope should not keep old iseq ptr from irep 2016-11-23 21:08:35 +09:00
Yukihiro "Matz" Matsumoto bfbc6b9ea4 local_variables() should not touch unshared env 2016-11-23 20:50:14 +09:00
Yukihiro "Matz" Matsumoto efebbbbf26 Implement Float shift methods in C 2016-11-23 09:45:50 +09:00
Yukihiro "Matz" Matsumoto f414ed03d6 Merge pull request #3265 from dabroz/feature-fixexternc
Fixed C declaration in re.h
2016-11-22 22:22:47 +09:00
Tomasz Dąbrowski 52b40cb4d0 Fixed extern "C" to use MRB_BEGIN/END_DECL in re.h 2016-11-22 13:34:40 +01:00
Yukihiro "Matz" Matsumoto 8cba708854 int64_value(): use FIXABLE() 2016-11-22 19:11:54 +09:00
Yukihiro "Matz" Matsumoto fb7776586e hash value may be overflown from Integer
mruby special.
2016-11-22 18:00:04 +09:00
Yukihiro "Matz" Matsumoto be73905c9c accept floats as bit operator operands; fix #3260 2016-11-22 17:59:41 +09:00
Yukihiro "Matz" Matsumoto 8112295031 Removed fix_shift_get_width()
Fixnum is usually big enough for shift width.
2016-11-22 17:45:07 +09:00
Yukihiro "Matz" Matsumoto 740bf09740 add bit operators ~,&,|,^ to Float class (mruby special) 2016-11-22 17:36:26 +09:00
Yukihiro "Matz" Matsumoto a70104798e remove unnecessary ".!"; ref #3261 2016-11-22 16:55:18 +09:00
Yukihiro "Matz" Matsumoto bbaf3c242d Merge pull request #3261 from ksss/range-first
Reimplements Range#first
2016-11-22 16:38:24 +09:00
Yukihiro "Matz" Matsumoto 03e399accf Merge pull request #3262 from dabroz/feature-nanbox64fix
Fixed NaN boxing for 64-bit configrations
2016-11-22 16:36:43 +09:00
Yukihiro "Matz" Matsumoto de415b7bc0 Merge pull request #3264 from naclyhara/patch-1
Fix typo in test
2016-11-22 16:34:45 +09:00
Yutaka HARA aaa86a1fd5 Fix typo in test 2016-11-22 16:25:18 +09:00
Tomasz Dąbrowski b21b02465e asserts checking validity of pointer and TT added for mrb_obj_value
Useful for testing when using boxing on different platforms.
2016-11-21 12:37:45 +01:00
Tomasz Dąbrowski c385782cfe mrb_assert definition moved to the beggining of mruby.h
So that other files can immediately use it.
2016-11-21 12:37:45 +01:00
Tomasz Dąbrowski 8cdaf1ed35 Fixed NaN boxing for 64-bit configrations on platforms that use full 48-bit usermode pointers
Definition of boxed pointer is following:
`111111111111TTTT TTPPPPPPPPPPPPPP PPPPPPPPPPPPPPPP PPPPPPPPPPPPPPPP`

Previously, only the last 32-bit were set, and remaining 14 bits were zeroed when setting `ttt`.
2016-11-21 12:37:45 +01:00
Tomasz Dąbrowski d86f5d2dca mruby architecture detection 2016-11-21 12:37:45 +01:00
ksss 682237be6e Reimplements Range#first
Range#first shouldn't call `Range#to_a` on infinity range.
2016-11-21 16:55:49 +09:00
Yukihiro "Matz" Matsumoto a3f8206ce6 Merge pull request #3259 from dabroz/feature-16bitfix1
Fix for sprintf test exceeding bounds with MRB_INT16
2016-11-21 10:22:47 +09:00
Tomasz Dąbrowski 4289e0cd81 Fix for sprintf test exceeding bounds with MRB_INT16 2016-11-21 00:37:03 +01:00
Yukihiro "Matz" Matsumoto 3ce51cbc7c Merge pull request #3257 from ksss/range-size
Fix Range#size results
2016-11-21 01:15:37 +09:00
ksss 22390aa1c8 Use mrb_float instead of double 2016-11-19 23:25:08 +09:00
ksss a2fbd80a47 Fix Range#size results 2016-11-19 23:25:07 +09:00
Yukihiro "Matz" Matsumoto 0ff3ae1fba Range#include?: simplify condition; ref #3255 2016-11-18 11:54:24 +09:00
Yukihiro "Matz" Matsumoto b03b1e37d9 Merge pull request #3255 from ksss/range-include
Fix condition of Range#include?
2016-11-18 11:48:49 +09:00
ksss 4ef591c897 Fix condition of Range#include? 2016-11-18 10:01:03 +09:00
Yukihiro "Matz" Matsumoto 2a38bf9116 Merge pull request #3254 from herwinw/doc
Doc
2016-11-18 00:02:58 +09:00
Herwin Weststrate 18d6994f78 Documented most methods in mruby/hash.h 2016-11-17 11:52:28 +01:00
Herwin Weststrate d20c56c7fa Documented most methods in mruby/array.h 2016-11-17 11:41:49 +01:00
Herwin Weststrate c043dc631e Typo fix: poped => popped 2016-11-17 11:05:27 +01:00
Yukihiro "Matz" Matsumoto 57900d809f String#include? does not take integers 2016-11-17 18:02:10 +09:00
Yukihiro "Matz" Matsumoto 92be276d76 String#{strip,lstrip,rstrip} may cause OOB access 2016-11-17 18:00:21 +09:00
Yukihiro "Matz" Matsumoto 2e8ed9514f Removed mruby-inline-struct gem from default.gembox; ref #3251
bundled testing gems do not need to be included in default.gembox.
all gems under mrbgems are linked automatically in the test process.
2016-11-17 17:19:49 +09:00
Yukihiro "Matz" Matsumoto 8438792d27 renamed "inline" to "istruct" to represent inline struct; ref #3251 2016-11-17 17:19:49 +09:00
Tomasz Dąbrowski 4cca8bac6b inline structures data type for mruby (MRB_TT_INLINE) (fix #3237)
Inline structures have no instance variables, no finalizer, and offer as much space as possible in RBASIC object. This means 24 bytes on 64-bit platforms and 12 bytes on 32-bit platforms.
mruby-inline-struct gem is only provided for testing.
2016-11-17 17:19:49 +09:00
Yukihiro "Matz" Matsumoto 784e07f902 Merge pull request #3252 from BanzaiMan/patch-1
Remove webhook notification for Travis CI
2016-11-17 16:46:26 +09:00
Yukihiro "Matz" Matsumoto c8b028027f Merge pull request #3253 from ksss/range
Ranges should not rewrite
2016-11-17 16:44:58 +09:00
ksss 176d93d72a Ranges should not rewrite 2016-11-17 14:57:30 +09:00
Hiro Asari 1ba61f055c Remove webhook notification for Travis CI
As travis-rubies now uses 3 Mac jobs to create archives for various OS
releases.

This is a bit wasteful if multiple builds pass in a short period.

Instead, Travis CI is now running a nightly build of mruby-head
(around 22:30 UTC). This will happen regardless of the state of the
master branch.
2016-11-16 19:41:40 -05:00
Yukihiro "Matz" Matsumoto 5208ee534f Merge pull request #3250 from dabroz/feature-correct-aspec
Correct argument specifications for few methods
2016-11-17 00:41:54 +09:00
Tomasz Dąbrowski 8e0dc6fa8d Correct argument specifications for few methods:
- Struct#values_at
 - Module#define_method
 - String#chop
 - String#chop!
2016-11-16 15:46:28 +01:00
Yukihiro "Matz" Matsumoto 1685eff2a5 Fixed off-by-one error in String#[]= with Ranges 2016-11-16 10:16:14 +09:00
Yukihiro "Matz" Matsumoto 1f554ff854 Fixed rindex calling into mrb_equal bug
Fixed by Alex Snaps and reported by Mathieu Leduc-Hamel,
both from shopify.com.  Thank you!
2016-11-16 02:10:44 +09:00
Yukihiro "Matz" Matsumoto 242b219471 Fixed memory disclosure in String#lines
Reported from from Alex Snaps via Mathieu Leduc-Hamel,
both from shopify.com.  Thank you!
2016-11-16 02:05:19 +09:00
Yukihiro "Matz" Matsumoto 92f72c7490 make String#[]= to take Ranges as position argument 2016-11-16 02:04:56 +09:00
Yukihiro "Matz" Matsumoto 739dad6e87 Fixed a memory problem in Array#to_h
Reported from Alex Snaps via Mathieu Leduc-Hamel,
both from shopify.com.  Thank you!
2016-11-16 01:29:04 +09:00
Yukihiro "Matz" Matsumoto 4f6cce059b class/module statement should re-open; fix #3225 2016-11-15 04:15:24 +09:00
Yukihiro "Matz" Matsumoto 1422e57630 move mrb_str_dup() to mrb_class_path; ref #2470
Class#to_s used to return same string repeatedly,
that mean you can modify "class name" by modifying
the return value from Class#to_s.
2016-11-13 16:17:44 +09:00
Yukihiro "Matz" Matsumoto 01dddaf385 rename mruby-module-ext to mruby-class-ext; ref #2470 2016-11-13 16:17:44 +09:00
take_cheeze 451985d44b Implement Module#name.
Solves #2132.
2016-11-13 16:17:36 +09:00
Yukihiro "Matz" Matsumoto 88604e39ac Hash#[] to call Hash#default 2016-11-12 05:23:05 +09:00
Yukihiro "Matz" Matsumoto feb9b3debd Merge pull request #3224 from ksss/define_method
Module#define_method supports proc argument
2016-11-11 22:57:52 +09:00
Yukihiro "Matz" Matsumoto 752ca514f6 do not dump_node if parser failed 2016-11-11 22:51:48 +09:00
Yukihiro "Matz" Matsumoto 185dad3a6e node_dump() to print NODE_HEREDOC terminator 2016-11-11 22:50:41 +09:00
Yukihiro "Matz" Matsumoto 45aadd7e60 HEREDOC could fail with NUL terminated lines; fix#3244 2016-11-11 22:49:23 +09:00
Yukihiro "Matz" Matsumoto e86ead436a Merge pull request #3246 from ksss/cycle
Reimplement Enumerable#cycle
2016-11-11 20:43:22 +09:00
ksss 7685783af4 Add regression test for Enumerable#cycle 2016-11-11 16:53:42 +09:00
ksss 126d55480d Reimplement Enumerable#cycle
Fix pattern of infinite loop
And support all specs in https://github.com/ruby/spec/blob/27960d06e0ce92c37f074450f0eab4b0519b118c/core/enumerable/cycle_spec.rb without Enumerable#size
2016-11-11 16:53:42 +09:00
Yukihiro "Matz" Matsumoto 3d946a8044 Merge pull request #3240 from dabroz/feature-fixtest
test/assert.rb should not use puts
2016-11-11 13:36:53 +09:00
Yukihiro "Matz" Matsumoto 570cbbdf3d Merge pull request #3234 from AltimitSystems/mrb.class_under_defined
Add mrb_class_defined_under
2016-11-11 08:24:52 +09:00
Felix Jones 70aa6dc38d Merge branch 'master' into android.rake-ndk-clang 2016-11-10 20:01:59 +00:00
Felix Jones 178816626d Merge branch 'mrb.class_under_defined' 2016-11-10 19:52:27 +00:00
Felix Jones e3c8092ccd Renamed class_under_defined to class_defined_under 2016-11-10 19:51:56 +00:00
Yukihiro "Matz" Matsumoto 3f002b6993 fixed a bug when number of LHS and RHS differs; fix #3239 2016-11-11 04:37:42 +09:00
Tomasz Dąbrowski 617050450e test/assert.rb should not use puts 2016-11-10 13:17:59 +01:00
Yukihiro "Matz" Matsumoto 872517dff3 class variables in higher order have a priority; fix #3235 2016-11-08 23:51:15 +09:00
Yukihiro "Matz" Matsumoto 1142cf2037 fixed a bug with [] in RHS of multiple assignments; fix #3236 2016-11-08 22:18:41 +09:00
Yukihiro "Matz" Matsumoto 6c299aae67 fixed wrong stack adjustment for ensure clauses; fix #3175 2016-11-07 00:44:08 +09:00
Felix Jones cc5f40b2db mrb_class_under_defined docs renamed parent and child to outer and inner 2016-11-06 13:19:14 +00:00
Felix Jones 8d6aa06548 Added mrb_class_under_defined 2016-11-06 13:01:21 +00:00
Yukihiro "Matz" Matsumoto 0b8d8dd379 associate REnv to the executing block; fix #3214 2016-11-05 02:52:34 +09:00
Yukihiro "Matz" Matsumoto 46995c3264 add quoted symbol tests; ref #3231 2016-11-04 14:21:46 +09:00
Yukihiro "Matz" Matsumoto 2960c69435 Merge pull request #3232 from lukaselmer/patch-1
Update documentation of fetch
2016-11-03 13:39:24 +09:00
Lukas Elmer f02694ecc7 Update documentation of fetch
The sentence `Negative values of +index+ count from the end of the array.` can be interpreted that it only holds if a block is given. Clarify it.
2016-11-02 19:45:43 +01:00
Yukihiro "Matz" Matsumoto cc3f1b7f5c allow single quoted labels in hashes; ref #3231 2016-11-02 16:14:20 +09:00
Yukihiro "Matz" Matsumoto 13d0832965 allow quoted labels in hashes; fix #3231 2016-11-02 08:41:43 +09:00
Yukihiro "Matz" Matsumoto 9a126278b6 should not unshare() reclaimed env objects; fix #3230 2016-10-28 09:21:14 +09:00
Yukihiro "Matz" Matsumoto c45ed46f28 macro mrb_bool() may evaluate arg multiple times; ref #3228 2016-10-24 01:30:31 +09:00
Yukihiro "Matz" Matsumoto 7061658b5b Merge pull request #3228 from ksss/respond_to_missing
Kernel#respond_to? should return true|false only
2016-10-24 01:27:13 +09:00
ksss 022e147b78 Kernel#respond_to? should return true|false only 2016-10-23 18:25:47 +09:00
Yukihiro "Matz" Matsumoto 6fd0e601cf Move to_proc conversion from OP_ENTER to OP_SENDB; fix #3227 2016-10-20 23:49:40 +09:00
Tomoyuki Sahara b5e2dc9097 raise an exception when we cannot close "fd" but can close "fd2". 2016-10-13 16:57:38 +09:00
ksss efe4f30b39 Module#define_method supports proc argument 2016-10-12 22:19:54 +09:00
Yukihiro "Matz" Matsumoto 8488425e50 Merge pull request #3223 from AltimitSystems/android.rake-ndk-clang
Android Task GCC support re-added
2016-10-08 23:34:48 +09:00
Felix Jones c3f271a861 Merge branch 'master' of github.com:mruby/mruby 2016-10-08 15:12:45 +01:00
Felix Jones b83bcd12df Removed GCC TODO 2016-10-08 15:10:46 +01:00
Felix Jones 3e9fe81591 Android GCC support re-added 2016-10-08 15:09:08 +01:00
Yukihiro "Matz" Matsumoto 364761f473 Merge pull request #3222 from AltimitSystems/android.rake-ndk-clang
Android mips/mips64 support
2016-10-08 10:33:54 +09:00
Felix Jones 5d2795c00d Fixed mips and mips64: GCC Toolchain now points to GCC. 2016-10-08 00:23:55 +01:00
Felix Jones 5fd068eb4d Android task: NDK default search paths now favour ndk-bundle. Added macOS NDK search paths. 2016-10-07 22:31:24 +01:00
Tomoyuki Sahara f6a82772e6 eof? should raise an IOError if it is not opened for reading. 2016-09-30 17:10:55 +09:00
Tomoyuki Sahara 2229a2aa0f reimplement #eof. fixes #66. 2016-09-30 16:27:11 +09:00
Yukihiro "Matz" Matsumoto 2d335daeeb Merge pull request #3218 from nobu/trailing-space
Removed trailing spaces
2016-09-28 15:51:02 +09:00
Nobuyoshi Nakada 6511bfd79a Removed trailing spaces 2016-09-28 12:29:41 +09:00
Yukihiro "Matz" Matsumoto 9d3167cabe Merge pull request #3217 from ksss/break
Fix unexpected behavior with break
2016-09-27 10:31:48 +09:00
Yukihiro "Matz" Matsumoto afbe211c60 mrb_str_strlen() should be MRB_API; ref #3216 2016-09-27 10:29:56 +09:00
Yukihiro "Matz" Matsumoto 6bc4b47c46 Merge pull request #3216 from kou/remove-needless-mrbapi
Remove needless MRB_API
2016-09-27 10:28:04 +09:00
ksss b1fa180ea3 Fix unexpected behavior with break
```
def yie
  yield
end

def bre
  yie {
    1+1
    break
  }
end

p bre #=> display 2, but should be nil
```
2016-09-26 12:17:46 +09:00
Kouhei Sutou 91bd3ebd32 Remove needless MRB_API
ref #3215

If a function (such as mrb_read_irep_file()) is declared without MRB_API
in header file (such as include/mruby/dump.h), implementation of the
function in source file (such as src/load.c) should also defined without
MRB_API.

If MRB_API is mismatch, Visual C++ reports link error with C2375 error
code: https://msdn.microsoft.com/en-us/library/5k6kw95a.aspx
2016-09-25 21:47:49 +09:00
Yukihiro "Matz" Matsumoto 7a382e8bdf Remove unnecessary MRB_API from read_irep related functions; ref #3215 2016-09-24 05:26:51 +09:00
Yukihiro "Matz" Matsumoto 77d004e835 Merge pull request #3213 from unak/print-visualc
Visual C++ support of UTF-8 hack on mruby-print
2016-09-22 00:41:04 +09:00
U.Nakamura 36c08476d9 Use non-underscore'ed names
Accept @mattn's comment.
2016-09-21 14:39:08 +09:00
U.Nakamura 37d2d57d63 Use underbar'ed name to get rid of warnings 2016-09-21 12:59:36 +09:00
U.Nakamura e5fedaf67f Not only for MINGW but also for Visual C++ 2016-09-21 12:58:58 +09:00
Kazuaki Tanaka cb29c9b415 Fix return value type of bytecode_decoder 2016-09-20 23:15:49 +00:00
Kazuaki Tanaka 968ebac001 Bytecode decoder support, MRB_BYTECODE_DECODE_OPTION 2016-09-20 23:07:28 +00:00
Yukihiro "Matz" Matsumoto c698c67e10 Merge pull request #3211 from eregon/fix_limitation_typos
Fix a couple typos in limitations.md
2016-09-18 08:58:51 +09:00
Benoit Daloze 5f37d8bd89 Fix a couple typos in limitations.md 2016-09-17 23:14:55 +02:00
Yukihiro "Matz" Matsumoto 6498970d81 Merge pull request #3210 from AltimitSystems/android.rake-ndk-clang
Fixed regex order falling early in arch cases, causing x86_64 and arm…
2016-09-16 08:33:01 +09:00
Felix Jones 04ae2960f4 Fixed regex order falling early in arch cases, causing x86_64 and arm-v7a to use wrong target. 2016-09-15 18:14:27 +01:00
Yukihiro "Matz" Matsumoto 07e905ef02 Merge pull request #3209 from AltimitSystems/master
Re-written android.rake task for latest Android NDK clang. Currently …
2016-09-16 00:33:50 +09:00
Felix Jones 18662ff576 Re-written android.rake task for latest Android NDK clang. Currently loses support for GCC and mips, mips64. Addresses issue #3208 2016-09-15 15:57:44 +01:00
Tomoyuki Sahara 51cf6b6048 Merge pull request #65 from ksss/join
Support Array argument
2016-09-13 09:57:05 +09:00
ksss ff845be72c Support Array argument 2016-09-11 22:01:45 +09:00
ksss 7c9d941003 Show value of expect and actual each assertion 2016-09-11 17:00:19 +09:00
Yukihiro "Matz" Matsumoto 08a1dd2ac8 Merge pull request #3207 from ksss/splat
Fix SEGV when splat object
2016-09-08 21:13:12 +09:00
ksss d467022347 Add testing for regression 2016-09-08 16:35:41 +09:00
ksss d265c03da0 Fix SEGV when splat object
Splat operation should return an array.
And raise an error if result of convert by to_a is not array or nil.
2016-09-08 16:35:17 +09:00
Yukihiro "Matz" Matsumoto cd5133c570 Merge pull request #3205 from yurie/abort-header
surpress warning when MRB_DISABLE_STDIO
2016-09-06 23:14:25 +09:00
Yukihiro "Matz" Matsumoto 028dcfe881 Merge pull request #3206 from ksss/env
Fix SEGV when unshared env
2016-09-06 23:13:58 +09:00
yuri c9d4d96872 surpress warning when MRB_DISABLE_STDIO 2016-09-06 22:41:50 +09:00
ksss e66b35c6ee Fix SEGV when unshared env 2016-09-06 17:11:18 +09:00
Yukihiro "Matz" Matsumoto 9040086e92 Merge pull request #3204 from ksss/mid
Should clear method name
2016-09-05 22:36:19 +09:00
ksss a5c2e95b10 Should clear method name
- Fix method name in top-level
- Fix SEGV when call Exception#backtrace if callinfo over CALLINFO_INIT_SIZE(32)
2016-09-05 21:58:08 +09:00
Yukihiro "Matz" Matsumoto d58c2585d4 Merge pull request #3202 from pbosetti/master
In mrbgem_spec.rake, added support for @mrblib_dir @objs_dir, so that a gem can have custom source directory names
2016-09-05 13:06:40 +09:00
Yukihiro "Matz" Matsumoto 495545ab09 Merge pull request #3203 from nozomiS/mrbc_filename-fix
Fix mrbc_filename leak
2016-09-05 13:02:32 +09:00
Nozomi SATO 068b46d5e2 - fix mrbc_filename leak; cxt->filename would not be freed until the state is closed. 2016-09-04 18:35:23 +09:00
Paolo Bosetti ac9b6f2a11 In mrbgem_spec.rake, added support for @mrblib_dir @objs_dir, so that a gem can have custom source directory names 2016-09-02 17:38:40 +02:00
Yukihiro "Matz" Matsumoto bf0893586a Merge pull request #3192 from ksss/instance_eval
instance_eval env should remake Fix #3191
2016-08-31 23:15:42 +09:00
Yukihiro "Matz" Matsumoto b3236b2a71 mruby-random: fixed typos 2016-08-30 10:52:44 +09:00
Yukihiro "Matz" Matsumoto fa76bbeb07 mruby-random: add reporting URL since we modified the source 2016-08-30 09:03:14 +09:00
Yukihiro "Matz" Matsumoto 22dc84f72a Fixed spell errors in test/t/lang.rb; ref #3199 2016-08-20 21:57:20 +09:00
Yukihiro "Matz" Matsumoto c313fdfed0 Merge pull request #3199 from miura1729/original
Add new test for optimize VM
2016-08-20 21:35:17 +09:00
Miura Hideki 1751d8fd3b Add new test for optimize VM 2016-08-20 20:30:37 +09:00
Yukihiro "Matz" Matsumoto ff3e4b91f2 Move Module#include and #prepend to class.c; ref #3197
To avoid VM nesting with mrb_funcall()
2016-08-20 00:03:30 +09:00
Yukihiro "Matz" Matsumoto b2fceae461 renamed class.rb and error.rb to ensure they are read first; ref #3197 2016-08-19 14:10:23 +09:00
Yukihiro "Matz" Matsumoto 67ad1ff11e Merge pull request #3198 from nobu/feature/lparen_arg-stmt
parse.y: lparen_arg statement
2016-08-19 12:52:40 +09:00
Nobuyoshi Nakada 73dd82e30a parse.y: lparen_arg statement
allow parenthesised statement as a method argument.
reported [Feature:12686] in bugs.ruby-lang.org fixed in CRuby 2.4.
2016-08-19 11:11:54 +09:00
Yukihiro "Matz" Matsumoto 0597f66b23 Merge pull request #3196 from mimaki/fix-negative-ord
Fix String#ord failure which return a negative value
2016-08-17 17:00:01 +09:00
Hiroshi Mimaki 861b0eed7b Fix String#ord failure which return a negative value 2016-08-17 15:29:59 +09:00
Yukihiro "Matz" Matsumoto ee40f9bbbd Merge pull request #3195 from franckverrot/master
Correct method name
2016-08-16 13:44:23 +09:00
Franck Verrot f6a2f67648 Correct method name 2016-08-15 20:49:32 -07:00
Yukihiro "Matz" Matsumoto 86821379fd Merge pull request #3194 from nobu/chained-rhs
parse.y: fix chained assignments
2016-08-13 14:06:35 +09:00
Nobuyoshi Nakada bdd7e2bc8c parse.y: fix chained assignments
fix syntax errors with chained assignment with op assign.
reported [Bug:12669] in bugs.ruby-lang.org fixed in CRuby 2.4.
2016-08-13 13:56:14 +09:00
Yukihiro "Matz" Matsumoto bee34fb9bd Merge pull request #3193 from nobu/rhs-rescue
parse.y: simplify 90e8ce5
2016-08-12 10:29:46 +09:00
Nobuyoshi Nakada a06940daa9 parse.y: simplify 90e8ce5
simplify tOP_ASGN rules by command_rhs and arg_rhs rules with
%prec.
2016-08-12 10:14:35 +09:00
Yukihiro "Matz" Matsumoto 90e8ce5c30 parse.y: rescue modifiers for OP_ASGN should protect rhs only
reported in [Bug:12402] in bugs.ruby-lang.org fixed in CRuby 2.4
2016-08-11 16:27:14 +09:00
Tomoyuki Sahara d8189c2b19 Merge pull request #64 from asfluido/master
Apparently, in mruby-process gem, Process is now a Module, not a Class
2016-08-10 09:12:44 +09:00
Carlo - PERI 024b09de0c Apparently, in mruby-process gem, Process is now a Module, not a Class 2016-08-09 11:23:49 +02:00
ksss ada264a513 instance_eval env should remake Fix #3191 2016-08-08 12:41:19 +09:00
Yukihiro "Matz" Matsumoto 7a7fac8412 removed ChangeLog that has not been updated for long time; ref #3190 2016-08-08 12:38:21 +09:00
Yukihiro "Matz" Matsumoto af4567bb41 update copyright notice and license description for mt19937ar.[ch]
despite the fact original authors agreed to distribute their work
under MIT license, it does not mean mt19937ar.[ch] became the work
of mruby developers. To clarify, we updated copyright and license
notice of the source files.
2016-08-08 12:38:21 +09:00
Tomoyuki Sahara b341ee7c12 Merge pull request #63 from ksss/opt
Enable option :in, :out, :err to IO.popen
2016-08-08 10:12:20 +09:00
Tomoyuki Sahara 9ccf03e5ae Merge pull request #62 from ksss/global
Should use global variable
2016-08-08 09:38:22 +09:00
ksss d2c1f4d10b Enable Fixnum option 2016-08-07 22:19:21 +09:00
ksss b462ef4506 Enable option :in, :out, :err 2016-08-07 21:21:01 +09:00
ksss 4cac5e9c70 Should use global variable 2016-08-06 23:11:31 +09:00
Yukihiro "Matz" Matsumoto 501e1ef260 Merge pull request #3189 from wrl/public-hash-values
make mrb_hash_values() a public API function
2016-08-03 02:26:04 +09:00
William Light e02a88e031 make mrb_hash_values() a public API function 2016-08-01 11:05:46 +02:00
Yukihiro "Matz" Matsumoto eb7422af58 Merge pull request #3188 from guoxiao/warning
intptr_t should be used instead of uint32_t to hold a pointer.
2016-07-31 14:37:39 +09:00
Guo Xiao 339005e1d5 intptr_t should be used instead of uint32_t to hold a pointer.
Fix warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
2016-07-31 12:53:39 +08:00
Yukihiro "Matz" Matsumoto 42fefef916 Merge pull request #3186 from rmalizia44/patch-2
Update mirb.c
2016-07-28 10:59:32 +09:00
Malizia R 1c7572bc6a Update mirb.c 2016-07-27 16:51:10 -03:00
Yukihiro "Matz" Matsumoto 2b4ed40fc9 Merge pull request #3185 from kou/string-reduce-needless-array
Reduce needless Array generation in some String methods
2016-07-27 14:03:52 +09:00
Kouhei Sutou 6bb0775d76 Reduce needless Array generation in some String methods
Here are some benchmarks:

each_char:

    # /tmp/each_char.rb
    a = "a" * 1000000
    a.each_char do |x|
    end

Without this change:

    % time bin/mruby /tmp/each_char.rb
    bin/mruby /tmp/each_char.rb  1.07s user 0.02s system 99% cpu 1.088 total

With this change:

    % time bin/mruby /tmp/each_char.rb
    bin/mruby /tmp/each_char.rb  0.52s user 0.01s system 99% cpu 0.530 total

2 times faster with this change.

codepoints:

    # /tmp/codepoints.rb
    a = "a" * 1000000
    a.codepoints do |x|
    end

Without this change:

    % time bin/mruby /tmp/codepoints.rb
    bin/mruby /tmp/codepoints.rb  1.16s user 0.05s system 99% cpu 1.216 total

With this change:

    % time bin/mruby /tmp/codepoints.rb
    bin/mruby /tmp/codepoints.rb  0.56s user 0.02s system 99% cpu 0.589 total
2016-07-27 13:58:07 +09:00
Yukihiro "Matz" Matsumoto 3757b16dab Merge pull request #3184 from ksss/each_char
Support to call without block to String#each_char
2016-07-27 02:32:04 +09:00
ksss bef63a4f91 Support to call without block to String#each_char 2016-07-26 18:46:23 +09:00
Yukihiro "Matz" Matsumoto 32ad74f4d1 Merge pull request #3182 from sdottaka/fix-broken-msvc-build
Fix broken msvc build
2016-07-26 00:13:53 +09:00
Yukihiro "Matz" Matsumoto e635dc2a47 Merge pull request #3181 from sdottaka/fix-crash-on-mrb_parser_free
Fix crash in mrb_parser_free() due to freed memory access
2016-07-26 00:12:54 +09:00
Yukihiro "Matz" Matsumoto 62a16673a6 Merge pull request #3183 from Mav7/mav7/docs
yard docs for string.h
2016-07-25 15:07:30 +09:00
Yukihiro "Matz" Matsumoto a66a1e92e7 Merge pull request #3179 from ksss/struct
Should not define to `Struct` class
2016-07-25 14:19:10 +09:00
Yukihiro "Matz" Matsumoto 34ac707ea3 OP_ASGN vsp may be negative
reported by https://gist.github.com/miura1729/53fbd8af889c289a79108e38635b2378
fix proposed by @miura1729 in
https://github.com/miura1729/mruby/commit/b1b7933f7aa950cfb747b06327a0d0340f3e4ff8
2016-07-25 11:34:55 +09:00
Yukihiro "Matz" Matsumoto 417092360d Fixed crash error when #initialize is redefined for Struct; fix #3177
refactored redundant functions; removed optimized accessors for safety
this fix also close #3178
2016-07-25 10:32:10 +09:00
Ralph Desir(Mav7) 189ad47346 yard docs for string.h 2016-07-23 02:47:32 -04:00
Takashi Sawanaka fb1c4b3ba7 Fix broken msvc build 2016-07-23 11:57:36 +09:00
Takashi Sawanaka 2eefbfed9d Fix crash in mrb_parser_free() due to freed memory access 2016-07-23 11:34:04 +09:00
ksss bf21063a72 Add regression test 2016-07-22 15:26:17 +09:00
ksss 1a8074accf Should not define to Struct class 2016-07-22 15:26:11 +09:00
Tomoyuki Sahara cc66bf94d1 Merge pull request #9 from ksss/pointer-sign
Suppress compiler warning [-Wpointer-sign]
2016-07-19 09:45:32 +09:00
Tomoyuki Sahara 13650747e7 Merge pull request #10 from dabroz/master
Added 'U' pack support.
2016-07-19 09:44:14 +09:00
Tomasz Dąbrowski 26c1dedcab Added 'U' pack support. 2016-07-18 16:06:01 +02:00
Yukihiro "Matz" Matsumoto 97283faa16 Merge pull request #3176 from ksss/string-insert
String#insert should be destructive
2016-07-15 01:22:02 +09:00
ksss d83d9cd164 String#insert should be destructive 2016-07-14 21:33:15 +09:00
Yukihiro "Matz" Matsumoto 72b28f1ed6 Merge pull request #3174 from ksss/local-jump-error
Should raise LocalJumpError when no block given
2016-07-14 17:10:54 +09:00
ksss 9dc820590f Should raise LocalJumpError when no block given 2016-07-14 13:03:25 +09:00
Yukihiro "Matz" Matsumoto d4d807b774 relax string length limitation to 64KB; fix #2725 2016-07-13 03:22:15 +09:00
Yukihiro "Matz" Matsumoto 2e74a93112 Merge pull request #3171 from kjunichi/c-has-no-try
C doesn't have try-catch
2016-07-08 12:14:46 +09:00
Junichi Kajiwara f67631afb4 C doesn't have try-catch 2016-07-08 06:30:45 +09:00
Yukihiro "Matz" Matsumoto 0d9aa830aa Merge pull request #3169 from ksss/Wshift-negative-value
Fix warning shift-negative-value
2016-07-02 00:55:00 +09:00
ksss b9f7daf5b6 Suppress compiler warning [-Wpointer-sign] 2016-07-01 22:27:02 +09:00
ksss e3bc81e75e Fix warning shift-negative-value 2016-07-01 22:00:55 +09:00
Yukihiro "Matz" Matsumoto 3c406d54be Merge pull request #3166 from yyamano/fix-gc-profile
Fix compilation error with GC_PROFILE.
2016-06-30 14:32:53 +09:00
Yuji Yamano 00faf3d317 Fix compilation error with GC_PROFILE. 2016-06-29 03:57:02 -04:00
Tomoyuki Sahara 93d481d4b4 update $? when IO object is closed. closes #58. 2016-06-22 10:29:49 +09:00
Tomoyuki Sahara e90ecff671 Merge pull request #60 from drbrain/test_io_setup_failure
Test io setup failure
2016-06-21 09:52:30 +09:00
Tomoyuki Sahara 2af2a4fff8 add IO#isatty and IO#tty? 2016-06-21 09:49:34 +09:00
Yukihiro "Matz" Matsumoto fa1c1ab487 Merge pull request #3163 from mattn/fix-public_methods
Fix public methods
2016-06-18 11:40:32 +09:00
Yasuhiro Matsumoto 8a15ab0c0c add test for public_methods(false) 2016-06-18 01:21:21 +09:00
Yasuhiro Matsumoto 8764bd282c fix public_methods(false) 2016-06-18 01:18:24 +09:00
Yukihiro "Matz" Matsumoto a8af43f61e Merge pull request #3162 from udzura/patch-1
Update doc, write about add_test_dependency
2016-06-14 19:10:04 +09:00
Uchio KONDO 481aa31f93 Update doc, write about add_test_dependency 2016-06-14 16:37:06 +09:00
Yukihiro "Matz" Matsumoto 09b11850a5 mrb_gc_unregister() to remove one registration; close #3160
when multiple mrb_gc_register() were called for the same object
2016-06-10 10:12:48 +09:00
Yukihiro "Matz" Matsumoto 44de80f76d fix a compiler warning for uninitialized variable 2016-06-10 10:11:58 +09:00
Yukihiro "Matz" Matsumoto 8dde647a51 add temporary workaround for irep memory corruption
need to find out real memory bug that appears in full-debug/mrbtest
2016-06-10 10:04:52 +09:00
Tomoyuki Sahara b2a0c9c6bf Merge pull request #30 from rhykw/tcpserver-reuseaddr
Use TCPServer SO_REUSEADDR
2016-05-30 10:42:30 +09:00
rhykw 4f6703203b TCPServer use SO_REUSEADDR if possible 2016-05-28 09:33:53 +09:00
rhykw 2a80cccf30 TCPServer use SO_REUSEADDR 2016-05-23 21:44:34 +09:00
Yukihiro "Matz" Matsumoto 6b0299f72b fixed remaining bugs in OP_ASGN stack adjustment; close #3159 2016-05-16 15:36:36 +09:00
Yukihiro "Matz" Matsumoto 29d3a40418 stack adjustment after NODE_OP_ASGN with NODE_CALL was wrong; fix #3159 2016-05-16 01:49:24 +09:00
Yukihiro "Matz" Matsumoto 2e81fee731 parser_dump() to show symbol number for NODE_SYM 2016-05-16 01:49:24 +09:00
Eric Hodel 11961b42ac Create socket in /tmp for security
Some systems do not allow UNIX sockets from arbitrary directories.
Instead of trying to `#define SOCKET_PATH` correctly I assume the /tmp/
directory is accessible and use it.
2016-05-12 17:55:14 -07:00
Eric Hodel 777cf70cc5 Include reason in test failure message
I am seeing this test fail in some environments but can't determine why.
The extra information will help me determine the reason bind(2) is
failing.
2016-05-12 16:02:09 -07:00
Yukihiro "Matz" Matsumoto 5933651ac7 Merge pull request #3157 from cremno/add-mrb_int_mul_overflow
add function for checked mrb_int multiplication
2016-05-11 09:41:19 +09:00
cremno 7453a5dfea use mrb_int_mul_overflow() 2016-05-10 19:12:02 +02:00
cremno 6369374f79 add mrb_int_mul_overflow(); close #3149
- call __builtin_mul_overflow() if it's available
- perform a 64-bit multiplication for 32-bit mrb_int (default)
- otherwise a much slower method is used
2016-05-10 19:10:49 +02:00
Yukihiro "Matz" Matsumoto 0be4b8960e Merge pull request #3156 from cremno/fix-mruby_version-value
fix MRUBY_VERSION value
2016-05-10 10:04:31 +09:00
Yukihiro "Matz" Matsumoto 4fd0cb61d7 Merge pull request #3154 from cremno/improve-checked-mrb_int-arithmetic-implementation
improve checked mrb int arithmetic implementation
2016-05-10 10:04:04 +09:00
Yukihiro "Matz" Matsumoto bc715f9938 Merge pull request #3155 from cremno/fix-3152
fix #3152
2016-05-10 09:18:25 +09:00
cremno bf63cff46e fix MRUBY_VERSION value
RUBY_ENGINE_VERSION and MRUBY_VERSION should refer to the same string.
2016-05-09 17:19:47 +02:00
cremno 309791b3ae raise the error at runtime; fix #3152 2016-05-09 16:57:56 +02:00
cremno 7276e84637 use type-generic checked arithmetic builtins
Version checking is not reliable - especially with Clang.
E.g. Apple's Clang (Xcode) uses different version numbers.
A feature check (__has_builtin) is the recommened way.

Add the MRB_HAVE_TYPE_GENERIC_CHECKED_ARITHMETIC_BUILTINS
macro which may be used in other files.
2016-05-09 16:52:57 +02:00
cremno 39b6a9dafc define macros only if builtins are n/a 2016-05-09 16:34:20 +02:00
Yukihiro "Matz" Matsumoto b4e1889813 Merge pull request #3153 from kou/remove-needless-assignment
Remove needless assignment
2016-05-09 17:35:19 +09:00
Kouhei Sutou 51cc35dc09 Remove needless assignment
d4ee409ae9 should remove this line.
2016-05-09 14:05:51 +09:00
Yukihiro "Matz" Matsumoto ea033526fb Merge pull request #3151 from okkez/use-stack-directly
Use stack directly
2016-04-27 12:14:54 +09:00
Kenji Okimoto d4ee409ae9 Use stack directly
See https://github.com/mruby/mruby/pull/3142#issuecomment-201138873
2016-04-27 10:18:13 +09:00
Yukihiro "Matz" Matsumoto 8f0c1c7d3c mruby-sprintf:fix double negative signs in printf; fix #3148
MRB_INT_MAX does not have corresponding positive integer
2016-04-23 23:50:01 +09:00
Yukihiro "Matz" Matsumoto c5229074bb mruby-sprintf: format specifiers o,u,x,b ignore sign(+); ref #3148 2016-04-23 22:20:11 +09:00
Yukihiro "Matz" Matsumoto e5c2013829 Merge pull request #3147 from ksss/1.8
Avoid Syntax Error on CRuby v1.8
2016-04-16 23:27:15 +09:00
ksss 451523ff02 Avoid Syntax Error on CRuby v1.8
CRuby v1.8 dose not support named capture
2016-04-16 22:39:09 +09:00
Yukihiro "Matz" Matsumoto fa1a17cbc4 Merge pull request #3145 from timoschilling/patch-1
fix syntax highlighting
2016-04-14 00:04:54 +09:00
Timo Schilling 1863f325c0 fix syntax highlighting 2016-04-13 13:41:31 +02:00
Yukihiro "Matz" Matsumoto 8c67e915b4 mruby-eval: instance_eval should keep target_class; close #3141 2016-04-11 14:28:44 +09:00
Yukihiro "Matz" Matsumoto ae5b5ce575 vm.c: mrb_hash_set() may reallocate VM stack; close #3133 2016-04-11 14:11:44 +09:00
Yukihiro "Matz" Matsumoto d97a37eb7b fix possible memory leak in mruby-time gem 2016-04-04 21:58:46 +09:00
Yukihiro "Matz" Matsumoto e1e888e354 fix too much optimization for ||= 2016-04-01 01:22:16 +09:00
Yukihiro "Matz" Matsumoto d098d823de fix duplicated eval in op_asgn
`a` in `a.m += c` or `a[b] += c` should be evaluated only once.
2016-03-30 20:43:57 +09:00
Yukihiro "Matz" Matsumoto 4979b52d61 reduce OP_ARRAY in argument splat 2016-03-30 01:35:11 +09:00
Yukihiro "Matz" Matsumoto 0e03a7f2a3 mruby-enum-ext: refine minmax 2016-03-30 01:12:18 +09:00
Yukihiro "Matz" Matsumoto 4d909d8b2b Merge pull request #3142 from kou/add-missing-regs-update
Add missing regs update
2016-03-25 13:41:35 +09:00
Kouhei Sutou c69cba2ad9 Add missing regs update
mrb_vm_define_class() may realloc() mrb->c->stack because it calls
mrb_funcall() for inherited hook. If mrb->c->stack is realloc()-ed, regs
refers orphan address.
2016-03-25 00:25:48 +09:00
Yukihiro "Matz" Matsumoto dd072b5364 remove wrong ISO section from safe navigation test; ref 4c1ce0f6 2016-03-24 23:35:04 +09:00
Yukihiro "Matz" Matsumoto 3886becec5 better code generation for ||=; #3138 2016-03-24 16:03:58 +09:00
Yukihiro "Matz" Matsumoto 1ce471c1cc ||= with cvars and constants should work with false values; #3138 2016-03-24 07:59:58 +09:00
Yukihiro "Matz" Matsumoto 4fcff34747 ||= reference error can happen with constants as well; #3138 2016-03-23 23:51:23 +09:00
Yukihiro "Matz" Matsumoto 817b884343 add #dig tests 2016-03-23 12:34:32 +09:00
Yukihiro "Matz" Matsumoto daf83946bb add #dig to Array,Hash and Struct 2016-03-23 11:49:28 +09:00
Yukihiro "Matz" Matsumoto 4c1ce0f61c add safe-navigation operator tests 2016-03-23 08:51:25 +09:00
Yukihiro "Matz" Matsumoto 21a3ae08f7 add safe-navigation (aka lonely) operator &. 2016-03-23 08:51:25 +09:00
Yukihiro "Matz" Matsumoto 7d0612528e Merge pull request #3139 from cremno/fix-vs2010-build
deprecate and fix VS2010/2012 build
2016-03-23 00:22:26 +09:00
cremno 30b0100e6c fix VS2010/2012 build
They don't have <inttypes.h>, only <stdint.h>.
2016-03-22 11:46:49 +01:00
cremno bfc7b2e30f deprecate Visual Studio 2010 and 2012 2016-03-22 11:41:16 +01:00
cremno 611e99e741 remove unnecessary array/each 2016-03-22 11:38:09 +01:00
Yukihiro "Matz" Matsumoto 2b0baec32a fixed silly class variable/constant confusion; #3138 2016-03-22 00:06:32 +09:00
Yukihiro "Matz" Matsumoto a02acf2635 rescue NameError from class variable access like @@foo ||= 42; fix #3138 2016-03-21 03:49:08 +09:00
Yukihiro "Matz" Matsumoto 643d967b10 Merge pull request #3131 from bggd/fix_bintest_on_windows
Fix doesn't work bintest on :visualcpp toolchain
2016-03-16 16:29:14 +09:00
Yukihiro "Matz" Matsumoto 52d388515f Merge pull request #3132 from pbosetti/edison
Added example for cross-compiling on Intel Edison
2016-03-16 16:28:35 +09:00
Yukihiro "Matz" Matsumoto 273eac6b64 Merge pull request #3136 from bggd/add_appveyor
Add appveyor.yml
2016-03-16 16:27:58 +09:00
bggd 51cb72962d Create appveyor_config.rb 2016-03-15 20:43:51 +09:00
bggd 87e5b0f30c Add appveyor.yml for Visual Studio 2015/2013 2016-03-15 20:41:15 +09:00
Yukihiro "Matz" Matsumoto 4f20d58ac2 Merge pull request #3135 from wanabe/reduce-include-paths
Reduce compiler include_paths
2016-03-14 09:35:53 +09:00
wanabe 2aa6b449a2 Reduce compiler include_paths 2016-03-13 17:06:39 +09:00
Paolo Bosetti a27426aa8d Added example for cross-compiling on Intel Edison 2016-03-07 17:50:03 +01:00
bggd a138ae3506 Fix doesn't work bintest on :visualcpp toolchain 2016-03-07 14:50:21 +09:00
Yukihiro "Matz" Matsumoto 41d6ba23b5 fix dump_prefix() with wrong type argument; fix #3128 2016-03-07 10:59:34 +09:00
Yukihiro "Matz" Matsumoto 0c28c7d754 change backtrace sep from const char* to char 2016-03-07 10:59:34 +09:00
Yukihiro "Matz" Matsumoto 4e95779851 Merge pull request #3125 from zzak/default-benchmark-build-config
Add default benchmark build config
2016-03-07 10:27:36 +09:00
Yukihiro "Matz" Matsumoto b4d946f6bc Merge pull request #3129 from kou/fix-segv-by-backtrace-and-gc
Fix SEGV by backtrace and GC
2016-03-06 12:15:55 +09:00
Yukihiro "Matz" Matsumoto 1a4540fb4a Merge pull request #3127 from kou/suppress-warning
Suppress a warning
2016-03-06 12:13:05 +09:00
Kouhei Sutou f1eb3aea11 Fix segmentation fault by backtrace and GC
GitHub: fix #3122

It reverts #3126. #3126 fixes the segmentation fault but generates
broken backtrace.

This change fixes the segmentation fault and generates correct
backtrace. The strategy of this change is "generating backtrace while
irep is alive".

/tmp/test.rb:
    def gen
      e0 = nil
      begin
        1.times {
          raise 'foobar'
        }
      rescue => e
        e0 = e
      end
      e0
    end

    e = gen
    GC.start
    gen
    GC.start

    puts e.backtrace.join("\n")

Run:

    % bin/mruby /tmp/test.rb
    /tmp/test.rb:5:in Object.gen
    /home/kou/work/ruby/mruby.kou/mrblib/numeric.rb:77:in Integral#times
    /tmp/test.rb:4:in Object.gen
    /tmp/test.rb:13

FYI:

    % ruby -v /tmp/test.rb
    ruby 2.3.0p0 (2015-12-25) [x86_64-linux-gnu]
    /tmp/test.rb:5:in `block in gen'
    /tmp/test.rb:4:in `times'
    /tmp/test.rb:4:in `gen'
    /tmp/test.rb:13:in `<main>'
2016-03-06 11:58:54 +09:00
Kouhei Sutou d77c72dac5 Revert "Merge pull request #3126 from jbreeden/backtrace_irep_null_check"
This reverts commit bf7719fe8d, reversing
changes made to 4f4fa0ade0.

We should get backtrace while irep is alive.
2016-03-06 11:51:04 +09:00
Kouhei Sutou e5cce388ff Suppress a warning
mrbgems/mruby-eval/src/eval.c: In function ‘create_proc_from_string’:
    mrbgems/mruby-eval/src/eval.c:152:10: warning: assignment discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
         file = "(eval)";
              ^
2016-03-06 10:05:14 +09:00
Yukihiro "Matz" Matsumoto bf7719fe8d Merge pull request #3126 from jbreeden/backtrace_irep_null_check
Null check for irep & initialize loc.lineno
2016-03-06 08:44:15 +09:00
jbreeden d2a8f7e0cc Fix Travis CI 2016-03-05 14:22:31 -08:00
jbreeden e02ff850fe Null check for irep & initialize loc.lineno 2016-03-05 13:45:56 -08:00
Zachary Scott aa90ad57fe Add default benchmark build config 2016-03-04 16:14:13 +09:00
Yukihiro "Matz" Matsumoto 4f4fa0ade0 Merge pull request #3121 from asfluido/master
The original code crashed when mrb->backtrace.n grew to 16.
2016-02-29 10:22:00 +09:00
Carlo Prelz d6cbe1bfc6 The original code crashed when mrb->backtrace.n grew to 16.
It looks like the logic to reallocate the backtrace was flawed,
based on the wrong variable (loc_raw->i, which, as I have verified,
decreases from 16 to 0 instead of increasing)

I am not sure if this is the correct fix
2016-02-26 09:21:33 +01:00
Yukihiro "Matz" Matsumoto 0c23d5a353 Merge pull request #3120 from rmalizia44/patch-1
Avoid Error when Compiling with -std=c99 flag
2016-02-25 08:55:41 +09:00
Malizia R 52aba8a706 Avoid Error when Compiling with -std=c99 flag 2016-02-24 16:39:38 -03:00
Yukihiro "Matz" Matsumoto b8479b62d8 too many register push for else-less condtions; fix #3117 2016-02-22 09:55:51 +09:00
Yukihiro "Matz" Matsumoto 81acbd2dd1 cosmetic change for OP_EQ 2016-02-22 09:38:20 +09:00
Yukihiro "Matz" Matsumoto cf5ca03676 mruby-struct: copied Struct length is not initialized; fix #3114 2016-02-19 11:46:18 +09:00
Yukihiro "Matz" Matsumoto 819c9da8d2 peephole optimization for LOADNIL before STRCAT; ref #3110 2016-02-17 11:03:27 +09:00
Yukihiro "Matz" Matsumoto d8fc09cf92 push value for NULL AST when value is required; fix #3110 2016-02-17 11:02:29 +09:00
Yukihiro "Matz" Matsumoto ec35e549ad need to free context when reclaiming fiber object in GC; fix #3109 2016-02-17 10:19:14 +09:00
Yukihiro "Matz" Matsumoto da96c335fe syntax error in interpolated symbol; fixed #3108 2016-02-16 11:33:58 +09:00
Yukihiro "Matz" Matsumoto 5596d14c00 Merge pull request #3107 from mame/fix-enum-hash
[255, 255, 255, 255, 255].hash raises "can't convert Float into Integer"
2016-02-16 10:43:12 +09:00
Yukihiro "Matz" Matsumoto 683ff0cbd0 Merge pull request #3106 from mame/fix-eval-no-filename
Fix segfault when `eval("__FILE__")` is executed
2016-02-16 10:42:28 +09:00
Yusuke Endoh a1a157b27e suppress "can't convert Float into Integer" in Enumerable#hash 2016-02-16 00:07:50 +09:00
Yusuke Endoh 668cc1b435 Fix segfault when eval("__FILE__") is executed 2016-02-15 23:57:18 +09:00
Yukihiro "Matz" Matsumoto 74d52a11f2 Merge pull request #3101 from deuwert/fix-test-build
Fix bug in mruby-test gem (fix #3094)
2016-02-12 08:27:55 +09:00
Yukihiro "Matz" Matsumoto 60c1ed4461 Merge pull request #3102 from deuwert/add-limits
Add more limitations
2016-02-12 08:27:04 +09:00
Daniel Bovensiepen 299cb5a7b9 Fix formatting again... 2016-02-12 03:37:36 +08:00
Daniel Bovensiepen 46fbd5349b Add more limitations:
- defined?
  - alias on global variables
  - Operator modification
  - Kernel.binding missing
2016-02-12 03:32:41 +08:00
Daniel Bovensiepen 5976185c0a Fix bug in mruby-test gem.
In an used build path mruby-test wasn't updating mrbtest.c in the
case that the mgem selection was changed. This lead to:
  - a missing reference in case a GEM was removed
  - ignoring all new GEMs added to the build configuration

This fix keeps track of the active gems and demands a rebuild of
mrbtest.c in case that the gem selection changed.
2016-02-12 02:19:18 +08:00
Yukihiro "Matz" Matsumoto 37344ecaad fixed typos in limitations.md 2016-02-12 00:54:07 +09:00
Yukihiro "Matz" Matsumoto 473827d1d1 Merge pull request #3100 from deuwert/toolchain-openwrt
Add toolchain support for OpenWRT
2016-02-12 00:48:13 +09:00
Yukihiro "Matz" Matsumoto f40fc9ab69 Merge pull request #3099 from deuwert/more-limits
Addition to mruby limitation documentation
2016-02-12 00:46:28 +09:00
Daniel Bovensiepen fcbaafaa2c Add toolchain support for OpenWRT 2016-02-11 21:32:42 +08:00
Daniel Bovensiepen e7eb40f9d6 Fix formatting 2016-02-11 21:23:29 +08:00
Daniel Bovensiepen 44d26dd994 Add more limitations 2016-02-11 21:19:48 +08:00
Yukihiro "Matz" Matsumoto 18870428bc add 1/2 description to limitations.md file 2016-02-11 16:50:01 +09:00
Yukihiro "Matz" Matsumoto b3a2d8bec5 Merge pull request #3098 from deuwert/limitations
Limitations
2016-02-11 15:34:04 +09:00
Daniel Bovensiepen 983948c5be Small format fix 2016-02-11 04:48:57 +08:00
Daniel Bovensiepen 3bbc486cf9 Add limitation file 2016-02-11 04:38:29 +08:00
Yukihiro "Matz" Matsumoto 62b06ab4d4 [cppcheck] mrb_str_rindex() remove unnecessary len update by chars2bytes() 2016-02-05 21:54:07 +09:00
Yukihiro "Matz" Matsumoto af4dd3d579 [cppcheck] remove duplicated break 2016-02-05 21:48:44 +09:00
Yukihiro "Matz" Matsumoto 3c73c315f4 Hash: check flags before accessing ifnone; ref #980 2016-02-05 10:08:28 +09:00
Yukihiro "Matz" Matsumoto 25e4ec3f37 cache UTF8 status for utf8_strlen(); ref #980 2016-02-04 23:33:16 +09:00
Yukihiro "Matz" Matsumoto 5e514c910f cache mrb_regexp_p(); ref #980 2016-02-04 23:22:01 +09:00
Yukihiro "Matz" Matsumoto 4344ca0aca Merge pull request #3096 from hlogmans/master
Fix missing dependency on mruby-print to support 'puts'
2016-02-04 10:15:08 +09:00
Hugo Logmans ed5bf72bcf Fix missing dependency on mruby-print to support 'puts' 2016-02-03 15:05:44 +01:00
Yukihiro "Matz" Matsumoto ce84e42f41 Merge pull request #3093 from retrage/retrage/dev
Add String#rjust to mruby-string-ext
2016-01-31 11:41:01 +09:00
Yukihiro "Matz" Matsumoto ac5649700c Merge pull request #3092 from kenhys/fix-suported
Fix a typo
2016-01-31 11:26:20 +09:00
HAYASHI Kentaro 9442cb9652 Fix a typo
su ported ->
supported
  ^
2016-01-31 00:48:12 +09:00
Tomoyuki Sahara 18f7b45ad1 Merge pull request #29 from rmalizia44/patch-1
Add _WIN32_WINNT definition to Avoid Windows Compilation Errors
2016-01-30 22:39:20 +09:00
Akira Moroo cb1a80e741 Add String#rjust test to mruby-string-ext 2016-01-30 14:28:00 +09:00
Akira Moroo e86bc6bb47 Add String#rjust to mruby-string-ext 2016-01-30 14:25:53 +09:00
rmalizia44 be2ec608e2 Add _WIN32_WINNT definition to Avoid Windows Compilation Errors
the line #define _WIN32_WINNT 0x0501 will cause ws2tcpip.h to implement the missing functions freeaddrinfo, getaddrinfo and getnameinfo on windows
2016-01-28 03:28:05 -02:00
Yukihiro "Matz" Matsumoto c35a25c51e Merge pull request #3091 from visualsayed/fix_hash_replace_method
protect NoMethodError from calling to_hash in replace
2016-01-28 12:17:51 +09:00
Sayed Abdelhaleem f5f48d9400 protect NoMethodError from calling to_hash in replace 2016-01-27 21:17:33 +02:00
Yukihiro "Matz" Matsumoto 2723b10a01 Merge pull request #3090 from kou/fix-segv-by-stack-extension-in-mrb-get-args
Fix SEGV by stack extension in mrb_get_args()
2016-01-22 00:50:15 +09:00
Kouhei Sutou c77123d20a Fix SEGV by stack extension in mrb_get_args()
mrb_get_args() keeps pointer of the current stack. But address of the
current stack maybe changed by method call.

'i' format character calls #to_i when the argument isn't integer but
has #to_i.

Here is a code that may call #to_i in mrb_get_args():

    case 'i':
      // ...
            default:
              *p = mrb_fixnum(mrb_Integer(mrb, ARGV[arg_i]));
              break;
     // ...

Here is a code #to_i is called:

    class X
      def initialize(i)
        @i = i
      end

      def to_i
        @i
      end
    end

    [][X.new(0), 0] # X#to_i is called

So, mrb_get_args() shouldn't keep pointer and use it. mrb_get_args()
should always refer mrb->ci->stack to use valid address of the current
stack.
2016-01-22 00:20:00 +09:00
Tomoyuki Sahara 1c4428880b Merge pull request #57 from MaximAbramchuck/patch-1
Add installation instructions
2016-01-21 22:09:17 +09:00
Yukihiro "Matz" Matsumoto 8a74e68552 mruby-random: fixed wrong fixnum conversion 2016-01-21 03:31:08 +09:00
Maxim Abramchuk 7d6f2beaaa Add installation instructions 2016-01-20 13:40:30 +03:00
Yukihiro "Matz" Matsumoto 8d78c49e9a Merge pull request #3088 from maclover7/patch-1
Small grammar fix
2016-01-20 15:14:46 +09:00
Jon Moss 793a62954e Small grammar fix
[ci skip]
2016-01-19 22:37:44 -05:00
Yukihiro "Matz" Matsumoto 17bd40a566 Merge pull request #3087 from kou/fix-segv-on-rerasing-no-memory-error
Fix SEGV on re-raising NoMemoryError
2016-01-19 17:36:51 +09:00
Kouhei Sutou 1d84b3205a Fix SEGV on re-raising NoMemoryError
Think about the following Ruby script:

segv.rb:

    begin
      lambda do
        lambda do
          "x" * 1000 # NoMemoryError
        end.call
      end.call
    rescue
      raise
    end

If memory can't allocate after `"x" * 1000`, mruby crashes.

Because L_RAISE: block in mrb_vm_exec() calls mrb_env_unshare() via
cipop() and mrb_env_unshare() uses allocated memory without NULL check:

L_RAISE: block:

    L_RAISE:
      // ...
      while (ci[0].ridx == ci[-1].ridx) {
        cipop(mrb);
        // ...
      }

cipop():

    static void
    cipop(mrb_state *mrb)
    {
      struct mrb_context *c = mrb->c;

      if (c->ci->env) {
        mrb_env_unshare(mrb, c->ci->env);
      }

      c->ci--;
    }

mrb_env_unshare():

    MRB_API void
    mrb_env_unshare(mrb_state *mrb, struct REnv *e)
    {
      size_t len = (size_t)MRB_ENV_STACK_LEN(e);
      // p is NULL in this case
      mrb_value *p = (mrb_value *)mrb_malloc(mrb, sizeof(mrb_value)*len);

      MRB_ENV_UNSHARE_STACK(e);
      if (len > 0) {
        stack_copy(p, e->stack, len); // p is NULL but used. It causes SEGV.
      }
      e->stack = p;
      mrb_write_barrier(mrb, (struct RBasic *)e);
    }

To solve the SEGV, this change always raises NoMemoryError even when
realloc() is failed after the first NoMemoryError in
mrb_realloc(). mrb_unv_unshare() doesn't need to check NULL with this
change.

But it causes infinite loop in the following while:

    L_RAISE:
      // ...
      while (ci[0].ridx == ci[-1].ridx) {
        cipop(mrb);
        // ...
      }

Because cipop() never pops ci.

This change includes cipop() change. The change pops ci even when
mrb_unv_unshare() is failed by NoMemoryError.

This case can be reproduced by the following program:

    #include <stdlib.h>
    #include <mruby.h>
    #include <mruby/compile.h>

    static void *
    allocf(mrb_state *mrb, void *ptr, size_t size, void *ud)
    {
      static mrb_bool always_fail = FALSE;

      if (size == 1001) {
        always_fail = TRUE;
      }
      if (always_fail) {
        return NULL;
      }

      if (size == 0) {
        free(ptr);
        return NULL;
      } else {
        return realloc(ptr, size);
      }
    }

    int
    main(int argc, char **argv)
    {
      mrb_state *mrb;
      mrbc_context *c;
      FILE *file;

      mrb = mrb_open_allocf(allocf, NULL);
      c = mrbc_context_new(mrb);
      file = fopen(argv[1], "r");
      mrb_load_file_cxt(mrb, file, c);
      fclose(file);
      mrbc_context_free(mrb, c);
      mrb_close(mrb);

      return EXIT_SUCCESS;
    }

Try the following command lines:

    % cc -I include -L build/host/lib -O0 -g3 -o no-memory no-memory.c -lmruby -lm
    % ./no-memory segv.rb
2016-01-19 16:37:42 +09:00
Tomoyuki Sahara c165e50193 Merge pull request #28 from zzak/port-ntop-pton-win32
Port inet_ntop and inet_pton for WIN32
2016-01-18 16:12:35 +09:00
Tomoyuki Sahara a25ec0a749 Merge pull request #27 from zzak/fix-udpsock-warning
Fix warning: variable 'udpsock' set but not used
2016-01-18 16:09:55 +09:00
Zachary Scott bdc118304c Port inet_ntop and inet_pton for WIN32
Without these functions, compilation fails on MinGW
2016-01-18 15:34:26 +09:00
Zachary Scott c8a2c636e0 Fix warning: variable 'udpsock' set but not used 2016-01-18 15:27:32 +09:00
Yukihiro "Matz" Matsumoto 70d24a9e5f Merge pull request #3086 from pra85/2016
Update license year range to 2016
2016-01-18 13:08:17 +09:00
Prayag Verma 70283a94a5 Update license year range to 2016 2016-01-18 08:55:12 +05:30
Yukihiro "Matz" Matsumoto 2e49a13163 Merge pull request #3084 from syohex/all-zeros
Fix passing all zero string to Kernel#Integer
2016-01-14 16:38:58 +09:00
Syohei YOSHIDA 787685a0b9 Fix all zero string case 2016-01-14 11:07:07 +09:00
Syohei YOSHIDA 2a661ac612 Add tests which passes all zero string to Kernel#Integer 2016-01-14 11:05:03 +09:00
Yukihiro "Matz" Matsumoto 4924856949 Merge pull request #3082 from jefffederman/feature/install-mruby-with-ruby-install
Update README to mention ruby version management tools
2016-01-14 00:49:25 +09:00
Jeff Federman d2961203b5 Update README to mention ruby version management tools 2016-01-13 10:30:15 -05:00
Yukihiro "Matz" Matsumoto 2f7efda346 Merge pull request #3081 from val00274/fix_toolchains_params
Fix build error in ruby 1.8.
2016-01-13 17:02:38 +09:00
asatou d0668cf9c9 Fix build error in ruby 1.8.
Apply change of #2978 to :clang, :gcc, :visualcpp toolchains
2016-01-13 16:02:58 +09:00
Yukihiro "Matz" Matsumoto 8143285956 Merge pull request #3080 from kou/fix-class-variable-in-module
Fix class variable reference in module
2016-01-11 10:00:34 +09:00
Kouhei Sutou ad492eb9f3 Fix class variable reference in module
Fix #3079
2016-01-11 00:34:15 +09:00
Yukihiro "Matz" Matsumoto fb2e0b721f fixed a problem with upvar access from instance_eval; ref #3072 2016-01-08 09:07:58 +09:00
Yukihiro "Matz" Matsumoto 0000192710 Merge pull request #3077 from sgnr/output-backtrace-segfault
Fix segfault on mrb_exc_backtrace.
2016-01-08 08:40:30 +09:00
Simon Génier 146a9eeb38 Fix segfault on mrb_exc_backtrace.
The code to iterate over backtrace locations was changed in #3065, but
unfortunately output_backtrace was not correctly updated to forward the
callback.
2016-01-07 11:24:16 -05:00
Yukihiro "Matz" Matsumoto f3cce24035 replace mrb_toplevel_run() by mrb_top_run() 2016-01-07 22:48:22 +09:00
Yukihiro "Matz" Matsumoto 258cb2093c mruby-eval: fixed receiver value in eval context; close #3072 2016-01-07 22:37:58 +09:00
Yukihiro "Matz" Matsumoto f7afe1d82a change mrb_run related API names; compatibility macros provided 2016-01-07 22:36:29 +09:00
Yukihiro "Matz" Matsumoto 725b3ca5a7 move KHASH_DECLARE(ht..) to mruby/hash.h; close #3073 2016-01-07 12:46:38 +09:00
Yukihiro "Matz" Matsumoto 7c82bfa7fe mruby-sprintf to use mrb_int formatting macros; ref #3076 2016-01-07 12:23:17 +09:00
Yukihiro "Matz" Matsumoto 3cf5af681a Merge pull request #3074 from syohex/precision-parameter-type
printf precision parameter must be 'int' type
2016-01-07 11:19:43 +09:00
Syohei YOSHIDA 931cc0359a printf precision parameter must be 'int' type
There is a problem when MRB_INT64 is enabled.
2016-01-07 11:06:20 +09:00
Yukihiro "Matz" Matsumoto ec711914a4 Merge pull request #3071 from ksss/symbol
symname_p support `!~`
2016-01-06 13:45:26 +09:00
Yukihiro "Matz" Matsumoto 20ebe9c5eb Merge pull request #3070 from kazuho/kazuho/printf-specifiers
provide macro to ease using printf mrb_int
2016-01-06 12:17:05 +09:00
Kazuho Oku cd131d18a7 define MRB_PRI? that map to PRI?NN depending on the size of mrb_int 2016-01-06 12:00:56 +09:00
ksss af21b365d2 symname_p support !~ 2016-01-06 11:59:09 +09:00
Yukihiro "Matz" Matsumoto 9145aed85e bytes2chars() conversion to fail if target byte offset is not on the character boundary; ref #3067
that means String#index matches first byte of a multi-byte character. this behavior is different
from CRuby, but a compromise for mruby which does not have encoding stuffs.
2016-01-05 18:05:25 +09:00
Yukihiro "Matz" Matsumoto aec825a64c stack_extend before eval_under() 2016-01-04 10:22:38 +09:00
Yukihiro "Matz" Matsumoto aa1f668b80 instance_eval should pass the receiver as a block parameter; close #3029 2016-01-02 22:01:00 +09:00
Yukihiro "Matz" Matsumoto 879e27d0f1 mirb: enlarge code buffer size to 4KB 2016-01-02 16:58:42 +09:00
Yukihiro "Matz" Matsumoto bd462c5edc mruby-fiber: fiber_switch() to use nesting VM when it's called from C API or mrb_funcall(); close #3056 2016-01-02 13:48:45 +09:00
Yukihiro "Matz" Matsumoto 4683b89b84 Merge pull request #3068 from kazuho/kazuho/osx-_setjmp
use _setjmp/_longjmp on OS X
2016-01-01 10:15:55 +09:00
Kazuho Oku 121c6e30aa use _setjmp/_longjmp on other BSD flavors 2016-01-01 06:48:53 +09:00
Kazuho Oku f4bb329c74 use _setjmp/_longjmp on OS X 2016-01-01 06:24:49 +09:00
Yukihiro "Matz" Matsumoto 38b9c2d308 mruby-fiber: add Fiber.yield description; close #3066
Fiber.yield cannot be called from #initialize which is called by
mrb_funcall().  It is mruby limitation.
2015-12-31 21:25:53 +09:00
Yukihiro "Matz" Matsumoto 31b8469bff Merge pull request #3067 from ksss/use-memchr
Use memchr for performance
2015-12-31 21:20:51 +09:00
ksss 6c1b6ef7a5 Use memchr for performance
```ruby
s = "b"
str = ("a" * 100 + s)

t = Time.now
str.index(s)
puts Time.now - t
```

before => 0.000788
after  => 0.000508

---

```ruby
s = "b"
str = ("a" * 100 * 1024 * 1024 + s)

t = Time.now
str.index(s)
puts Time.now - t
```

before => 0.225474
after  => 0.008658
2015-12-31 17:52:22 +09:00
Yukihiro "Matz" Matsumoto 1d7d7062fc __t_printstr__ may not be available for tests 2015-12-31 00:55:07 +09:00
Yukihiro "Matz" Matsumoto 3531fe179c GC must scan env from fibers even when it's not yet copied to heap; fix #3063 2015-12-31 00:11:37 +09:00
Yukihiro "Matz" Matsumoto 4fdec33ff4 simpler t_print 2015-12-30 14:25:05 +09:00
Yukihiro "Matz" Matsumoto ee3fa1be49 Merge pull request #3065 from kou/support-backtrace-after-method-calls
Support backtrace after method calls
2015-12-29 23:49:33 +09:00
Kouhei Sutou 0ebac02813 Skip backtrace related tests when backtrace isn't available 2015-12-29 23:26:31 +09:00
Kouhei Sutou a561bdb25f Support backtrace after method calls
GitHub: fix #2902, #2917

The current implementation traverses stack to retrieve backtrace. But
stack will be changed when some operations are occurred. It means that
backtrace may be broken after some operations.

This change (1) saves the minimum information to retrieve backtrace when
exception is raised and (2) restores backtrace from the minimum
information when backtrace is needed. It reduces overhead for creating
backtrace Ruby objects.

The space for the minimum information is reused by multiple
exceptions. So memory allocation isn't occurred for each exception.
2015-12-29 20:36:12 +09:00
Yukihiro "Matz" Matsumoto e132de9e8e Merge pull request #3064 from kou/fix-indent
Fix indent
2015-12-29 14:25:10 +09:00
Kouhei Sutou 1eeeecb08a Fix indent 2015-12-29 14:20:10 +09:00
Yukihiro "Matz" Matsumoto d3c6fafaf3 Merge pull request #2331 from take-cheeze/struct_test
Improve `Struct` test.
2015-12-26 15:46:49 +09:00
Yukihiro "Matz" Matsumoto 825ced12de remove duplicated local variable declaration 2015-12-26 11:23:28 +09:00
Yukihiro "Matz" Matsumoto d10e304d79 Merge pull request #3062 from suzukaze/refactor-array-each
Refactor Array#each
2015-12-26 10:49:20 +09:00
Yukihiro "Matz" Matsumoto 6218b2e098 Merge pull request #3061 from mattn/fix-ctrl-c
mirb: Don't exit on Ctrl-C
2015-12-26 10:28:50 +09:00
Jun Hiroe 88076901fd Refactor Array#each 2015-12-26 10:12:01 +09:00
kyab 1e34b12a02 mirb: Don't exit on Ctrl-C 2015-12-26 10:03:28 +09:00
Yukihiro "Matz" Matsumoto 76d44b1b48 remove execute bit from mrbgems/mruby-bin-debugger files 2015-12-26 00:07:16 +09:00
Yukihiro "Matz" Matsumoto 6e09abceaf Merge pull request #3058 from mattn/fix-include-blocker
rename include blocker
2015-12-26 00:04:24 +09:00
Yasuhiro Matsumoto f0205e1182 rename include blocker 2015-12-25 13:43:01 +09:00
Yukihiro "Matz" Matsumoto a060bd5114 Merge pull request #3057 from yuuu/add_next_command
mrdb: Added 'next' command.
2015-12-23 22:35:48 +09:00
Yuhei Okazaki 887a56ba80 fix bug that doesn't stop program when execute next command. 2015-12-23 22:16:36 +09:00
Yuhei Okazaki a08439a7c0 fixed next command's comment. 2015-12-23 22:16:36 +09:00
Yuhei Okazaki e1cc814ec4 add next command to mrdb. 2015-12-23 22:16:36 +09:00
Yukihiro "Matz" Matsumoto 7e4a7abf5f Merge pull request #3055 from mattn/fix-msvc-warnings
fix build on VS2012
2015-12-22 18:02:31 +09:00
Yasuhiro Matsumoto 7cc33af2dc fix build on VS2012 2015-12-22 17:46:20 +09:00
Yukihiro "Matz" Matsumoto d0727be6eb Merge pull request #3054 from kazuho/kazuho/adjust-column-offset-in-peekc_n
fix miscalculation of column number in `peekc_n`
2015-12-21 18:12:06 +09:00
Kazuho Oku adadbf5792 in peekc_n, adjust column number after calling nextc 2015-12-21 15:08:56 +09:00
Yukihiro "Matz" Matsumoto 2ca825a212 Merge pull request #3051 from zzak/ambiguous-first-argument
Fix "ambiguous first argument" warning
2015-12-17 01:23:34 +09:00
Zachary Scott 3f228c1da4 Fix "ambiguous first argument" warning 2015-12-17 00:12:19 +09:00
Yukihiro "Matz" Matsumoto 0720aac250 Merge pull request #3050 from remore/fix-minor-bug-about-objectspace
Add case statement of MRB_TT_SCLASS in mrb_obj_is_kind_of()
2015-12-16 21:04:43 +09:00
Kei Sawada d69b5c3fc7 Add case statement of MRB_TT_SCLASS in mrb_obj_is_kind_of() 2015-12-16 15:54:03 +09:00
Yukihiro "Matz" Matsumoto f54a98ff15 mrb_str_len_to_inum(): fixed a bug with MRB_INT_MIN conversion; fix #3048 2015-12-16 14:49:43 +09:00
Yukihiro "Matz" Matsumoto d18c55fca7 mrb_str_len_to_inum(): fixed a bug with underscores in digits; fix #3049 2015-12-16 14:49:08 +09:00
Yukihiro "Matz" Matsumoto 80c1c60762 Merge pull request #3047 from csouls/rafactor_array_ruby_extension
Remove redundant conditions of Array#each in ruby extension
2015-12-16 01:03:20 +09:00
Yusuke Tanaka d3f59db597 Remove redundant conditions of Array#each in ruby extension 2015-12-15 19:54:29 +09:00
Yukihiro "Matz" Matsumoto 2a234a93d7 mrb_str_len_to_inum(): string may not be NUL terminated; ref #3043 2015-12-14 10:59:56 +09:00
Yukihiro "Matz" Matsumoto 19c744e14d mrb_str_len_to_inum(): fixed a bug with separating _ in the digits; ref #3043 2015-12-14 10:59:56 +09:00
Yukihiro "Matz" Matsumoto 4a6a11486c Merge pull request #3045 from Mav7/master
Added YARD docs in new mruby.h
2015-12-13 15:49:43 +09:00
Ralph Desir af33394281 Undid newline and whitespace on YARD doc 2015-12-12 20:21:53 -05:00
Ralph Desir e27985416f One space indentation. 2015-12-12 18:28:42 -05:00
Yukihiro "Matz" Matsumoto 26a25e1666 mrb_str_len_to_inum: should not raise "string contains null byte" error on "0x"; fix #3043 2015-12-12 16:33:48 +09:00
Yukihiro "Matz" Matsumoto ad333cd191 mrb_str_len_to_inum: converting may not be terminated by NUL; fix #3044 2015-12-12 16:33:48 +09:00
Ralph Desir(Mav7) 4e267d74c6 Added YARD docs in new mruby.h 2015-12-11 01:52:44 -05:00
Tomoyuki Sahara 99e10b8dc4 File::ALT_SEPARATOR is always defined (some string or nil). 2015-12-08 16:44:13 +09:00
Tomoyuki Sahara 4acfd1c7d2 Merge pull request #56 from takahashim/fix-flock
Fix for windows(mingw)
2015-12-08 12:55:38 +09:00
takahashim dd754220ce Fix for windows(mingw)
* File.expand_path: support drive letter and ALT_SEPARATOR

* File.dirname: support ALT_SEPARATOR
* File.basename: ditto.

* IO.popen: raise NotImplementedError
* IO.pipe: ditto.
* `cmd`:  ditto.
* File#flock: ditto.
* FileTest.pipe?: ditto.
* FileTest.symlink?: ditto.
* FileTest.socket?: ditto.
2015-12-08 00:29:42 +09:00
Tomoyuki Sahara 68de1e4fc5 Merge pull request #55 from takahashim/separator
fix file separator
2015-12-07 16:00:46 +09:00
Yukihiro "Matz" Matsumoto b9e5be6a1c Merge pull request #3041 from zzak/travis-osx
Test against latest xcode
2015-12-07 15:27:33 +09:00
Zachary Scott 95edcc8f58 Test against latest xcode
/cc @banzaiman

https://github.com/mruby/mruby/commit/bfcc55fbf98665b33ca7110349aeb66d3ef0df1d#commitcomment-14812510
2015-12-07 15:10:58 +09:00
takahashim 0f5b8b66b0 fix file separator
* File::SEPARATOR should be "/"
* File::ALT_SEPARATOR should be "\\" or nil.
2015-12-04 15:36:41 +09:00
Tomoyuki Sahara 6c67120ed4 Merge pull request #54 from takahashim/win-crlf
fix tests for Win: use binary mode
2015-12-03 12:22:59 +09:00
takahashim b19c315148 fix tests for Win: use binary mode 2015-12-02 21:47:46 +09:00
Tomoyuki Sahara 7337bfa497 Merge pull request #53 from takahashim/build-win32
build on Win32
2015-12-02 10:13:15 +09:00
takahashim 07ceb138fa build on Win32 2015-12-02 00:10:43 +09:00
Yukihiro "Matz" Matsumoto 9a21aa2d3c preserve original string for error message 2015-12-01 21:42:07 +09:00
Yukihiro "Matz" Matsumoto ca417dac26 mrb_str_len_to_inum(): inspect string in error message 2015-12-01 21:41:53 +09:00
Yukihiro "Matz" Matsumoto 36fabe104b new API function mrb_string_value_len() 2015-12-01 16:18:01 +09:00
Yukihiro "Matz" Matsumoto 0701236dac mrb_str_to_inum(): should treat null byte in strings properly; fix #3040 2015-12-01 16:11:47 +09:00
Yukihiro "Matz" Matsumoto d3a56a6949 mrb_cstr_to_inum(): should ignore trailing white spaces even when badcheck set 2015-12-01 11:14:22 +09:00
Yukihiro "Matz" Matsumoto dbb8cf637e mrb_str_to_inum(): should raise error when string contains null byte 2015-12-01 11:13:32 +09:00
Yukihiro "Matz" Matsumoto 9f2fca6ebe mrb_str_to_inum(): no need to call mrb_string_value_cstr() here; ref 05411ee 2015-12-01 10:54:00 +09:00
Yukihiro "Matz" Matsumoto 05411ee15e mrb_string_value_cstr() should not raise error for frozen strings
cf. http://qiita.com/tsahara@github/items/b2a442af95ac893e10a1 (Japanese).
2015-12-01 10:45:43 +09:00
Yukihiro "Matz" Matsumoto 85bd99757c avoid comparison between signed and unsigned 2015-12-01 10:18:01 +09:00
Yukihiro "Matz" Matsumoto 1636ad41a6 C++ compiler does not like cast from pointer to enum; ref #3039 2015-12-01 10:17:35 +09:00
Yukihiro "Matz" Matsumoto c2996514d3 should ignore block to next, break, etc. fix #3039 2015-12-01 09:38:42 +09:00
Yukihiro "Matz" Matsumoto 81a7b4039b Merge pull request #3038 from zzak/gc-arena-docs
GC Arena docs pass for fixups
2015-11-30 10:34:11 +09:00
Zachary Scott dce300517f GC Arena docs pass for fixups 2015-11-30 10:09:43 +09:00
Yukihiro "Matz" Matsumoto 065966dae4 common.h are supposed to be included from other header, so call it with quotes; ref #3032 2015-11-28 00:10:38 +09:00
Yukihiro "Matz" Matsumoto 6f831ef21c Merge pull request #3037 from pbosetti/mruby-time
Implemented round(double) function when _MSC_VER < 1800
2015-11-27 23:31:56 +09:00
Paolo Bosetti 67e3cdfa76 Implemented round(double) function within mruby-time gem, for it is missing on
VisualStudio compilers where _MSC_ver < 1800
2015-11-27 10:54:03 +01:00
Yukihiro "Matz" Matsumoto 9a41db6f3a Merge pull request #2950 from mattn/mirb-file-args
mirb should take filename and arguments.
2015-11-27 17:49:35 +09:00
Yukihiro "Matz" Matsumoto 5c405dea3d include changed from by quotes ("") to by brackets (<>); close #3032 2015-11-27 17:48:23 +09:00
Yukihiro "Matz" Matsumoto 2e0519de89 Merge pull request #3036 from zzak/remove-mrbtest_irep
Remove mrbtest irep
2015-11-26 01:03:55 +09:00
Yukihiro "Matz" Matsumoto 6dbc314ad2 Merge pull request #3035 from iij/pr-yard-mrb_str_to_cstr
YARD doc for mrb_str_to_cstr.
2015-11-26 01:03:08 +09:00
Yukihiro "Matz" Matsumoto 2fb12bd90e Merge pull request #3034 from takahashim/try_convert
add {Array|Hash|String}.try_convert
2015-11-26 01:02:38 +09:00
Tomoyuki Sahara 07f1ebd26d symlink(2) returns -1 when it fails. 2015-11-24 17:09:00 +09:00
Tomoyuki Sahara 11ffb93852 assert_nothing_raised is not available on mruby 1.0.0. 2015-11-24 17:00:12 +09:00
Tomoyuki Sahara ca495944b6 Merge pull request #51 from ksss/io-pipe
Implement IO.pipe
2015-11-24 16:49:34 +09:00
Zachary Scott 1ef2faf1a6 Remove unnecessary dependencies for assert_rb codegen and test_rbireps 2015-11-24 16:33:40 +09:00
Zachary Scott e7a301828f Remove mrbtest_irep from mrbtest
If we make the core tests a dependency on the mruby-test gem,
we don't need to worry about maintaining the core test irep alone.
2015-11-24 16:32:17 +09:00
Tomoyuki Sahara 90b7ec88dc YARD doc for mrb_str_to_cstr. 2015-11-24 16:03:58 +09:00
ksss a55accd736 Implement IO.pipe 2015-11-24 14:24:24 +09:00
Tomoyuki Sahara c9a4091b83 arguments can be shared strings. 2015-11-24 09:54:03 +09:00
Tomoyuki Sahara 1f4bd9fd9f Merge pull request #50 from takahashim/file-symlink
add File.symlink
2015-11-24 09:47:09 +09:00
takahashim 621487a0cd add {Array|Hash|String}.try_convert 2015-11-24 08:39:39 +09:00
Yukihiro "Matz" Matsumoto 625a3fee77 Merge pull request #3033 from sgnr/compiler-fix-mrb-disable-stdio-typo
Fix MRB_DISABLE_STDIO typo.
2015-11-24 07:44:54 +09:00
Simon Génier 058ffcb29c Fix MRB_DISABLE_STDIO typo. 2015-11-23 11:05:33 -05:00
takahashim 2cc674e58e add File.symlink 2015-11-22 13:13:52 +09:00
Tomoyuki Sahara 14cdff075d Merge pull request #48 from takahashim/file-path
add File.path
2015-11-22 07:12:23 +09:00
takahashim 44473fecdd add File.path 2015-11-21 22:03:40 +09:00
Yukihiro "Matz" Matsumoto 18190fa77e Merge pull request #3030 from takahashim/nonzero
Support Numeric#zero? and Numeric#nonzero?
2015-11-21 00:09:17 +09:00
takahashim 40a9700ef8 support Numeric#zero? and Numeric#nonzero? 2015-11-20 23:39:45 +09:00
Yukihiro "Matz" Matsumoto 0e721efe9c Merge pull request #3028 from sgnr/fix-mrb-disable-stdio-typo
Fix typo on MRB_DISABLE_STDIO.
2015-11-20 10:58:33 +09:00
Simon Génier 40f237e938 Fix typo on MRB_DISABLE_STDIO. 2015-11-19 17:03:34 -05:00
Yukihiro "Matz" Matsumoto 2aca5ab479 Merge pull request #3027 from pbosetti/master
Fix check for VisualStudio Version in mruby-math gem
2015-11-19 22:51:03 +09:00
Yukihiro "Matz" Matsumoto abc724840e formatting buffer should be bigger for negative dots; ref #3025 2015-11-19 22:49:50 +09:00
Yukihiro "Matz" Matsumoto f974880563 binary format no longer need to preserve org_v 2015-11-19 22:49:50 +09:00
Yukihiro "Matz" Matsumoto 996417cabf integer range check was moved to mrb_flo_to_fixnum(); ref #3025 2015-11-19 22:49:50 +09:00
Yukihiro "Matz" Matsumoto 09abdcb5e8 negative binary format should not be masked by 10bits; ref #3025 2015-11-19 22:49:50 +09:00
Yukihiro "Matz" Matsumoto 1a9b607a4d binary sprintf should not be restricted by mrb_int size; fix #3025 2015-11-19 22:49:50 +09:00
Yukihiro "Matz" Matsumoto 8229f34098 Merge pull request #3026 from murasesyuka/bugfix/check_minus_signedint_bitshift_overflow
Bugfix nagative-number lshift() bit overflow
2015-11-19 22:49:27 +09:00
Paolo Bosetti 470fce5c90 Fix check for VisualStudio Version in mruby-math gem 2015-11-19 12:01:23 +01:00
murase_syuka ef95dcd390 Bugfix nagative-number lshift() bit overflow 2015-11-18 21:37:17 +09:00
Yukihiro "Matz" Matsumoto 557ab3472a Merge pull request #3024 from yoshiori/fix_readme_link
Update README.md
2015-11-18 01:27:55 +09:00
Yoshiori SHOJI 6c181fa123 Update README.md
Fix mrbgems doc link.
2015-11-17 10:20:39 -06:00
murase_syuka a4d5588101 Bugfix lshift() bit overflow; close #3023 2015-11-18 01:00:46 +09:00
mimaki 22464fe5a0 mruby-1.2.0 2015-11-17 18:02:30 +09:00
Yukihiro "Matz" Matsumoto 547a29d2ca Merge pull request #3022 from zzak/enable-full-debug-travis-build
Enable full-debug build on travis using `MRB_ENABLE_DEBUG_HOOK`
2015-11-17 12:51:01 +09:00
Yukihiro "Matz" Matsumoto 41c3d2fb70 Merge pull request #3021 from zzak/fix-enable-debug-define
Fix MRB_ENABLE_DEBUG_HOOK config typo left from 4440566
2015-11-17 12:50:27 +09:00
Zachary Scott 8454e9006e Enable full-debug build on travis using MRB_ENABLE_DEBUG_HOOK 2015-11-17 12:03:13 +09:00
Zachary Scott acdfcfe256 Fix MRB_ENABLE_DEBUG_HOOK config typo left from 4440566
/cc #3014
2015-11-17 11:43:37 +09:00
Yukihiro "Matz" Matsumoto acf2fb29cd Merge pull request #2752 from cremno/add-ruby_engine_version
add RUBY_ENGINE_VERSION
2015-11-17 09:00:21 +09:00
Yukihiro "Matz" Matsumoto 27ee7cfbde Merge pull request #3020 from cremno/document-mrb_utf8_string
document MRB_UTF8_STRING config macro
2015-11-17 08:59:03 +09:00
cremno e8d8796988 document MRB_UTF8_STRING config macro 2015-11-17 00:49:20 +01:00
Yukihiro "Matz" Matsumoto fd5e341855 Merge pull request #3019 from cremno/fix-mrb_disable_stdio-typos
fix MRB_DISABLE_STDIO typos
2015-11-17 08:16:52 +09:00
cremno e2e23c66d2 add RUBY_ENGINE_VERSION
RUBY_ENGINE_VERSION is equivalent to MRUBY_VERSION. It would be a
standard way to get the interpreter version (without a case expression).

It's also already defined by CRuby 2.3, JRuby 9000, Opal, and Rubinius.
2015-11-17 00:13:31 +01:00
cremno ad21e5e6d8 fix MRB_DISABLE_STDIO typos 2015-11-17 00:08:41 +01:00
Yukihiro "Matz" Matsumoto dd57cb7112 update TODO entries; close #2831 2015-11-17 07:30:34 +09:00
Yukihiro "Matz" Matsumoto 4440566b95 DISABLE_STDIO/ENABLE_DEBUG macros to rename; close #3014
changes:
 * rename DISABLE_STDIO -> MRB_DISABLE_STDIO
 * rename ENABLE_DEBUG -> MRB_ENABLE_DEBUG_HOOK
 * no more opposite macro definitions (e.g. ENABLE_STDIO, DISABLE_DEBUG).
 * rewrite above macro references throughout the code.
 * update documents
2015-11-17 07:30:34 +09:00
Yukihiro "Matz" Matsumoto 1dfe38bea0 Merge pull request #3018 from zzak/add-mruby-cli-authors
Add contributors from mruby-cli project to AUTHORS file
2015-11-17 04:31:46 +09:00
Yukihiro "Matz" Matsumoto 6ce31f334e Merge pull request #3017 from Mav7/master
Added type annotation to YARD.
2015-11-17 02:54:19 +09:00
Mav7 6f43e95163 Added type annotation to YARD. 2015-11-16 12:39:52 -05:00
Yukihiro "Matz" Matsumoto ed6f3a0735 Merge pull request #3015 from murasesyuka/fix/fix_lshift_and_fix_rshift_doc
fix comment
2015-11-16 23:36:11 +09:00
murase_syuka cd1a566002 fix comment 2015-11-16 22:27:42 +09:00
Zachary Scott 31a8743d66 Add contributors from mruby-cli project to AUTHORS file 2015-11-16 15:44:38 +09:00
Yukihiro "Matz" Matsumoto 916630be1a Merge pull request #3013 from zzak/dont-pull-gems-by-default
This patch changes git gem behavior to never pull gems unless specified.
2015-11-16 12:03:20 +09:00
Zachary Scott 98285e6b16 This patch changes git gem behavior to never pull gems unless specified.
Since mgem's function almost the same as git gems, but you can see they already
avoid pulling from source after the gem has already been cloned.

 You can see from the `load_special_path_gem` method found in the file
`mruby_build_gem.rake`, or extracted here:

```ruby
if File.exist? mgem_list_dir
  git.run_pull mgem_list_dir, mgem_list_url if $pull_gems
else
  FileUtils.mkdir_p mgem_list_dir
  git.run_clone mgem_list_dir, mgem_list_url, "--depth 1"
end
```

Also, later in this same method; mgem will set the `git` params.
Doing this will trigger the following block:

```ruby
if File.exist?(gemdir)
  if $pull_gems
    git.run_pull gemdir, url
  else
    gemdir
  end
else
  # ... clone
end
```

You can see here, this checks if `$pull_gems` is enabled before pulling.

Lastly, the final condition for this method is here:

```ruby
if params[:checksum_hash]
  # Jump to the specified commit
  git.run_checkout gemdir, params[:checksum_hash]
else
  # Jump to the top of the branch
  git.run_checkout gemdir, branch if $pull_gems
end
```

What we changed was the `else` condition of this block to follow the same
behavior as the aforementioned code. In doing so, we can avoid two things:

* Excess `clone` calls can slow down builds (times number of gems used)
* We _don't_ want our code to _update_ during build

To explain, if during build time there are some changes in the gem we are
depending upon: updating during compile time could actually break our
application.

This is what we're trying to avoid.
2015-11-16 11:43:56 +09:00
Yukihiro "Matz" Matsumoto 85b5af6154 Merge branch 'nobu-feature/hash-cmp' 2015-11-15 05:15:37 +09:00
Yukihiro "Matz" Matsumoto fa86026a99 move Hash comparison methods to mruby-hash-ext gem 2015-11-15 05:15:20 +09:00
Yukihiro "Matz" Matsumoto 1fc90746a6 Merge branch 'feature/hash-cmp' of https://github.com/nobu/mruby into nobu-feature/hash-cmp 2015-11-15 05:11:45 +09:00
Yukihiro "Matz" Matsumoto 4e63ea9649 Merge pull request #3011 from Mav7/master
Added more YARD docs to mruby.h
2015-11-15 05:10:52 +09:00
Mav7 66a839eb54 Added more YARD docs to mruby.h 2015-11-14 05:37:10 -05:00
Nobuyoshi Nakada bf5f83ffda Add comparison methods to Hash 2015-11-14 17:05:57 +09:00
Yukihiro "Matz" Matsumoto 9c108002bf Merge pull request #3008 from Mav7/master
Added YARD documentation in mruby.h
2015-11-10 09:50:15 +09:00
Mav7 27146dca16 Added YARD documentation in mruby.h 2015-11-09 12:16:14 -05:00
Yukihiro "Matz" Matsumoto 0c4218b704 Merge pull request #3007 from mruby-debian/fix/fail_to_package_build
fail to debuild
2015-11-10 01:20:09 +09:00
Akira Mitsui 1238739997 fail to debuild 2015-11-09 23:57:45 +09:00
Yukihiro "Matz" Matsumoto 7090b5f07a Merge pull request #3006 from cremno/remove-ifdef-mrb_fixnum_shift
remove ifdef as MRB_FIXNUM_SHIFT is always defined
2015-11-08 21:38:47 +09:00
Yukihiro "Matz" Matsumoto b65bd3778d Merge pull request #3005 from cremno/fix-ambiguous-first-argument-warning
fix ambiguous first argument warning
2015-11-08 21:37:19 +09:00
Yukihiro "Matz" Matsumoto d6e1762346 Merge pull request #3004 from cremno/remove-return
remove return
2015-11-08 21:36:54 +09:00
Yukihiro "Matz" Matsumoto d3b323cf2f PR #2521 did not work for singleton classes for non-class objects; fix #3003 2015-11-07 15:51:00 +09:00
cremno d109e5b4e1 remove ifdef as MRB_FIXNUM_SHIFT is always defined 2015-11-06 19:27:39 +01:00
cremno bb141e5532 fix ambiguous first argument warning
/home/travis/build/mruby/mruby/test/t/float.rb:201:17:
ambiguous first argument; put parentheses or even spaces
2015-11-06 18:35:19 +01:00
cremno e18e2a44f0 remove return
The return type of the mrb_objspace_each_objects function is void.
So this return statement with an expression is unnecessary and
also violates a constraint. From C99 §6.8.6.4:
>A return statement with an expression shall not appear
>in a function whose return type is void.
2015-11-06 18:13:38 +01:00
Yukihiro "Matz" Matsumoto 8bad1954a4 mrb_get_args should consume argument even when type specifier with bang get nil; fix #3002 2015-10-28 09:36:48 +09:00
Yukihiro "Matz" Matsumoto 614927447a mrb_str_concat() may call VM resursively thus may reallocate VM stack; close #3000 2015-10-27 01:06:15 +09:00
Yukihiro "Matz" Matsumoto 57e30b3be3 Merge pull request #3001 from zzak/fix-mrbtest-task
Ensure mrbs dependency is maintained for mruby-test
2015-10-24 23:03:48 +09:00
Zachary Scott 1e3da80923 Ensure mrbs dependency is maintained for mruby-test 2015-10-24 21:14:54 +09:00
Yukihiro "Matz" Matsumoto 727f2485c9 Merge pull request #2999 from sagmor/better-docs
More Docs
2015-10-22 07:10:16 +09:00
Seba Gamboa d4238494eb Tag include/mruby/error.h functions with required mrbgem tag 2015-10-21 17:03:43 -03:00
Seba Gamboa 25c8e95365 Revert "Mark core gems with mrbgem tag"
This reverts commit 5cdcce8dbd.
2015-10-21 14:31:13 -03:00
Yukihiro "Matz" Matsumoto e5fbf9dfa2 align codedump output for OP_JMP 2015-10-22 00:37:42 +09:00
Yukihiro "Matz" Matsumoto 73fa6486c6 align codedump output for OP_RETURN 2015-10-22 00:36:51 +09:00
Yukihiro "Matz" Matsumoto 48771a357c loop() to return StopIteration#result; [ruby-bugs#11498] 2015-10-21 21:47:43 +09:00
Yukihiro "Matz" Matsumoto 7278fd1f1b loop may return StopIteration#result; [ruby-bugs#11498] 2015-10-21 21:47:25 +09:00
Yukihiro "Matz" Matsumoto f6c58616a2 Merge pull request #2997 from furunkel/gc_cleanup
GC cleanup
2015-10-21 21:38:24 +09:00
Yukihiro "Matz" Matsumoto b41f1180c8 fixed SEGV in mrb_parser_dump(NODE_COLON3) 2015-10-21 21:15:35 +09:00
furunkel 6b67590fda Merge branch 'master' of https://github.com/mruby/mruby into gc_cleanup 2015-10-21 11:17:58 +02:00
furunkel 0d8012f513 Merge upstream 2015-10-21 11:12:08 +02:00
Yukihiro "Matz" Matsumoto 68ba386213 Merge pull request #2879 from cremno/call-always-frexp-instead-of-frexpl
call always frexp() instead of frexpl()
2015-10-21 10:36:11 +09:00
Seba Gamboa 13b552538a Remove obvious warnings from docs 2015-10-20 12:48:31 -03:00
Seba Gamboa f0e9974221 Fix Unknown tag error 2015-10-20 12:16:47 -03:00
Seba Gamboa 45e70e4dd6 Fix enumerator doc errors 2015-10-20 12:16:47 -03:00
Seba Gamboa 5cdcce8dbd Mark core gems with mrbgem tag 2015-10-20 12:16:47 -03:00
Seba Gamboa 84b70886cd Add block to document mrb_value type 2015-10-20 12:16:46 -03:00
Seba Gamboa fe1275a6af Improved mrb_args_format table 2015-10-20 12:16:46 -03:00
Seba Gamboa e871b77f41 Increasing docs coverage 2015-10-20 12:16:46 -03:00
furunkel 1c6b1d0155 Prefix mrb_gc_state enum members, make color defines private 2015-10-20 10:54:47 +02:00
Yukihiro "Matz" Matsumoto fc4f0b9be7 do not assert is_dead() during mark phase; close #2825 ref #2996 #2769 2015-10-20 17:06:54 +09:00
Tomoyuki Sahara 828551f86c off_t can be larger than mrb_int. 2015-10-20 16:03:02 +09:00
Tomoyuki Sahara db7d829679 raise a SystemCallError when lseek(2) fails. 2015-10-20 15:40:25 +09:00
Tomoyuki Sahara 21963f8fa1 UT for IO#sysseek. 2015-10-20 15:37:05 +09:00
Tomoyuki Sahara cac0035348 fix typo. 2015-10-20 15:16:46 +09:00
Tomoyuki Sahara 78fe65aec4 Merge branch 'master' of github.com:iij/mruby-io 2015-10-20 15:13:28 +09:00
furunkel 2b39d87fe8 Remove gc_ prefix of mrb_gc fields 2015-10-19 23:00:07 +02:00
furunkel 2f8b0f66bc Move MRB_GC_ARENA_SIZE to gc.h and fix compiler warnings 2015-10-19 22:43:09 +02:00
furunkel 5c093ed22b Remove segregated value struct declaration 2015-10-19 22:34:47 +02:00
furunkel 3ab2f9371e Clean up GC code 2015-10-19 22:29:43 +02:00
Tomoyuki Sahara 71197d2737 Merge pull request #47 from matsumoto-r/patch-1
Fix buffer overflow of `pos` when file-size is too big
2015-10-19 19:33:09 +09:00
MATSUMOTO, Ryosuke 238704592a Fix buffer overflow of pos when file-size is too big 2015-10-19 19:24:39 +09:00
Yukihiro "Matz" Matsumoto f07ee20260 Merge pull request #2995 from Mav7/master
fixed YARD documentation for mrb_obj_new
2015-10-18 00:16:02 +09:00
Ralph Desir(Mav7) 91444aec4b fixed YARD documentation for mrb_obj_new 2015-10-17 03:10:28 -04:00
Ralph Desir(Mav7) 12c24e0e89 got rid of dummy gem 2015-10-15 19:46:25 -04:00
Ralph Desir(Mav7) d16912681a updated YARD docs on mruby.h 2015-10-15 19:41:45 -04:00
Yukihiro "Matz" Matsumoto 83922d0bbb use visualcpp toolchain for test as well 2015-10-16 00:18:36 +09:00
Yukihiro "Matz" Matsumoto fd8634d26b Merge pull request #2993 from Mav7/master
Updated mruby.h YARD doc.
2015-10-15 23:12:47 +09:00
Yukihiro "Matz" Matsumoto d890645964 Merge branch 'crimsonwoods-fix_androidndk_rake' 2015-10-15 23:10:03 +09:00
Yukihiro "Matz" Matsumoto 622e68e535 Merge branch 'fix_androidndk_rake' of https://github.com/crimsonwoods/mruby into crimsonwoods-fix_androidndk_rake 2015-10-15 23:08:38 +09:00
Ralph Desir 2df9786f33 got rid of dummy gem i was testing 2015-10-14 22:48:49 -04:00
Ralph Desir(Mav7) d702b7fdf0 Add more YARD docs for mruby.h for mrb_undef_method and mrb_undef_class_method. 2015-10-14 16:49:10 -04:00
Ralph Desir(Mav7) a5b416e2ce Added documentation for mrb_undef_method 2015-10-14 02:50:12 -04:00
Yukihiro "Matz" Matsumoto 6b122c6b2a rename androidndk to androidin compile.md; ref #2991 2015-10-13 08:31:01 +09:00
Yukihiro "Matz" Matsumoto 089e2a1677 Merge pull request #2991 from sagmor/android-rename
Rename androidndk tolchain to just android
2015-10-13 08:28:10 +09:00
Seba Gamboa 1e2381f870 Rename androidndk tolchain to just android 2015-10-12 13:41:46 -03:00
Yukihiro "Matz" Matsumoto e48596e9e6 delete tasks/toolchains/androideabi.rake; ref #2983 #2988
use androidndk.rake which is better and 64bit aware
2015-10-13 00:03:58 +09:00
crimsonwoods 6b58d58a64 Fix issue: LDFLAGS is not applied correctly. 2015-10-12 23:15:32 +09:00
Yukihiro "Matz" Matsumoto af3aecd94f Merge pull request #2916 from felixjones/master
mrb_get_mid and mrb_get_argc
2015-10-12 21:04:19 +09:00
Yukihiro "Matz" Matsumoto 8ab39865d0 Merge pull request #2989 from Mav7/master
Wrote YARD docs for mrb_define_module, mrb_include_module, mrb_prepen…
2015-10-12 21:02:53 +09:00
Yukihiro "Matz" Matsumoto ae926e0802 Merge pull request #2988 from crimsonwoods/update_androidndk_rake
Update androidndk.rake to add support 64bit architectures.
2015-10-12 20:44:40 +09:00
Ralph Desir(Mav7) 6276227e70 Wrote YARD docs for mrb_define_module, mrb_include_module, mrb_prepend_module, mrb_define_class_method, mrb_define_module_function, and mrb_define_const on mruby.h 2015-10-11 08:55:56 -04:00
crimsonwoods 1a59721c69 Accoding to the implementation of 'cflags', '-no-canonical-prefixes' is isolated. 2015-10-11 17:40:26 +09:00
crimsonwoods 7b65f394e6 Remove unnecessary cases.
'mips64' can integrate into 'mips'.
'x86_64' is the same as 'mips64'.
2015-10-11 17:35:36 +09:00
crimsonwoods 61e4d1e6f0 Integrate common flag '-no-canonical-prefixes'. 2015-10-11 17:34:01 +09:00
crimsonwoods a2a5c34c56 Integrate common flag. 2015-10-11 17:25:48 +09:00
crimsonwoods ad8a895af5 Implement 'ldflags' for 'x86' architecture. 2015-10-11 17:24:47 +09:00
crimsonwoods 210f86f95c Implement 'ldflags' for 'x86_64' architecture. 2015-10-11 17:23:39 +09:00
crimsonwoods a106e5dc5a Implement 'ldflags' for 'mips' architecture. 2015-10-11 17:22:39 +09:00
crimsonwoods 2482642e09 Implement 'ldflags' for 'mips64' architecture. 2015-10-11 17:21:48 +09:00
crimsonwoods f5bc0cea20 Implement 'ldflags' for 'armeabi-v7a-hard' and 'armeabi-v7a'. 2015-10-11 17:17:32 +09:00
crimsonwoods 4a07b84d2c Implement 'ldflags' for 'armeabi' architecture. 2015-10-11 17:13:35 +09:00
crimsonwoods c0d30ab6cd Implement 'ldflags' for 'arm64' architecture. 2015-10-11 17:11:38 +09:00
crimsonwoods 07c35de3a6 Implement 'ldflags'.
This is the first step of implementing 'ldflags'.
2015-10-11 17:08:46 +09:00
crimsonwoods c38a27185e Add a missing required flag '-fstack-protector-strong'. 2015-10-11 16:46:53 +09:00
crimsonwoods ad89fe63ae Add support for 'x86_64' architecture. 2015-10-11 16:45:34 +09:00
crimsonwoods 1ac5d35753 Remove duplicated compiler options. 2015-10-11 16:40:59 +09:00
crimsonwoods 3458a83e89 Some flags (-ffunction-sections and etc.) should be set by default for 'x86' architecture. 2015-10-11 16:37:38 +09:00
crimsonwoods b493c6bfde Add support for 'armeabi-v7a-hard' architecture. 2015-10-11 16:34:42 +09:00
crimsonwoods abaad5c0d6 Some flags (-fpic and etc.) should be set by default for 'armeabi-v7a' and 'armeabi' architecture. 2015-10-11 16:32:50 +09:00
crimsonwoods 61a188a38a Some flags (-fpic and etc.) should be set by default for 'arm64' architecture. 2015-10-11 16:26:58 +09:00
crimsonwoods 86f710cf0c Replace tab by white-spaces. 2015-10-11 16:24:30 +09:00
crimsonwoods c022357ed5 Add support for 'mips64' architecture. 2015-10-11 16:22:45 +09:00
crimsonwoods 3ae425e3f0 Fix build error for 'x86' architecture. 2015-10-11 16:14:00 +09:00
crimsonwoods a2966734aa Fix build error for 'mips' architecture. 2015-10-11 16:06:21 +09:00
crimsonwoods cd9733933e Add support for 'arm64' architecture. 2015-10-11 15:58:28 +09:00
Yukihiro "Matz" Matsumoto 5830e2a655 update doc/guides/compile.md to refer androidndk.rake; ref #2983 #2974 2015-10-11 13:01:51 +09:00
Yukihiro "Matz" Matsumoto 8d6ba96430 Merge pull request #2983 from sagmor/android-setup
WIP - New Android NDK toolchain
2015-10-11 12:58:55 +09:00
Yukihiro "Matz" Matsumoto f1610a98c5 Merge pull request #2987 from crowell/patch-1
point to the right compile file
2015-10-11 12:54:34 +09:00
Jeffrey Crowell 7c6f237468 point to the right compile file 2015-10-10 22:45:39 -04:00
Yukihiro "Matz" Matsumoto c87c409a1d Merge pull request #2986 from takahashim/mrbdoc
fix `rake doc` error
2015-10-10 17:24:34 +09:00
takahashim f377753b16 fix rake doc error
using mrbdoc
2015-10-09 11:48:51 +09:00
Yukihiro "Matz" Matsumoto 02a6d866ba Merge pull request #2984 from sagmor/yard
Simpler documentation
2015-10-09 05:30:31 +09:00
Yukihiro "Matz" Matsumoto 0050bfe586 Merge pull request #2982 from mattn/unicode-print
print unicode on windows console
2015-10-09 04:45:42 +09:00
Seba Gamboa 87e0840e9d Fix mrb_obj_respond_to 2015-10-08 15:34:51 -03:00
Seba Gamboa ef73ec560e array header cleanup 2015-10-08 13:33:38 -03:00
Seba Gamboa 11fb10a21a Merge doc/api/mruby/hash.h.md docs 2015-10-08 13:29:57 -03:00
Seba Gamboa 5dfdd53bcc Merge doc/api/mruby/range.h.md docs 2015-10-08 13:26:23 -03:00
Seba Gamboa e441fdaad8 Merge doc/api/mruby/value.h.md docs 2015-10-08 13:17:31 -03:00
Seba Gamboa 649901b75c Merge doc/api/mruby/string.h.md contents 2015-10-08 12:55:28 -03:00
Seba Gamboa 4dc9869700 Merge contents from doc/api/mruby/version.h.md 2015-10-08 12:45:25 -03:00
Seba Gamboa 657d069582 Move guides location 2015-10-08 12:29:11 -03:00
Seba Gamboa 249226730f Formatting docs to new YARD structure 2015-10-08 12:29:11 -03:00
Seba Gamboa facc4bf428 Fix samples syntax highlighting 2015-10-08 12:29:11 -03:00
Seba Gamboa a0fe0c40b1 Remove old doxygen tags 2015-10-08 12:29:10 -03:00
Seba Gamboa 554406b987 Testing @see tag 2015-10-08 12:29:10 -03:00
Seba Gamboa 76f24d2182 Testing yard generation 2015-10-08 12:29:10 -03:00
Yasuhiro Matsumoto 6c0dc1a720 print unicode on windows console 2015-10-08 23:52:58 +09:00
Seba Gamboa 2bec248a19 Change some constants names 2015-10-07 21:18:28 -03:00
Seba Gamboa deb349d729 Refactoring Android NDK toolchain 2015-10-07 21:04:30 -03:00
Yukihiro "Matz" Matsumoto 2d29d140f5 Merge pull request #2978 from sagmor/toolchain-params
Add optional params to toolchain configuration
2015-10-07 23:34:08 +09:00
Seba Gamboa d6665fc402 Add optional params to toolchain configuration 2015-10-06 15:52:19 -03:00
Yukihiro "Matz" Matsumoto 98762c5a5d Merge pull request #2977 from tatsuhiro-t/gc-arena-howto
Add how to use  mrb_gc_arena_save()/mrb_gc_arena_restore() doc
2015-10-06 22:50:06 +09:00
Tatsuhiro Tsujikawa 445ba44a56 Add how to use mrb_gc_arena_save()/mrb_gc_arena_restore() doc 2015-10-06 22:25:37 +09:00
Yukihiro "Matz" Matsumoto 79c4618754 Merge pull request #2975 from yasuyuki/eval_rescue
Add regression test for #2933
2015-10-05 09:51:43 +09:00
INOUE Yasuyuki 49bfaca6c7 Add regression test for #2933 2015-10-04 18:22:34 +09:00
Yukihiro "Matz" Matsumoto e1ec2b02be travis-CI migration
Migrating from legacy to container-based infrastructure.
http://docs.travis-ci.com/user/migrating-from-legacy/
2015-10-03 19:14:07 +09:00
Yukihiro "Matz" Matsumoto 3f508d90da Merge pull request #2946 from sagmor/test-dependencies
Add gem test dependencies
2015-10-03 18:41:22 +09:00
Yukihiro "Matz" Matsumoto fafe86d364 Array#index to take block; fix #2968 close #2970 2015-10-01 22:35:06 +09:00
Yukihiro "Matz" Matsumoto d12926da8a Merge pull request #2937 from sagmor/gem
Distribute MRuby's source as a Ruby gem
2015-10-01 19:57:58 +09:00
Yukihiro "Matz" Matsumoto a41b61ea58 Merge pull request #2960 from suzukaze/refactor-hash-ext-test
Refator Hash#fetch test
2015-10-01 19:53:32 +09:00
Yukihiro "Matz" Matsumoto 6c78589163 Merge pull request #2962 from hone/spec_linker_flags_after_libraries
LinkerConfig is a struct with five params
2015-10-01 19:52:53 +09:00
Yukihiro "Matz" Matsumoto 6b3fd18262 clarify asserts to UTF-8 test suites; ref #2971 2015-10-01 19:32:29 +09:00
Yukihiro "Matz" Matsumoto 0a94c69cc3 optimize if statement with constant condition 2015-10-01 19:29:05 +09:00
Yukihiro "Matz" Matsumoto cb76ed8ec4 Merge pull request #2971 from mattn/utf8-chop
chop with utf-8. fix #2967
2015-10-01 19:27:35 +09:00
Yukihiro "Matz" Matsumoto 744578687d Merge pull request #2961 from takahashim/regex_enc
support Regexp literal option: //n and //u
2015-10-01 19:26:37 +09:00
Yukihiro "Matz" Matsumoto bcd10c710c Merge pull request #2973 from mattn/fix-windows-tests
fix tests on windows.
2015-10-01 19:21:57 +09:00
Yasuhiro Matsumoto 545d649eff fix tests on windows.
'bin/mruby' not work on windows. so correct command name and quoted arguments.
2015-09-30 16:13:02 +09:00
Yasuhiro Matsumoto 7ad75a4a19 fix tests 2015-09-30 13:08:11 +09:00
Yukihiro "Matz" Matsumoto 81ec5f5dc0 Merge pull request #2966 from maclover7/patch-1
Small Markdown updates to README.md
2015-09-29 21:43:38 +09:00
Jon Moss df2af60cfe Get rid of weird whitespace 2015-09-29 08:37:46 -04:00
Jon Moss f654a567e1 Retain #2595 markdown short links 2015-09-29 08:36:37 -04:00
Yasuhiro Matsumoto d5f145076c chop with utf-8. fix #2967 2015-09-29 21:22:45 +09:00
Tomoyuki Sahara e724c5af98 Merge pull request #45 from takahashim/enable-test
enable test
2015-09-28 12:25:33 +09:00
Tomoyuki Sahara 1f217ea82e Merge pull request #46 from takahashim/add-rewind
support IO#rewind
2015-09-28 12:24:51 +09:00
Jon Moss a9b78063aa Small Markdown updates to README.md
Small copy and styling updates
2015-09-27 16:04:15 -04:00
takahashim 9bbfc38bb4 add IO#rewind 2015-09-27 21:25:06 +09:00
Tomoyuki Sahara 1d6b7f9bba Merge pull request #44 from takahashim/io-addstr
support IO#<<
2015-09-27 21:15:54 +09:00
Yukihiro "Matz" Matsumoto 2eb2f5b408 Merge pull request #2965 from takahashim/fix-class-new-instance
fix signature of mrb_class_new_instance()
2015-09-27 20:48:54 +09:00
Yukihiro "Matz" Matsumoto f70634b542 Merge pull request #2964 from takahashim/fix-utf8-inspect
fix String#inspect with MRB_UTF8_STRING
2015-09-27 20:48:16 +09:00
takahashim df83d42935 fix signature of mrb_class_new_instance()
dd925578c6 changed the order of arguments,
but it doesn't seem intentional.
2015-09-27 17:33:13 +09:00
takahashim 074c6e2678 fix String#inspect with MRB_UTF8_STRING
cf. #2963
2015-09-27 13:43:45 +09:00
takahashim f5560e8f17 enable test 2015-09-27 01:39:11 +09:00
takahashim c26f998ed5 support IO#<< 2015-09-27 00:29:17 +09:00
Yukihiro "Matz" Matsumoto 0aa83c503d Enumerable#each_{cons,slice} to return enumerators 2015-09-27 00:04:34 +09:00
Terence Lee c717bbb77a LinkerConfig is a struct with five params 2015-09-25 23:22:11 -06:00
Jun Hiroe 570c261555 Refator Hash.fetch test 2015-09-26 09:58:36 +09:00
takahashim f187fdd996 support Regexp literal option: //n and //u 2015-09-26 09:41:38 +09:00
Yukihiro "Matz" Matsumoto 524a038876 inspect prints valid UTF-8 character without escaping 2015-09-25 23:09:46 +09:00
Yukihiro "Matz" Matsumoto c069e5ff40 add boundary check to utf8len() to avoid oob memory access 2015-09-25 23:08:37 +09:00
Yukihiro "Matz" Matsumoto 798ec3aff4 UTF-8 string support in core
define MRB_UTF8_STRING (in mrbconf.h) to enable UTF-8 support.
2015-09-24 02:37:33 +09:00
Yukihiro "Matz" Matsumoto 101ec5eb0a don't print anonymous struct class name 2015-09-23 12:51:12 +09:00
Yukihiro "Matz" Matsumoto 20a4e9ade6 mruby-struct gem refactoring 2015-09-23 12:13:01 +09:00
Yukihiro "Matz" Matsumoto ad1087f5ed should initialize local variable prepended to false 2015-09-23 03:27:10 +09:00
Yukihiro "Matz" Matsumoto 6a06a3e48d String#rindex should no longer take integer argument 2015-09-23 01:06:26 +09:00
Yukihiro "Matz" Matsumoto 418eec2c7d remove a comment that no longer be true; 2cb6c27 2015-09-23 00:01:39 +09:00
Yukihiro "Matz" Matsumoto 2cb6c27781 String#index should no longer take integer argument 2015-09-22 19:10:48 +09:00
Yukihiro "Matz" Matsumoto e47f0fc0c2 Merge pull request #2959 from sagmor/api-documentation
C API documentation
2015-09-22 04:14:31 +09:00
Seba Gamboa 4c8205db1f Merge descriptions from doc/api/mruby/array.h.md 2015-09-21 15:13:43 -03:00
Seba Gamboa 88f9770f83 document mrb_nil_value 2015-09-21 14:50:59 -03:00
Seba Gamboa 0e5b815399 Document data header 2015-09-21 14:50:04 -03:00
Yukihiro "Matz" Matsumoto 73dc32c670 add new functions mrb_gc_register/unregister; close #1411
some routines need to refer mruby objects (e.g. callbacks), in that case
you have to protect your objects from garbage collection. the new functions
mrb_gc_register() keeps those objects from GC. you have to remove your
objects using mrb_gc_unregister() when your C routines use mruby objects
any longer, otherwise objects will leak.
2015-09-22 00:15:29 +09:00
Seba Gamboa dd925578c6 Sort compiler macros around 2015-09-21 11:59:39 -03:00
Seba Gamboa 40bf7bde78 Sorting documentation grouping 2015-09-21 01:48:42 -03:00
Seba Gamboa c127614638 Setting up doxygen groups 2015-09-20 21:14:07 -03:00
Seba Gamboa f36944f551 Merging documentation from docs 2015-09-20 18:57:17 -03:00
Seba Gamboa 7505bad677 Playing around with some documentations schemes 2015-09-18 23:59:29 -03:00
Yukihiro "Matz" Matsumoto 386a2b8aa1 Merge pull request #2958 from suzukaze/fix-indents
Fix indents
2015-09-19 11:41:23 +09:00
Jun Hiroe ce6297aa04 Fix indents 2015-09-19 06:38:28 +09:00
Yukihiro "Matz" Matsumoto 6d55e770d3 Merge pull request #2957 from suzukaze/replace-1-with-true-macro
Replace 1 with TURE macro
2015-09-18 23:20:55 +09:00
Yukihiro "Matz" Matsumoto 9586aaa889 Merge pull request #2956 from Asmod4n/master
Problem: Hash#fetch doesn't raise KeyError when a key cannot be found
2015-09-18 23:19:51 +09:00
Jun Hiroe dd1fa91a66 Replace 1 with TURE macro 2015-09-18 15:51:49 +09:00
Asmod4n 4bd98671bc Problem: Hash#fetch doesn't raise KeyError when a key cannot be found
Solution: change the Exception class raised to KeyError when a key
cannot be found.
2015-09-17 13:28:09 +02:00
Asmod4n e6d9b450ba Merge remote-tracking branch 'mruby/master' 2015-09-17 13:24:17 +02:00
Yukihiro "Matz" Matsumoto 070e04ea22 Merge pull request #2953 from takahashim/string_aset
support String#[pos, len]= val
2015-09-17 09:34:11 +09:00
takahashim f1c23a0f75 support String#[]= with 3 args 2015-09-16 18:50:03 +09:00
Yukihiro "Matz" Matsumoto 08f9a3ed04 Merge pull request #2952 from takahashim/hash-fetch-block-key
fix block variable in Hash#fetch
2015-09-16 03:19:44 +09:00
takahashim b88ca625ab fix block variable in Hash#fetch 2015-09-16 02:57:41 +09:00
Yukihiro "Matz" Matsumoto e91b7d640c Merge pull request #2951 from tatsuhiro-t/mrb_close_with_nullptr
Don't crash if NULL is passed to mrb_close
2015-09-15 08:45:34 +09:00
Yukihiro "Matz" Matsumoto e8f88daa9c instance_eval should set target_class; close #2936
target_class should be singleton class of the receiver
2015-09-14 15:56:54 +09:00
Yasuhiro Matsumoto e20c2d78d1 mirb should take filename and arguments. 2015-09-12 13:23:22 +09:00
Tatsuhiro Tsujikawa a085c04e37 Don't crash if NULL is passed to mrb_close
Sometimes it is very useful just return from mrb_close if NULL is
passed as mrb.  This is the same spirit of free(3), which just does
nothing if NULL is passed.
2015-09-12 12:11:10 +09:00
Yukihiro "Matz" Matsumoto eb9bec19dc Merge pull request #1822 from mattn/locale
Add mrb_utf8_from_locale, mrb_utf8_free, mrb_locale_from_utf8, mrb_locale_free
2015-09-11 11:42:03 +09:00
Yasuhiro Matsumoto 8277e950ee Support windows locale
Add mrb_utf8_from_locale, mrb_utf8_free, mrb_locale_from_utf8, mrb_locale_free. Just works for windows.
2015-09-11 11:12:03 +09:00
Yukihiro "Matz" Matsumoto 3ed8e7fbb2 Merge pull request #2949 from tatsuhiro-t/custom-install-location
Customize installation directory using INSTALL_DIR environment variable
2015-09-11 10:48:09 +09:00
Tatsuhiro Tsujikawa 291265ec86 Customize installation directory using INSTALL_DIR environment variable
Previously, minirake installed several commands (e.g., mrbc) in
repository locally under bin directory.  But there was no knob for
users to change this directory.  It effectively made `make distcheck`
fail if mruby was embedded into project managed by autotools.

This change adds a way for the user to change installation directory
by setting INSTALL_DIR environment variable.
2015-09-11 00:15:01 +09:00
Yukihiro "Matz" Matsumoto 698b3c925d add Hash#rehash to handle key modification; ref #2945 2015-09-10 23:03:53 +09:00
Yukihiro "Matz" Matsumoto 543ac88eae Merge pull request #2947 from kazuho/kazuho/freeze-hash-key
freeze the hash keys (fixes #2945)
2015-09-10 22:58:01 +09:00
Kazuho Oku 8256d77c7f avoid unnecessary string duplications by checking the frozen flag 2015-09-10 22:50:01 +09:00
Kazuho Oku 44eb1492be freeze the hash key (fixes #2945) 2015-09-10 22:24:10 +09:00
Seba Gamboa 803f11e001 Add test dependencies 2015-09-09 13:33:42 -03:00
Tomoyuki Sahara 625995424c To run test, we need "conf.enable_test" in build_config.rb. 2015-09-08 13:25:05 +09:00
Tomoyuki Sahara f3016752bd build in container-based environment. 2015-09-08 13:23:46 +09:00
Tomoyuki Sahara ecd7ef5924 Revert "try to fix failure on travis."
This reverts commit 02daa2509d.
2015-09-08 11:57:08 +09:00
Tomoyuki Sahara 02daa2509d try to fix failure on travis. 2015-09-08 10:44:08 +09:00
Seba Gamboa 1c8576dcc2 Change to Proc.new to make Ruby 1.9 Happy 2015-09-07 15:37:55 -03:00
Seba Gamboa 9d0c49f05e Switch gem API to constants only 2015-09-06 12:57:31 -03:00
Yukihiro "Matz" Matsumoto 1cbbb7e11c Merge branch 'polyfox-module-prepend' 2015-09-05 02:04:20 +09:00
Yukihiro "Matz" Matsumoto 2550edd570 remove origin member to implement prepend from struct RClass; ref #2885
instead origin is saved in ICLASS with MRB_FLAG_IS_ORIGIN set.
2015-09-05 02:01:02 +09:00
Yukihiro "Matz" Matsumoto 2f1a031fcd Merge pull request #2943 from zzak/subdirs
Allow rbfiles in mrblib and test to have subdirs
2015-09-05 01:06:12 +09:00
Yukihiro "Matz" Matsumoto 47795d0636 Merge pull request #2942 from suzukaze/revert
Revert 7b5f8b0 except removing trailing spaces
2015-09-05 01:05:20 +09:00
Jun Hiroe 6ced9c3752 Revert 7b5f8b0 except removing trailing spaces 2015-09-05 00:08:12 +09:00
Zachary Scott c6860bc0c4 Allow rbfiles in mrblib and test to have subdirs 2015-09-04 11:01:50 -04:00
Yukihiro "Matz" Matsumoto fb3883e57e Merge pull request #2941 from Mav7/master
Added range.h.md and edited re.h.md and version.h.md
2015-09-04 17:00:58 +09:00
Yukihiro "Matz" Matsumoto 8bb7962eb8 Merge branch 'module-prepend' of https://github.com/polyfox/mruby into polyfox-module-prepend 2015-09-04 04:01:49 +09:00
Ralph Desir 743432d4ec Update range.h.md 2015-09-03 14:52:21 -04:00
Ralph Desir 8a09515c6c Cleaned up the version.h markdown. 2015-09-03 14:20:16 -04:00
Ralph Desir e1beb502ab Cleaned up the re.h markdown. 2015-09-03 14:19:02 -04:00
Ralph Desir(Mav7) 93aaa06736 Added range markdown. 2015-09-03 14:16:57 -04:00
Seba Gamboa 230db2ca85 Add other version.h constants 2015-09-03 11:13:27 -03:00
Yukihiro "Matz" Matsumoto 7967c76e14 Merge pull request #2940 from zzak/build_mrbtest
Add build_mrbtest after config block is evaluated
2015-09-03 14:34:48 +09:00
Zachary Scott bacb826868 Add build_mrbtest after config block is evaluated
This allows us to add `enable_test` anywhere in a build target,
without having to worry about the order in which they are included.

Previously, there was a bug that occured when adding 'mruby-test' gem
to dependencies before additional gems.

Instead of adding the 'mruby-test' gem dependency manually to a test build,
we now only need to call `enable_test` in the target. This also allows us to
call `test_enabled?` downstream when running mruby tests ourselves.

/cc #2924
2015-09-03 01:02:53 -04:00
Yukihiro "Matz" Matsumoto 402890d571 Merge pull request #2938 from Mav7/master
Added version.h.md and re.h.md
2015-09-03 13:01:01 +09:00
Ralph Desir 79aa0866ce Added reg.h markdown. 2015-09-02 18:57:00 -04:00
Ralph Desir(Mav7) 1bd5c48596 Added regular expression header markdown. 2015-09-02 18:52:16 -04:00
Ralph Desir 6beae5ec71 Created version.h markdown. 2015-09-02 18:45:03 -04:00
Ralph Desir(Mav7) da0dc6937d doc/api/mruby/version.h.md 2015-09-02 18:19:53 -04:00
Yukihiro "Matz" Matsumoto cc0b28373a clear DUMP_ENDIAN flags before setting 2015-09-03 01:46:35 +09:00
Yukihiro "Matz" Matsumoto 7b5f8b0728 remove trailing spaces from bc9c47d5 2015-09-03 01:39:17 +09:00
Yukihiro "Matz" Matsumoto c6aa87c837 Merge pull request #2924 from zzak/mruby-test
Extract mrbtest to binary gem
2015-09-03 00:43:21 +09:00
Yukihiro "Matz" Matsumoto e35c3aff83 unsigned long may be smaller than mrb_int; use uint64_t instead; fix #2935 2015-09-03 00:14:37 +09:00
Yukihiro "Matz" Matsumoto 3a462fe468 Integer << and >> to use Float instead of raising RangeError 2015-09-02 23:41:51 +09:00
Zachary Scott 87564dc98f Make travis happy
We have do this because mruby's test files are found using MRUBY_ROOT, like this:
    mrbs = Dir.glob("#{MRUBY_ROOT}/test/t/*.rb")
2015-09-02 09:56:27 -04:00
Yukihiro "Matz" Matsumoto 74696ffd96 Float << and >> should be more compatible to Fixnum 2015-09-02 22:29:01 +09:00
Yukihiro "Matz" Matsumoto 6ddd79fd0e ensure must not be called before rescue; fix #2933 2015-09-02 21:46:51 +09:00
Yukihiro "Matz" Matsumoto a8c5df2442 Merge pull request #2934 from zzak/master
Typo in mruby-bin-debugger/mrbgem.rake
2015-09-02 15:11:17 +09:00
Yukihiro "Matz" Matsumoto 6b32fa676f Merge pull request #2932 from jbreeden/cpp11_compatibility_fix
C++11 Build Error: C++11 requires a space between literal and identifiers
2015-09-02 15:10:51 +09:00
Yukihiro "Matz" Matsumoto 14f0e4a4e4 update string.h.md; ref #2931 2015-09-02 15:09:50 +09:00
Yukihiro "Matz" Matsumoto 7ce5b21c1d Merge pull request #2931 from Mav7/master
Updated string.h.md
2015-09-02 15:08:06 +09:00
Zachary Scott c0ff5b475f Typo in mruby-bin-debugger/mrbgem.rake 2015-09-01 23:43:36 -04:00
jbreeden 5ed13da7d6 C++ 11 requires a space between literal and identifiers 2015-09-01 18:12:53 -07:00
Zachary Scott 80598f40bf mruby-test should be opt-in 2015-09-01 20:54:27 -04:00
Seba Gamboa 63d2d192a1 Expose MRuby source as a gem 2015-09-01 18:45:53 -03:00
Ralph Desir 8ad8c547dd Update string.h.md 2015-09-01 13:50:27 -04:00
Yukihiro "Matz" Matsumoto 64d7dec457 Merge pull request #2930 from suzukaze/version2
Refactor version macros, and add a global const variable
2015-09-01 15:01:03 +09:00
Jun Hiroe e9b4cb11cf Add a global const variable MRUBY_RELEASE_NO 2015-09-01 13:55:08 +09:00
Jun Hiroe a2385c05f5 Refactor version.h macros 2015-09-01 13:54:52 +09:00
Yukihiro "Matz" Matsumoto 87f1281cec Merge pull request #2929 from Mav7/master
C string.h API documentation.
2015-09-01 12:45:23 +09:00
Yukihiro "Matz" Matsumoto 9257ee6433 Merge pull request #2927 from hone/bintest_subfolders
run bintests within subfolders of bintest/
2015-09-01 12:41:07 +09:00
Ralph Desir d78d001734 Update string.h.md 2015-08-31 23:16:45 -04:00
Terence Lee b432f12fdd run bintests within subfolders of bintest/ 2015-08-31 18:54:42 -04:00
Ralph Desir 00dd2dfa39 Update string.h.md 2015-08-31 14:11:17 -04:00
Ralph Desir a2f6152be8 Update string.h.md 2015-08-30 23:55:55 -04:00
Ralph Desir(Mav7) 0f2b3643ba Added string markdown. 2015-08-30 20:20:45 -04:00
Yukihiro "Matz" Matsumoto 43b93126e7 Merge pull request #2925 from suzukaze/test-string-freeze
Add String#freeze test
2015-08-27 21:55:45 +09:00
Jun Hiroe 69e835cd0f Add String#freeze test 2015-08-27 21:44:56 +09:00
Yukihiro "Matz" Matsumoto 1a45447b8b add String#freeze to the core 2015-08-27 17:54:30 +09:00
Tomoyuki Sahara 5fa3c39145 variables are not used on the platforms lack FD_CLOEXEC. 2015-08-27 09:56:17 +09:00
Tomoyuki Sahara 6c4d39412f Merge pull request #30 from ksss/cloexec
Opened fd should be set FD_CLOEXEC by default
2015-08-26 17:37:21 +09:00
Zachary Scott 133d57cb0d Add mruby-test build config and update :test task to use mrbgem binary
Removed old mrbgems_test.rake which was merged into mrbgem spec
2015-08-22 10:21:52 -04:00
Zachary Scott c7d0f8ebcb Refactor test/mrbtest.rake and tasks/mrbgems_test.rake into mrbgem.rake 2015-08-22 10:20:15 -04:00
Zachary Scott 383a7d24d3 Move test source code and rake task to mrbgem 2015-08-22 10:18:12 -04:00
Yukihiro "Matz" Matsumoto 87e11676b3 Merge pull request #2923 from yasuyuki/nil
Use #nil? instead of == nil.
2015-08-22 21:20:36 +09:00
Yukihiro "Matz" Matsumoto fd2f2f28de Merge pull request #2922 from gkta/refactor-mrubygem-code
Refactor mrubygem code (range.rb, numeric.rb, string.rb, array.rb, enum.rb)
2015-08-22 21:19:34 +09:00
INOUE Yasuyuki 0d055559f1 Use #nil? instead of == nil. 2015-08-22 19:57:11 +09:00
go.kikuta 85f0dd7da0 enum.rb: refactor code (remove redundant code) 2015-08-21 14:56:49 +09:00
go.kikuta 931a7223e6 array.rb: refactor (use onliner code if possible) 2015-08-21 14:56:49 +09:00
go.kikuta 11524f6f67 string.rb: refactor code (remove redundant code) 2015-08-21 14:54:01 +09:00
go.kikuta cb870de2b5 numeric.rb: refactor code (Avoid using {...} for multi-line blocks, Surrounding space missing in default value assignment) 2015-08-21 14:54:00 +09:00
go.kikuta cf588bd5cb range.rb: refactor code (use ! instead of not, use favor modifier if and unless usage when having a single-line body) 2015-08-21 14:54:00 +09:00
Tomoyuki Sahara 042e4a4313 Merge pull request #43 from jkutner/master
Made FILE_SEPERATOR platform dependent
2015-08-21 09:20:32 +09:00
Joe Kutner 2467332c93 Made FILE_SEPERATOR platform dependent 2015-08-20 07:22:48 -05:00
Yukihiro "Matz" Matsumoto 71f2975a5b Merge pull request #2921 from gkta/refactor-array
array.rb: refactor some code
2015-08-20 13:18:05 +09:00
go.kikuta c326f065e1 array.rb: refactor some code 2015-08-19 16:17:06 +09:00
Yukihiro "Matz" Matsumoto 05625cd658 Merge pull request #2920 from cremno/fix-irep-float-dump-format-string-for-mrb_use_float
irep dump: fix format string for MRB_USE_FLOAT
2015-08-18 04:09:07 +09:00
Yukihiro "Matz" Matsumoto 15f2787033 Merge pull request #2919 from cremno/delete-duplicate-definition-of-exception-exception
delete duplicate definition of Exception.exception
2015-08-18 04:08:42 +09:00
cremno eec00ccf60 delete duplicate definition of Exception.exception
It overwrote the original definition in src/error.c, line 446.
2015-08-17 20:51:25 +02:00
cremno ad50a6c410 fix irep float dump format string for MRB_USE_FLOAT
IEC 60559 single format has 6 to 9 significant decimal digits precision.

However the printf conversion specifier e (and E, of course) already
writes 1 digit - the one before the decimal point - and precision
specifies the number of digits to write after the decimal point.
2015-08-17 20:39:24 +02:00
felixjones 8e72558bac Added mrb_get_argc and mrb_get_mid 2015-08-16 23:41:21 +01:00
Yukihiro "Matz" Matsumoto a1731254be Merge pull request #2913 from gkta/remove-duplicate-len-check
Remove duplicated RARRAY_LEN check in ary_elt
2015-08-12 12:11:43 +09:00
go.kikuta c7fad5aa33 Remove duplicated RARRAY_LEN check 2015-08-12 10:20:55 +09:00
Tomoyuki Sahara efaf74672e Merge pull request #42 from hone/path_separator
define PATH_SEPARATOR
2015-08-12 09:06:34 +09:00
Yukihiro "Matz" Matsumoto 1fd9dca510 Merge pull request #2912 from gkta/remove-nonneed-tmp-value
Remove non-need tmp value in mrb_obj_to_sym
2015-08-11 19:24:36 +09:00
go.kikuta 96c948d812 Remove non-need tmp value 2015-08-11 18:02:12 +09:00
Yukihiro "Matz" Matsumoto 2574adab48 compiler: allow "class A end" by tweaking the superclass rule like CRuby2.3 2015-08-11 16:27:48 +09:00
Yukihiro "Matz" Matsumoto e4f32ad9ad codegen: don't need to genop(); just update s->iseq directly 2015-08-10 15:19:32 +09:00
Yukihiro "Matz" Matsumoto dfaff83eba codegen: add peep hole optimization to skip overridden OP_MOVE 2015-08-10 15:11:00 +09:00
Yukihiro "Matz" Matsumoto b34ee9a4b4 codegen: reserve stack region for OP_APOST; fix #2824 2015-08-10 14:55:48 +09:00
Yukihiro "Matz" Matsumoto 5af770cd59 prevent out-of-bounds ensure clause access; fix #2910 2015-08-10 11:41:01 +09:00
Tomoyuki Sahara 5323498033 Merge pull request #23 from expeditiousRubyist/master
Changed Windows IO overrides to use sysread and syswrite instead
2015-08-10 10:36:14 +09:00
Yukihiro "Matz" Matsumoto 0c7d29dff6 FIXABLE() may work wrong on MRB_INT64; fix #2909 2015-08-07 15:30:52 +09:00
Tomoyuki Sahara e8efd10bd9 make pack_l simpler. 2015-08-07 11:51:01 +09:00
Tomoyuki Sahara 4603047eb1 update installation procedure. 2015-08-07 11:49:56 +09:00
Tomoyuki Sahara 359d2ae6fd support "q" and "Q". closes #7. 2015-08-07 11:48:45 +09:00
Tomoyuki Sahara d34db58797 implicit type conversion caused unexpected result. fixes #8. 2015-08-06 15:38:35 +09:00
Yukihiro "Matz" Matsumoto 4fdf492219 add String#setbyte and String#byteslice to mruby-string-ext 2015-08-05 11:28:41 +09:00
Yukihiro "Matz" Matsumoto 6f745e211f Merge pull request #2908 from BanzaiMan/ha-feature-containers
Add build on Trusty and OS X
2015-08-04 11:03:27 +09:00
Hiro Asari bfcc55fbf9 Try building on Xcode 6.4
The default 6.1 was slow
2015-08-03 20:34:45 -04:00
Hiro Asari e3361fbc2a Add OS X build to the matrix 2015-08-03 20:25:35 -04:00
Hiro Asari fca9522af3 Build matrix of size 2 2015-08-03 19:55:44 -04:00
Hiro Asari dd612950b4 Update package list 2015-08-03 19:47:49 -04:00
Hiro Asari 996d0c0345 Set language, and use the new Trusty env 2015-08-03 19:22:46 -04:00
Yukihiro "Matz" Matsumoto 65066f1799 Merge pull request #2907 from hone/path
be able to source with :path for mrbgems
2015-08-03 21:20:57 +09:00
unknown c43a08314e Changed IO overrides to use sysread and syswrite instead of read and write 2015-08-03 04:12:10 -07:00
Yukihiro "Matz" Matsumoto 95412aeb50 better hash value from enumerables; fix #2906 2015-08-03 13:24:04 +09:00
Terence Lee ec4982b2d3 define PATH_SEPARATOR 2015-08-02 17:35:07 +02:00
Terence Lee 5c055d670a be able to source with :path for mrbgems 2015-08-02 15:03:12 +02:00
Yukihiro "Matz" Matsumoto 52a9712c26 link libncurses when there's /usr/include/curses.h; fix #2905 2015-08-01 16:16:22 +09:00
Yukihiro "Matz" Matsumoto f0040b5371 vm: execute ensure without exception at the top of the fiber; fix #2904 2015-07-30 16:46:31 +09:00
Yukihiro "Matz" Matsumoto 89ebb0c4f1 vm: execute ensure at the top of the fiber; fix #2903 2015-07-30 16:45:31 +09:00
Yukihiro "Matz" Matsumoto 5b11d519d8 Merge pull request #2901 from cremno/fix-ruby-bug-11380
pop cmdarg in lambda body; fix [ruby-bug#11380]
2015-07-30 10:45:36 +09:00
cremno 1a98512831 always call frexp() instead of frexpl()
No values that can only be represented as long double
are passed since mrb_float is either float or double.
2015-07-29 21:05:33 +02:00
cremno ca49936468 pop cmdarg in lambda body; fix [ruby-bug#11380]
regression introduced by 2fe556d9c0
2015-07-29 20:52:32 +02:00
Yukihiro "Matz" Matsumoto 0da057d99c Merge pull request #2900 from joans321/enhance-mrbgem-build
mrbgem compile should be depend on mrbgem.rake
2015-07-29 11:44:23 +09:00
Yukihiro "Matz" Matsumoto 8f3f731589 Merge pull request #2899 from zzak/shallow-clone-mgem
Shallow clone mgem source
2015-07-29 11:41:32 +09:00
Tomoyuki Sahara 8527c78fb5 Merge pull request #22 from Asmod4n/master
added SO_NOSIGPIPE
2015-07-28 09:00:31 +09:00
Zachary Scott 923e04cf50 Shallow clone mgem source 2015-07-27 17:16:37 -04:00
Asmod4n 2929c629d4 added SO_NOSIGPIPE 2015-07-27 18:42:22 +02:00
Yukihiro "Matz" Matsumoto 1a8843d3de Merge pull request #2898 from joans321/update-mrbgems-doc
update mrbgems doc
2015-07-27 18:17:00 +09:00
xuejianqing 578db292fd mrbgem compile should be depend on mrbgem.rake 2015-07-27 12:22:23 +08:00
xuejianqing 54c853ff4a update mrbgems doc 2015-07-26 21:52:56 +08:00
Yukihiro "Matz" Matsumoto c9168341bf Merge pull request #2897 from joans321/fix-android-gcc-version
fix android compile bug : uninitialized constant GCC_VERSION
2015-07-26 21:08:24 +09:00
Tomoyuki Sahara de60400c64 Merge pull request #21 from expeditiousRubyist/master
Added functioning read for Win32
2015-07-25 20:09:20 +09:00
xuejianqing 007d26f168 fix android compile bug : uninitialized constant GCC_VERSION 2015-07-25 18:43:27 +08:00
Rubyist f80a4fd0e8 Added functioning read for Win32 2015-07-25 00:24:31 -07:00
Tomoyuki Sahara 2d1134e9ea Merge pull request #41 from hone/cross_compile_windows
support for crossbuild for windows (32 bit and 64 bit) using mingw
2015-07-24 09:19:56 +09:00
Terence Lee fe7784efb0 support for crossbuild for windows (32 bit and 64 bit) using mingw 2015-07-23 12:39:05 -05:00
Yukihiro "Matz" Matsumoto 156dd27f88 Merge pull request #2896 from sagmor/custom-gcc-version
Add ability to change compiler versions for androideabi
2015-07-23 14:41:53 +09:00
Seba Gamboa f01704477f Add ability to change compiler versions for androideabi 2015-07-22 21:57:20 -03:00
Tomoyuki Sahara bfb9cf7922 Merge pull request #20 from expeditiousRubyist/master
Win32 Port
2015-07-22 09:35:39 +09:00
Rubyist 4ab922044d Removed unnecessary/incorrect use of sizeof(int) and corrected more
improper usages of mrb_sys_fail
2015-07-21 15:56:27 -07:00
Rubyist 7ee9ab89f9 Changed some uses of mrb_sys_fail to instead use mrb_raise where
appropriate
2015-07-21 03:37:28 -07:00
Yukihiro "Matz" Matsumoto 0f5386db2e Merge pull request #2894 from suzukaze/fix-docs
Fix indents; Indent is two spaces; Delete tabs [skip ci]
2015-07-20 11:15:48 +09:00
Jun Hiroe 18a0900a82 Fix indents; Indent is two spaces; Delete tabs [skip ci] 2015-07-19 23:04:13 +09:00
Rubyist a426f0e2b5 Overrided close and write to work on Win32 platforms 2015-07-18 23:22:57 -07:00
Yukihiro "Matz" Matsumoto 4ebe94725c Merge pull request #2892 from Mav7/master
Added documentation for hash.
2015-07-18 16:19:27 +09:00
Rubyist 752f7c1526 Minimal semi-working compile on Windows platforms. 2015-07-17 23:45:02 -07:00
Rubyist 7d8cbf1a9c Added Winsock 2 to list of libraries to use when building for Windows
targets
2015-07-17 23:03:34 -07:00
Ralph Desir(Mav7) 6619dc4d75 Deleted range and string markdowns for now. 2015-07-17 14:43:55 -04:00
Ralph Desir f282d94793 Update hash.h.md 2015-07-17 14:25:15 -04:00
Ralph Desir 78a40fce88 Update hash.h.md 2015-07-17 14:21:13 -04:00
Yukihiro "Matz" Matsumoto 34fc856a45 Merge pull request #2890 from jbreeden/sub_pattern_not_found
Don't crash if pattern not found for sub
2015-07-17 11:37:30 +09:00
Jared Breeden 08c12ab7bf Don't crash if pattern not found for sub 2015-07-16 15:33:07 -07:00
Corey Powell 26bee4a16b Added mrb_prepend_module to mruby header 2015-07-16 15:25:27 -05:00
Corey Powell ae1ece7228 Make include_module_at static
Since I can't forsee any reason to use it directly inplace of using
prepend/include
2015-07-16 15:25:14 -05:00
Yukihiro "Matz" Matsumoto 6c94b2d963 Merge pull request #2889 from takkaw/fix_build_cygwin64
64bit Cygwin also doesn't have frexpl(3)
2015-07-16 21:56:38 +09:00
Yukihiro "Matz" Matsumoto 4f37adfd5e Merge pull request #2887 from cremno/use-mrb_str_cat_str-instead-of-mrb_str_append
use mrb_str_cat_str() instead of mrb_str_append()
2015-07-16 21:56:00 +09:00
Yukihiro "Matz" Matsumoto 31d085e795 Merge pull request #2888 from cremno/delete-non-nullptr-checks-before-mrb_free()-calls
delete mrb_free()-related non-NULL checks
2015-07-16 21:55:27 +09:00
takkaw 67e187f0f8 64bit Cygwin also doesn't have frexpl(3) 2015-07-16 18:40:07 +09:00
cremno 0f284091d1 delete mrb_free()-related non-NULL checks
No need to optimize since a program only exits once and errors are rare.
Also the mruby source code doesn't have these kind of checks elsewhere.

The ones in {Time,Random}#initialize are kept because there it actually
matters
since initialization always happens and re-initialization is unlikely.
2015-07-16 04:58:21 +02:00
cremno 938ed044f4 use mrb_str_cat_str() instead of mrb_str_append()
If the argument is always a string, then mrb_str_cat_str() can be
directly called instead of indirectly by mrb_str_append().

mrb_any_to_s(), mrb_obj_as_string(), mrb_inspect() always return a
string.
2015-07-16 03:56:31 +02:00
Corey Powell 667f7788db Renamed MRB_FLAG_IS_INSTANCE to MRB_INSTANCE_TT_MASK 2015-07-15 07:27:31 -05:00
Yukihiro "Matz" Matsumoto 207577f0af mrb_protect() to return the exception raised (with the state of true) 2015-07-15 14:47:15 +09:00
Yukihiro "Matz" Matsumoto 1085167fef add an small comment description in mruby/error.h header 2015-07-15 14:47:15 +09:00
Yukihiro "Matz" Matsumoto c0bf76d0a1 remove unused variable declaration 2015-07-15 14:47:15 +09:00
take_cheeze f6b5a82972 Use class array instead of variadic. 2015-07-15 14:47:15 +09:00
take_cheeze cdd72d9c37 Implement mrb_protect, mrb_ensure, mrb_rescue, mrb_rescue_exceptions.
(`mrb_rescue_exceptions` is mruby implementation of `rb_rescue2`.)
Closes #2844, closes #2837.
2015-07-15 14:46:56 +09:00
take_cheeze 2e4bc2de88 Refactor Build#compile_as_cxx. 2015-07-15 14:46:56 +09:00
Corey Powell dbbf2e2623 Remove non-applicable "hack" comment 2015-07-14 14:12:23 -05:00
Corey Powell eb172c28d7 Applied gc patch to fix ORIGIN ICLASS method table leak
Based on the gc patch by ko1

https://github.com/ruby/ruby/commit/5922c954614e5947a548780bb3b894626affe6dd
2015-07-14 09:44:04 -05:00
Corey Powell f0e920baf0 Renamed parameters in include_module_at 2015-07-14 08:55:53 -05:00
Yukihiro "Matz" Matsumoto 69a2c5cc73 Merge pull request #2884 from jbreeden/doc_bang_modifier
Doc bang modifier
2015-07-14 15:32:47 +09:00
jbreeden e92da7b76c Fix typo 2015-07-13 23:26:29 -07:00
jbreeden 510e53d89f Add ! documentation to mruby.h.md 2015-07-13 23:21:19 -07:00
Yukihiro "Matz" Matsumoto 53a81da0fa mrb_get_args: improve function description about ! 2015-07-14 13:35:06 +09:00
Yukihiro "Matz" Matsumoto 4e7050fe0c mrb_get_args: allow d! 2015-07-14 13:34:21 +09:00
Yukihiro "Matz" Matsumoto a075498613 mrb_get_args: allow A,H,s,z,a,d specifiers to take ! to accept nil.
S,A,H gives nil, s,z,a,d gives NULL for nil argument. ref 02474da
2015-07-14 13:22:42 +09:00
Blaž Hrastnik 78462c9181 Clean up tests 2015-07-13 23:46:41 +02:00
Blaž Hrastnik 8c4da7accd assert() cannot be nested 2015-07-13 23:38:37 +02:00
Blaž Hrastnik 8c13e2b7c6 Set origin when doing kind_of? comparisons 2015-07-13 23:35:30 +02:00
Blaž Hrastnik b0fb9ccfd8 Enable test_prepend_module_ancestors because it seems to pass. 2015-07-13 23:25:01 +02:00
Corey Powell 11cb41770d Space out test_prepend_super_in_alias assert
Also tried to fix it, however the problem lies with how aliased methods
are done and their internal structure.

mruby simply aliases methods by grabbing the RProc and giving it a new name,
super then determines the original method to call by using the name

so a method called m, aliased as m2, will call the m2 super method instead of m
2015-07-13 10:45:57 -05:00
Corey Powell 81a2b3431c included_modules, origin fix
Prepended modules would include their origin ICLASS
2015-07-13 09:49:51 -05:00
Corey Powell 199a808e36 Bugfix, included_modules would include classes 2015-07-13 09:49:18 -05:00
Corey Powell 1f678a4ace Removed comment beside method_removed
Not sure if this apart of the ISO standard, so make sure its not misrepresented
2015-07-13 09:40:40 -05:00
Corey Powell 668153092f Added Module#method_removed hook 2015-07-13 09:38:24 -05:00
Blaž Hrastnik 11dad71578 Enable visibility prepend tests again 2015-07-13 14:04:43 +02:00
Blaž Hrastnik a725cb9093 Include prepended methods in the instance_methods list. 2015-07-13 14:04:43 +02:00
Corey Powell 47264bf289 Ported all MRI prepend tests
And of course, some of them fail miserably
2015-07-13 14:04:42 +02:00
Corey Powell 319553f0ef Removed some debug prints from the test 2015-07-13 14:04:42 +02:00
Corey Powell 99aff17075 Ported a bit more of the MRI Module#prepend tests over
Currently kind_of fails miserably, still looking for the reason
2015-07-13 14:04:42 +02:00
Corey Powell d4b009b394 Fixed Modules not being fully initialized before #initialize was called 2015-07-13 14:04:42 +02:00
Corey Powell 40f48034d5 Added changed check to the mrb_include_module 2015-07-13 14:04:42 +02:00
Corey Powell ce66727177 Remove some remnant debug code 2015-07-13 14:04:42 +02:00
Corey Powell 005cacf18b Additional patches to make this work 2015-07-13 14:04:42 +02:00
Blaž Hrastnik 97529c2a9a Comment in a refactor to match MRI, but that fails 320 tests. 2015-07-13 14:04:42 +02:00
Blaž Hrastnik 2e617e37e1 origin must be initialized 2015-07-13 14:04:42 +02:00
Blaž Hrastnik ad9f32c5a8 Expose insert position, which should be at origin for include and klass for
prepend.
2015-07-13 14:04:42 +02:00
Blaž Hrastnik d046814d8b Rename classes because of conflicts 2015-07-13 14:04:42 +02:00
Blaž Hrastnik f962890a92 Implement Module#prepend. 2015-07-13 14:04:42 +02:00
Yukihiro "Matz" Matsumoto d0e67aada7 use "S!" specifier of mrb_get_args() to improve #2882 fix. 2015-07-13 11:18:44 +09:00
Yukihiro "Matz" Matsumoto 02474daa14 allow '!' after 'S' specifier of mrb_get_args() that allow nil.
thus "S!" means String|nil type. you have to check nil before
dereferencing the value.  this is added to address #2882 while
keeping code simplicity. besides that current #2882 fix lose
polymorphism provided by mrb_get_args().
2015-07-13 11:14:50 +09:00
Yukihiro "Matz" Matsumoto 9c311ddc93 refactor mrb_bob_missing to share raising NoMethodError code; fix #2878
Note: arguments of mrb_no_method_error() has changed. You need to replace
3rd and 4th argument (say n, argv) to mrb_ary_new_from_values(mrb, n, argv).
2015-07-13 11:07:59 +09:00
Yukihiro "Matz" Matsumoto 4dac03cb2d Merge pull request #2883 from jbreeden/array_join_nil
Patching array join
2015-07-12 22:42:18 +09:00
jbreeden dd558a108d Removing unndeeded to_s 2015-07-11 21:15:33 -07:00
jbreeden bdbd696c48 Patching array join 2015-07-11 21:03:04 -07:00
Yukihiro "Matz" Matsumoto 39dd182244 Merge pull request #2880 from mattn/llround
implement llround. some platform (ex: mingw32) doesn't have llround.
2015-07-09 14:57:29 +09:00
Yasuhiro Matsumoto 1167fd1ae4 use round for llround. some platform (ex: mingw32) doesn't have llround. 2015-07-09 11:02:34 +09:00
Ralph Desir 82380780db Update hash.h.md 2015-07-08 05:35:37 -04:00
Mav7 2523ed473a Added new markdowns. 2015-07-08 04:50:01 -04:00
Yukihiro "Matz" Matsumoto 40252169fc method_missing definition may be undefined; fix #2878 2015-07-07 10:32:54 +09:00
Yukihiro "Matz" Matsumoto 5cfc0d0dc0 Merge pull request #2877 from cremno/fix-dangling-ptr
Coverity: fix dangling pointer
2015-07-07 07:40:38 +09:00
Yukihiro "Matz" Matsumoto 5daabc9407 Merge pull request #2876 from joans321/master
fix androideabi cross-compile error : undefined reference to 'frexpl'
2015-07-07 00:36:51 +09:00
Yukihiro "Matz" Matsumoto f1c6d6c866 Merge pull request #2875 from davydovanton/doc-comment-typo
Fix typo in comment in String#mrb_cstr_to_inum
2015-07-07 00:34:03 +09:00
xuejianqing 0b50b4a500 fix androideabi cross-compile error : undefined reference to 'frexpl' 2015-07-06 12:51:57 +08:00
Anton Davydov 03ae38df4e Fix typo in comment in String#mrb_cstr_to_inum [skip ci] 2015-07-05 13:53:14 +03:00
Yukihiro "Matz" Matsumoto e690e1e877 Merge pull request #2871 from archSeer/patch-2
Fix incorrect memory allocation of mrdb_state_new.
2015-07-03 15:05:29 +09:00
Yukihiro "Matz" Matsumoto 1dbb2b74d3 Merge pull request #2874 from cremno/fix-parser-oob-write
Coverity: fix oob write by actually truncating buffer
2015-07-03 15:03:45 +09:00
Yukihiro "Matz" Matsumoto b071dcd4fb Merge pull request #2873 from cremno/fix-coverity-missing-break-in-switch
Coverity: fix missing break in switch defects
2015-07-03 15:03:01 +09:00
cremno 7206a8c4f9 fix dangling pointer
CID 75872 (#3-2 of 3): Pointer to local outside scope (RETURN_LOCAL)
38. use_invalid: Using p, which points to an out-of-scope variable buf.
2015-07-03 02:48:22 +02:00
Tomoyuki Sahara 1b5c68567e Merge pull request #40 from archSeer/patch-1
Remove mrb_io_s_select typo.
2015-07-03 09:36:49 +09:00
cremno 24583a7a18 fix oob write by actually truncating buffer
Found by Coverity scan of polyfox-moon:
CID 121927 (#1 of 1): Out-of-bounds write (OVERRUN)
2015-07-03 01:30:54 +02:00
cremno 43df1d7e39 remove unnecessary default case 2015-07-03 01:14:06 +02:00
cremno 6a74b8bf0d add missing fall through comments 2015-07-02 22:11:21 +02:00
Blaž Hrastnik 8da787be72 Remove mrb_io_s_select typo.
Uncovered with a Coverity scan of our project using mruby-io. https://scan8.coverity.com/reports.htm#v26153/p11375/fileInstanceId=6844382&defectInstanceId=2515905&mergedDefectId=121921
2015-07-02 21:02:56 +02:00
Blaž Hrastnik a4f63caa79 Fix incorrect memory allocation of mrdb_state_new.
As detected in a Coverity scan. https://scan8.coverity.com/reports.htm#v26153/p11375/fileInstanceId=6844472&defectInstanceId=2516000&mergedDefectId=75866
2015-07-02 20:47:22 +02:00
Yukihiro "Matz" Matsumoto ff49cf95fc Merge pull request #2869 from cremno/refactor-print.c
src/print.c: rewrite printstr() to get rid of code duplication
2015-07-01 08:47:41 +09:00
Yukihiro "Matz" Matsumoto 18c82d5359 Merge pull request #2868 from sgnr/avoid-narrowing-cast-in-flo-round
Avoid a narrowing cast in flo_round under MRB_INT64.
2015-07-01 08:43:49 +09:00
Simon Génier d6865a9cc7 Avoid a narrowing cast in flo_round under MRB_INT64. 2015-06-29 20:19:19 -04:00
Yukihiro "Matz" Matsumoto 1c2fc94c20 Merge pull request #2867 from kou/proc-fix-gc-crash
Fix a crash bug when GC is ran while creating a proc with env
2015-06-29 18:33:46 +09:00
Kouhei Sutou 52db92de53 Fix a crash bug when GC is ran while creating a proc with env
mrb_proc_new_cfunc_with_env() allocates RProc with RProc::env as NULL
then allocates REnv and sets it to RProc::env of the allocated RProc. If
incremental GC is ran before "allocates REnv and sets it to RProc::env
of the allocated RProc", the allocated RProc's GC status is
"marked" (Black) and the allocated REnv's GC status is
"unmarked" (White). The next incremental GC sweeps the allocated REnv
without re-marking the allocated RProc. Because the RProc is Black and
the REnv is White.

We need to implement write barrier for the case.

We can force to cause the above situation by the following patch:

    diff --git a/src/proc.c b/src/proc.c
    index f98998f..4f4e25c 100644
    --- a/src/proc.c
    +++ b/src/proc.c
    @@ -92,6 +92,7 @@ mrb_proc_new_cfunc_with_env(mrb_state *mrb, mrb_func_t func, mrb_int argc, const
       struct REnv *e;
       int i;

    +  mrb_incremental_gc(mrb);
       p->env = e = env_new(mrb, argc);
       MRB_ENV_UNSHARE_STACK(e);
       e->stack = (mrb_value*)mrb_malloc(mrb, sizeof(mrb_value) * argc);

With this patch, "rake test" causes segmentation fault.
2015-06-29 14:39:30 +09:00
Yukihiro "Matz" Matsumoto b0ec992d41 Merge pull request #2866 from jurriaan/fix-crash
Fix segfault found using afl-fuzz
2015-06-29 10:27:09 +09:00
Yukihiro "Matz" Matsumoto 96d6e45acd Merge pull request #2863 from suzukaze/fix-typo
Fix typo; Replace extensional with extended
2015-06-29 10:22:28 +09:00
Yukihiro "Matz" Matsumoto a41a649e83 Merge pull request #2862 from scalone/recursive_clone
Add —-recursive option to automatically update submodules from git mgems
2015-06-29 10:21:07 +09:00
Yukihiro "Matz" Matsumoto d671f57305 Merge pull request #2861 from scalone/quotes_use
Fix quotes use during load special path gem of gem.
2015-06-29 10:17:30 +09:00
Yukihiro "Matz" Matsumoto 0e0773c683 Merge pull request #2860 from franckverrot/move-doc
Respect the directory structure of `include`
2015-06-29 10:12:03 +09:00
Jurriaan Pruis a41f5eb23f Fix segfault found using afl-fuzz 2015-06-28 13:46:23 +02:00
Jun Hiroe 4e4929bc72 Rename extended xxxx class or module to xxxx class or module extension 2015-06-28 11:18:52 +09:00
Jun Hiroe c69d1201e1 Fix typo; Replace extensional with extended 2015-06-28 00:05:58 +09:00
Thiago Scalone fa4b88b893 Fix quotes use during load special path gem of gem. 2015-06-26 14:35:34 -03:00
Thiago Scalone 449ec101f6 Add —-recursive option to automatically update submodules from git mgems. 2015-06-26 14:22:09 -03:00
Franck Verrot 427cc64de0 Respect the directory structure of include
As mentioned in the README, two files have been put under the `mruby`
directory.
2015-06-26 14:37:57 +02:00
Yukihiro "Matz" Matsumoto f39a31a623 Merge pull request #2859 from mattn/fix-root
add_dependency doesn't work
2015-06-25 09:57:23 +09:00
Yukihiro "Matz" Matsumoto db7e02cd41 Merge pull request #2858 from franckverrot/remove-unnecessary-backticks
Remove unnecessary backticks
2015-06-25 09:55:25 +09:00
mattn a15e99d2b6 add_dependency doesn't work 2015-06-25 00:19:04 +09:00
Franck Verrot 2588507285 Remove unnecessary backticks.
Dr Markus Kuhn published in 1999 an article [1] explaining in details
why we shouldn't use the ASCII grave accent (0x60) as a left quotation.

Backticks have been used most notably to produce nice-looking LaTeX
documents but it doesn't seem to be an issue on modern platforms and
for the oldest ones, there are workarounds as mentioned by Dr Kuhn.

[1]: https://www.cl.cam.ac.uk/~mgk25/ucs/quotes.html
2015-06-24 13:07:07 +02:00
Yukihiro "Matz" Matsumoto 5161909cd7 Merge branch 'furunkel-deprecated' 2015-06-24 10:05:15 +09:00
Yukihiro "Matz" Matsumoto e88e7dc8db remove deprecated.h 2015-06-24 10:05:05 +09:00
Yukihiro "Matz" Matsumoto 36e010cd75 Merge branch 'deprecated' of https://github.com/furunkel/mruby into furunkel-deprecated 2015-06-24 10:03:44 +09:00
Yukihiro "Matz" Matsumoto fb5af4de2c Merge pull request #2857 from hone/cross_compile_targets
provide targets for building native extensions during CrossBuild
2015-06-24 09:31:22 +09:00
Yukihiro "Matz" Matsumoto acb504fa0d Merge pull request #2853 from jbreeden/alloc_doc
Alloc doc
2015-06-24 09:27:26 +09:00
Terence Lee 0006a8cd4a add host_target/build_target options for CrossBuild'ng native extensions 2015-06-23 13:05:35 -04:00
cremno 6ed64e2367 rewrite printstr() to get rid of code duplication 2015-06-23 12:44:28 +02:00
furunkel e90f0d51a3 Move deprecated macros and functions to dedicated header file 2015-06-23 10:35:02 +02:00
Jared Breeden 18337266f8 Merge branch 'master' of http://github.com/mruby/mruby into alloc_doc 2015-06-22 23:20:24 -07:00
Jared Breeden 9781580c71 Fixes #912 2015-06-22 23:19:58 -07:00
Yukihiro "Matz" Matsumoto 1001be2e99 Merge pull request #2852 from jbreeden/mrb_string_value_cstr_patch
Mrb string value cstr patch
2015-06-23 14:54:13 +09:00
Yukihiro "Matz" Matsumoto 0b720ffa61 Merge pull request #2851 from hone/mruby_compiler
Need mruby-compiler to build mruby-bin-mruby and mruby-bin-mirb for
2015-06-23 14:53:12 +09:00
Yukihiro "Matz" Matsumoto 29a7226d8e Merge pull request #2849 from cremno/proc-curry-should-preserve-lambdas
Proc#curry should preserve lambdas
2015-06-23 14:51:36 +09:00
Yukihiro "Matz" Matsumoto 66a352c836 Merge branch 'cremno-fix-strict-proc-arity' 2015-06-23 14:43:12 +09:00
Yukihiro "Matz" Matsumoto 937b5b5462 fix Proc#curry test failure; ref #2848 2015-06-23 14:42:58 +09:00
Jared Breeden 9ad632559e *Correctly* removing extra mrb_str_to_str call 2015-06-22 20:49:09 -07:00
Jared Breeden cfcca2a727 Reverting overzealous changes 2015-06-22 19:49:12 -07:00
Jared Breeden 264a059aef Removing unneeded bad_checks for verified strings 2015-06-22 19:15:52 -07:00
Jared Breeden 9553e20d34 Removing redundant mrb_str_to_str call 2015-06-22 19:07:25 -07:00
Jared Breeden 338ca305ae Calling mrb_str_to_str in mrb_string_value_cstr. Fixes #2847 2015-06-22 18:37:14 -07:00
Terence Lee 7e087d7191 Need mruby-compiler to build mruby-bin-mruby and mruby-bin-mirb for
cross compiles
2015-06-22 13:01:15 -04:00
cremno 69b4c1648a Proc#curry should preserve lambdas 2015-06-22 16:35:54 +02:00
cremno f0eaf9eaf5 fix arity of lambdas with optional arguments
From the CRuby 2.2.2 Proc#arity documentation:

If the block has optional arguments, returns -n-1, where n is the number
of mandatory arguments, with the exception for blocks that are not
lambdas and have only a finite number of optional arguments; in this
latter case, returns n.
2015-06-22 13:34:24 +02:00
Yukihiro "Matz" Matsumoto e344c6ab6d [ci skip] replace "ignored" by "omitted"; ref #2846 2015-06-22 10:09:04 +09:00
Yukihiro "Matz" Matsumoto c8229dbd19 Merge pull request #2846 from take-cheeze/mgem_mrbgem
Add :mgem gem loading.
2015-06-22 10:04:00 +09:00
take_cheeze 078d24d4d3 Add documentation to new mgem features. 2015-06-22 02:24:15 +09:00
take_cheeze 0c8fa845e4 Load missing dependencies from core or mgem-list. 2015-06-22 02:23:52 +09:00
take_cheeze 8d54977d25 Add :mgem gem loader to load mrbgem from mgem-list ( https://github.com/mruby/mgem-list ). 2015-06-22 02:23:11 +09:00
Yukihiro "Matz" Matsumoto 7cf94bac10 Merge pull request #2842 from davydovanton/doc-fix-old-link
Fix repository link to mruby/mruby
2015-06-20 22:49:21 +09:00
Anton Davydov 111602319b Fix repository link to mruby/mruby [skip ci] 2015-06-20 13:27:36 +03:00
Yukihiro "Matz" Matsumoto 8a5b0433ab Merge pull request #2840 from davydovanton/doc-fix-typos
Fix typos in documentation and error messages
2015-06-19 23:54:20 +09:00
Yukihiro "Matz" Matsumoto a219e8b717 Merge pull request #2839 from yui-knk/fix/string_split_sample
[ci skip] Remove some Srting#split samples
2015-06-19 23:53:49 +09:00
Anton Davydov dcc316d3b8 Fix typos in documentation and error messages [skip ci] 2015-06-19 15:52:23 +03:00
yui-knk d1e6d647bd [ci skip] Remove some Srting#split samples
mruby not support regexp, so remove these samples.
2015-06-19 20:34:32 +09:00
Yukihiro "Matz" Matsumoto 6a796cb4cc Added a check for 64 bit time_t overflow; based on a patch from @kext; close #2836 2015-06-17 09:19:09 +09:00
Yukihiro "Matz" Matsumoto 6dcc3e7383 Merge pull request #2835 from kext/time-rounding-precision
Time rounding precision
2015-06-16 16:36:34 +09:00
Lukas Joeressen 47c61cf502 Changed llrint to llround 2015-06-16 09:24:27 +02:00
Lukas Joeressen 95fa22a65c Rounding errors could make time_alloc imprecise 2015-06-15 15:03:44 +02:00
Yukihiro "Matz" Matsumoto 97a18ff4d9 Merge pull request #2833 from cremno/call-mrb_inspect
refactor code to call mrb_inspect() instead
2015-06-14 21:10:49 +09:00
cremno 5e8d2a4b84 refactor code to call mrb_inspect() instead
mrb_inspect() also calls mrb_obj_as_string() after #inspect to ensure
the mrb_value is a string.
2015-06-13 14:59:57 +02:00
Yukihiro "Matz" Matsumoto d2433a7723 Merge pull request #2830 from hiroshiyui/mirb-termcap-compat
Remove the unused libterminfo detection code.
2015-06-10 16:08:19 +09:00
Huei-Horng Yo 2f4f36b334 Remove unused libterminfo detection code.
The detection code is unused even on OpenBSD 5.7,
because of the standard installation is libtermcap be installed, not libterminfo.

This fixes #2829

Tested on Arch Linux (x86_64) & OpenBSD 5.7 (amd64).

Signed-off-by: Huei-Horng Yo <hiroshi@ghostsinthelab.org>
2015-06-10 12:40:18 +08:00
Yukihiro "Matz" Matsumoto 95cb416852 Merge pull request #2829 from hiroshiyui/mirb-termcap-compat
Detect if ncurses' backend is terminfo or termcap.
2015-06-10 02:51:32 +09:00
Huei-Horng Yo be2c156876 Detect if ncurses' backend is terminfo or termcap. fixes #2662
Borrowed from @mattn's code at:
https://github.com/mruby/mruby/issues/2662#issuecomment-65535705

Signed-off-by: Huei-Horng Yo <hiroshi@ghostsinthelab.org>
2015-06-09 21:07:12 +08:00
Yukihiro "Matz" Matsumoto 5c6de6858e Merge pull request #2828 from iij/pr-string-sub-backslash
gsub/sub supports back references in substitutes.  fixes #2816.
2015-06-08 21:52:52 +09:00
Tomoyuki Sahara 5dd2b8e16f gsub/sub supports back references in substitutes. fixes #2816.
This implementation is compatible with CRuby's String#gsub/sub
except \1 ... \9 and \+.  They are useless without Regexp library.
2015-06-08 17:32:14 +09:00
Yukihiro "Matz" Matsumoto a041162678 Merge pull request #2827 from mruby-debian/fix-upstream
Fix build on MIPS of linux
2015-06-06 19:57:30 +09:00
Yukihiro "Matz" Matsumoto e1b638376f Merge pull request #2826 from Mav7/master
Added some documentation for some of the functions found in array.h.
2015-06-06 19:56:29 +09:00
Nobuhiro Iwamatsu 3bcf570a17 Fix build on MIPS of linux
MIPS of Linux platform is supported frexpl(3).
This fixes to use the frexpl that are provided with gcc if user wants to build
on MIPS of Linux platform.

Signe-doff-by: Nobuhiro Iwamatsu <iwamatsu@nigauri.org>
2015-06-06 09:05:53 +09:00
Ralph Desir 0f93d9b7db Update array.h.md 2015-06-05 02:54:11 -04:00
Ralph Desir e1795cb72d Update value.h.md 2015-06-05 02:51:37 -04:00
Ralph Desir a3a18cd7a6 Update array.h.md 2015-06-05 02:43:54 -04:00
Ralph Desir 12b307396a Added more function documentation for arrays. 2015-06-05 02:42:48 -04:00
Ralph Desir 88342b2709 Update array.h.md 2015-06-05 00:17:42 -04:00
Ralph Desir b9716c59c7 Update array.h.md 2015-06-05 00:05:41 -04:00
Ralph Desir 8a14073207 Update array.h.md 2015-06-04 23:54:27 -04:00
Ralph Desir e63962c0a4 Update array.h.md 2015-06-04 23:53:15 -04:00
Mav7 d768dcc42c Adding an array readme markdown. 2015-06-04 23:49:43 -04:00
Mav7 5d63350a3b testing something. 2015-06-04 23:46:32 -04:00
Ralph Desir b735c0d9df Update README.md 2015-06-04 23:37:41 -04:00
Mav7 cd38bcf074 Adding an array readme markdown. 2015-06-04 23:34:03 -04:00
Yukihiro "Matz" Matsumoto 630c2c5853 Merge pull request #2823 from cremno/remove-unnecessary-mrb_immediate_p
remove unnecessary mrb_immediate_p()
2015-06-03 22:40:43 +09:00
Yukihiro "Matz" Matsumoto ebbc7d0e82 Merge pull request #2822 from cremno/directly-call-ary_new_capa
directly call ary_new_capa()
2015-06-03 22:39:18 +09:00
Yukihiro "Matz" Matsumoto 059da2ad56 Merge pull request #2821 from cremno/push-only-after-op_getconst-in-val-mode
push only after OP_GETCONST in VAL mode
2015-06-03 22:38:32 +09:00
cremno ef0fc90cd0 remove unnecessary mrb_immediate_p()
`!mrb_array_p(ary2)` and `mrb_type(obj) != MRB_TT_DATA` are  sufficient.
2015-06-02 08:56:41 +02:00
cremno 599d141cc8 directly call ary_new_capa() 2015-06-02 08:34:36 +02:00
cremno b721d449e6 push only after OP_GETCONST in VAL mode; ref #2769 2015-06-02 07:57:27 +02:00
Yukihiro "Matz" Matsumoto 2f635f56cb update lex.def using gperf 3.0.4 2015-06-01 21:57:53 +09:00
take_cheeze 6460ef77bc Compile mruby compiler as mrbgem.
Compiler codes is moved to "mruby-compiler".
Executable `mrbc` is moved to "mruby-bin-mrbc".
2015-06-01 21:53:55 +09:00
Yukihiro "Matz" Matsumoto 214bc3c95a Merge pull request #2819 from cremno/only-genop-non-lvar-gets-in-val-mode
only generate gets of non-local vars in VAL mode
2015-06-01 21:40:11 +09:00
Yukihiro "Matz" Matsumoto ddab53e66f Merge pull request #2820 from cremno/add-too-big-array-size-checks
fix two potential cases of signed integer overflow
2015-06-01 21:39:21 +09:00
Yukihiro "Matz" Matsumoto 3739299823 Merge pull request #2818 from Mav7/master
Added more documentation for some of the functions found in mruby.h and value.h
2015-06-01 21:38:37 +09:00
Yukihiro "Matz" Matsumoto b6121adc7d singleton_class should not be duped; fix #2815 2015-06-01 21:30:07 +09:00
cremno 7e8fb15457 only generate gets of non-local vars in VAL mode
This fixes a crash for code like "#{@a;1}".

Unlike CRuby globals are excluded too since mruby doesn't implement
hooking.
2015-06-01 13:54:20 +02:00
cremno dc0e335664 fix two potential cases of signed integer overflow 2015-06-01 13:23:43 +02:00
Ralph Desir b357a6320d Update AUTHORS 2015-06-01 00:59:22 -04:00
Ralph Desir f8b1de0ab4 Update README.md 2015-06-01 00:54:30 -04:00
Ralph Desir 1d90018cfa Update mruby.h.md 2015-06-01 00:44:34 -04:00
Ralph Desir 297b6fe6e6 Update value.h.md
Wrote documentation for functions found in the value.h file.
2015-06-01 00:42:23 -04:00
Mav7 1400c6e88b Added a .md file for value.h 2015-05-31 23:50:56 -04:00
Ralph Desir d90ccd7e6d Update mruby.h.md 2015-05-31 23:33:36 -04:00
Ralph Desir 4959e4958a Update mruby.h.md 2015-05-31 23:27:12 -04:00
Ralph Desir 7284d1d295 Update mruby.h.md
Added documentation of more of the C API functions found inside mruby.h
2015-05-31 23:26:33 -04:00
Yukihiro "Matz" Matsumoto bd2686d82d singleton_class should not be cloned; close #2815 2015-06-01 00:13:12 +09:00
Yukihiro "Matz" Matsumoto c80f500c68 Merge pull request #2814 from cremno/fix-masgn-nosplat-array-rhs-bug
fix masgn nosplat array rhs bug
2015-05-31 22:12:49 +09:00
cremno 5cd877be7f fix masgn nosplat array rhs bug
The rest lhs variable has to be an empty array if rhs is an array with
less elements than pre + post lhs variables. The codegen generated
OP_ARRAY with an invalid length (such as 127 for *a, b = []) because rn
was negative.
2015-05-31 13:30:49 +02:00
Yukihiro "Matz" Matsumoto 6a1978c7e1 fix OP_APOST bug for no pre arg cases; fix #2810 2015-05-31 18:30:37 +09:00
Yukihiro "Matz" Matsumoto 9ef4bbb10d update test/t/syntax.rb to success on CRuby 2015-05-31 18:29:26 +09:00
Yukihiro "Matz" Matsumoto 8dd6b0fd09 Merge branch 'failing-multiple-assignments-with-rest-tests' of https://github.com/cremno/mruby into cremno-failing-multiple-assignments-with-rest-tests 2015-05-31 17:02:45 +09:00
Yukihiro "Matz" Matsumoto b720cb635a Merge pull request #2811 from cremno/check-if-outer-is-a-class-or-module
check if outer is a class or module
2015-05-31 17:01:49 +09:00
Yukihiro "Matz" Matsumoto d9f191cf97 Merge pull request #2809 from cremno/codegen-remove-unreachable-code
codegen: remove unreachable code
2015-05-31 17:00:36 +09:00
cremno 59ea323976 check if outer is a class or module
For modules this check didn't exist yet. Also call #inspect.
2015-05-29 14:58:53 +02:00
cremno ba3a0c22a5 add multiple assignment with rest tests 2015-05-29 12:17:13 +02:00
cremno 2554fd9c94 remove unreachable code
It's just a copy of the code in the previous case (NODE_CALL).
2015-05-29 11:29:11 +02:00
Yukihiro "Matz" Matsumoto b05d736b49 update mrblib/*.rb files to conform (some of) Rubocop checks 2015-05-29 17:01:52 +09:00
Yukihiro "Matz" Matsumoto 13a2cc3e5d Merge pull request #2807 from cremno/fix-capture-group-index-parsing-ub-bug
fix capture group index bug
2015-05-29 02:03:13 +09:00
Yukihiro "Matz" Matsumoto 55fed387a9 Merge pull request #2806 from cremno/simplify-mruby-ctype-macros
mruby.h: simplify ctype-like macros
2015-05-29 02:01:03 +09:00
cremno ce31272dba fix capture group index bug
atoi() is used to convert the index to an int but the behavior is
undefined if the value can't be represented.

> $9999999999
00007 NODE_SCOPE:
00007   NODE_BEGIN:
00007     NODE_NTH_REF: $2147483647
irep 00630580 nregs=2 nlocals=1 pools=0 syms=1 reps=0
file: (mirb)
7 000 OP_GETGLOBAL  R1      :$2147483647
7 001 OP_STOP

Call strtoul() instead as its behavior in such cases is defined and add
a simple range check.

Alternatively NODE_NTH_REF's cdr could be changed from int to mrb_sym
(like NODE_GVAR).
2015-05-28 12:52:44 +02:00
cremno 2ee84eb3df remove unnecessary including of <ctype.h>
Not needed anymore since 85075bef75
2015-05-28 10:44:20 +02:00
cremno 85075bef75 simplify all IS* and TO* macros
Reduces the file size (by up to 2 KB with VS2015 RC, /O2, /MD) and
removes the requirement of including <ctype.h> before their usage.
Multiple macro argument evaluation and lack of type-checking is still an
issue.
2015-05-28 10:20:41 +02:00
cremno cd4cc3bd9d simplify ISASCII() macro 2015-05-28 10:10:05 +02:00
Yukihiro "Matz" Matsumoto b1871cf446 Merge pull request #2804 from take-cheeze/mruby_throw_h
Move "src/mrb_throw.h" to "include/mruby/throw.h".
2015-05-26 23:38:50 +09:00
take_cheeze 6498d90f1b Move "src/mrb_throw.h" to "include/mruby/throw.h".
Related to #2760.
2015-05-25 21:19:24 +09:00
Yukihiro "Matz" Matsumoto f709054910 Merge pull request #2802 from take-cheeze/move_codedump
Move `mrb_codedump_all` to "src/codedump.c".
2015-05-24 01:44:47 +09:00
Yukihiro "Matz" Matsumoto f0424ff308 Merge pull request #2803 from carsonmcdonald/specinheredoc
Add null check on lex_strterm in heredoc block
2015-05-24 01:40:51 +09:00
Carson McDonald 4a791701bc Add null check on lex_strterm in heredoc block 2015-05-23 11:10:10 -04:00
take_cheeze 46e50492eb Move mrb_codedump_all to "src/codedump.c".
Related to #2760.
2015-05-23 17:55:44 +09:00
Yukihiro "Matz" Matsumoto b97c6d10a2 Merge pull request #2801 from carsonmcdonald/fix2779
Add locals null checks
2015-05-23 16:11:22 +09:00
Yukihiro "Matz" Matsumoto a94ff9666e Merge pull request #2800 from carsonmcdonald/proccheck
Verify that proc_lambda is passed a proc
2015-05-23 16:09:54 +09:00
Carson McDonald 3e911a8e14 Add locals null checks 2015-05-22 10:42:50 -04:00
Carson McDonald a797d45e90 Verify that proc_lambda is passed a proc 2015-05-22 10:34:28 -04:00
Tomoyuki Sahara b913e7eefd test suite for pack/unpack. 2015-05-22 11:38:56 +09:00
Tomoyuki Sahara 2ba4933158 refactor "AaZ". fixes #6. 2015-05-22 11:38:39 +09:00
Tomoyuki Sahara 15de80a7cd style. 2015-05-22 09:41:39 +09:00
Yukihiro "Matz" Matsumoto 4f6bae61eb Merge pull request #2799 from iij/pr-remove-useless-conditional-in-split
remove an always-true conditional.
2015-05-22 06:59:13 +09:00
Tomoyuki Sahara 4308f3c686 remove an always-true conditional. 2015-05-21 11:50:02 +09:00
Yukihiro "Matz" Matsumoto b7049b3945 there may be expecting here-doc when we see terminating characters; fix #2780 2015-05-20 19:14:04 +09:00
Yukihiro "Matz" Matsumoto bce3843456 Merge pull request #2797 from iij/pr-split-only-first
String#split fails to split on second or later separator
2015-05-20 15:11:59 +09:00
Yukihiro "Matz" Matsumoto 4996e88602 Merge pull request #2796 from syohex/add-link
Link documents
2015-05-20 15:10:42 +09:00
Yukihiro "Matz" Matsumoto 2e838250a4 Merge pull request #2798 from iij/pr-netbsd
Fix build mruby for NetBSD
2015-05-20 15:02:03 +09:00
Tomoyuki Sahara 486870e353 NetBSD does not have libreadline but readline(3) is in libedit. 2015-05-20 12:43:44 +09:00
Tomoyuki Sahara 48b63b1c7a NetBSD (6.1.5) does not have frexpl(3). 2015-05-20 12:43:10 +09:00
Tomoyuki Sahara dacb8b626b failed to remove temporary files! 2015-05-20 11:38:03 +09:00
Tomoyuki Sahara 64ab781266 RSTRING_PTR may be changed in while loop. 2015-05-20 10:15:19 +09:00
Syohei YOSHIDA b5eb6602b7 Link documents 2015-05-20 10:15:01 +09:00
Yukihiro "Matz" Matsumoto 505c6961dc Merge pull request #2795 from cremno/fix-type-of-mrb_exc_new-s-len-parameter
fix type of mrb_exc_new()'s len parameter
2015-05-19 23:00:43 +09:00
cremno dc479392ef fix type of mrb_exc_new()'s len parameter
mrb_str_new() takes size_t, so should mrb_exc_new().
2015-05-18 22:18:53 +02:00
Yukihiro "Matz" Matsumoto 4ba9c3b733 Merge pull request #2793 from cremno/remove-set_proc_value-macro
remove SET_PROC_VALUE() macro
2015-05-18 10:49:07 +09:00
cremno 4c868a9562 remove SET_PROC_VALUE() macro
It isn't used anymore since the #2791 merge. It's also unlikely to be
needed again as it wasn't before (its usage was unnecessary).
2015-05-17 22:25:55 +02:00
Yukihiro "Matz" Matsumoto 5fa01f4ca3 Merge pull request #2789 from take-cheeze/PR2760_piece
Use `mrb_funcall` instead of `mrb_load_string` in test driver.
2015-05-17 20:43:32 +09:00
Yukihiro "Matz" Matsumoto cf070b64f1 Merge pull request #2792 from cremno/let-the-c-compiler-validate-the-identifier
let the C compiler validate the identifier
2015-05-17 20:42:41 +09:00
Yukihiro "Matz" Matsumoto 0cae5eaf94 Merge pull request #2791 from cremno/remove-mrb_define_method_vm
remove mrb_define_method_vm() function
2015-05-17 20:41:27 +09:00
Yukihiro "Matz" Matsumoto 579ba2d9e4 Merge pull request #2790 from bovi/copyright-2015
Update Coopyright Information to year 2015
2015-05-17 19:59:51 +09:00
cremno 406fb9c809 let the C compiler validate the identifier
Some C compilers may allow other characters in identifiers such as $.
They may also implement C99's extended identifiers (\u30EB\u30D3\u30FC,
ルビー).
2015-05-15 22:41:46 +02:00
cremno 2106d4d446 remove mrb_define_method_vm() function
It isn't needed as it's very similar to mrb_define_method_raw() and also
there's only one place where mrb_proc_ptr() actually has to be called.

Inspired by @furunkel's method cache patch (#2764).
2015-05-15 13:04:55 +02:00
Daniel Bovensiepen 02fffb02d2 Update Coopyright Information to year 2015 2015-05-15 15:12:32 +08:00
take_cheeze ab565f16bc Use mrb_funcall instead of mrb_load_string in test driver.
Related to #2760.
2015-05-15 16:06:03 +09:00
Yukihiro "Matz" Matsumoto bc8308ba8d Merge pull request #2788 from sgnr/dump-without-stdio
Reenable mrb_dump_irep under DISABLE_STDIO.
2015-05-15 09:47:40 +09:00
Simon Génier 1e51517615 Reenable mrb_dump_irep under DISABLE_STDIO. 2015-05-14 15:43:29 -04:00
Yukihiro "Matz" Matsumoto dd3a292a27 Merge pull request #2787 from cremno/remove-unused-token-declarations
remove unused token declarations
2015-05-14 18:52:05 +09:00
cremno 7fe853c216 remove unused token declarations 2015-05-13 18:31:51 +02:00
Yukihiro "Matz" Matsumoto 91ba9ba77b Merge pull request #2786 from furunkel/set_value
Avoid unnecessary stores and reloads
2015-05-13 18:20:02 +09:00
furunkel 99a00cf417 Avoid unnecessary stores and reloads 2015-05-12 13:46:56 +02:00
Yukihiro "Matz" Matsumoto 0628778306 Merge pull request #2785 from bovi/install-doc
Remove INSTALL and improve README instead
2015-05-12 20:00:20 +09:00
Daniel Bovensiepen 691997a447 Remove INSTALL and improve README instead 2015-05-12 18:32:20 +08:00
Yukihiro "Matz" Matsumoto d979172b3e Merge pull request #2784 from cremno/fix-splat-without-assignment
fix splat without assignment
2015-05-08 11:49:49 +09:00
cremno 2aa59393ba fix splat without assignment; fix #2781
The parser generates NODE_NIL for tSTAR without argument in masgns. The
codegen didn't handle that.
2015-05-07 16:58:43 +02:00
Yukihiro "Matz" Matsumoto 4bafd62844 Merge pull request #2782 from cremno/define-yydebug-macro-conditionally
define YYDEBUG macro conditionally
2015-05-07 23:43:09 +09:00
Yukihiro "Matz" Matsumoto d9e37bd729 Merge pull request #2783 from pbosetti/master
Defining static version of frexpl also fro MIPS platforms.
2015-05-07 23:41:46 +09:00
Paolo Bosetti 5e5e129014 Defining static version of frexpl also fro MIPS platforms.
On MIPS/linaro, libm.so lacks frexpl() as CygWin does.
2015-05-07 13:05:25 +02:00
cremno 3cd80a520a define YYDEBUG macro conditionally
The YYDEBUG macro enables parser debugging which
unnecessarily increases the executable size (9 to 10 KB).
Now it only will be defined when PARSER_DEBUG is too.
2015-05-04 16:53:50 +02:00
Yukihiro "Matz" Matsumoto 2fe556d9c0 push cmdarg_stack in lambda body; fix [ruby-bug#11107] 2015-04-30 15:21:01 +09:00
Yukihiro "Matz" Matsumoto b09f1712af Merge pull request #2778 from cremno/fix-load-size-error-macros
src/load.c: fix size error macros
2015-04-30 12:19:09 +09:00
Yukihiro "Matz" Matsumoto 5d0c8a70e9 Merge pull request #2777 from cremno/fix-parser-locals-null-deref
parser: fix possible null dereferences
2015-04-30 12:17:47 +09:00
Yukihiro "Matz" Matsumoto 8d1f9a6ece Merge pull request #2776 from cremno/undef-strndup
prevent accidental macro redefinition of strndup()
2015-04-30 12:17:14 +09:00
Yukihiro "Matz" Matsumoto 1fefa046cd Merge pull request #2774 from cremno/refactor-mrb_read_irep_file
mrb_read_irep_file(): unify error handling / fix uint underflow
2015-04-30 12:16:21 +09:00
cremno c579ab1c8b always define SIZE_ERROR_MUL() macro
Previously there wasn't a way to trigger the useful definition, but it
is needed and that in every case to check for integer overflow due to
multiplication and faulty/modified binary files.

Also change existing code to a calloc()-like parameter order.
2015-04-29 17:00:35 +02:00
cremno aaf2615ed6 remove SIZE_ERROR() macro
It's only used once and in that case it isn't necessary anyway, since
size_t must be at least 32 bits wide and
the max. length of a filename is UINT16_MAX.
2015-04-29 16:41:45 +02:00
cremno 4a82b9391a add more descriptive error message and fail earlier 2015-04-29 16:37:35 +02:00
cremno c18212573c fix null dereference (ref: #2769)
parser_state->locals might be a null pointer.

Fixes (and other similiar invalid code):
def a; Proc.new do def x==x end end
2015-04-28 19:03:58 +02:00
cremno 8789a5d520 prevent accidental macro redefinition of strndup() 2015-04-28 17:51:34 +02:00
cremno 091ce867c1 fix possible unsigned integer underflow
buf_size has to be greater than header_size, otherwise subtracting
header_size from buf_size will cause an integer underflow.

Being equal to header_size is fine, however useless, so quit early.
2015-04-28 15:02:39 +02:00
cremno 0518ab22c4 unify error handling
Convert mrb_read_irep_file() to use goto like read_section_lv() and
read_section_debug() already do.
2015-04-28 14:40:22 +02:00
Yukihiro "Matz" Matsumoto 41e6931987 Merge pull request #2773 from syohex/fix-misspelling
Fix misspellings in document
2015-04-27 21:54:25 +09:00
Syohei YOSHIDA c261c01598 Fix misspellings in document 2015-04-27 09:35:55 +09:00
Yukihiro "Matz" Matsumoto 5c25a9a6a9 C++ compilation failed due to skipping iniitalization by goto out_super 2015-04-27 02:50:42 +09:00
Yukihiro "Matz" Matsumoto f1164487e1 Merge branch 'master' of github.com:mruby/mruby 2015-04-27 00:54:36 +09:00
Yukihiro "Matz" Matsumoto bdb9d4d19c super should not be called outside of a method; fix #2770 2015-04-27 00:53:08 +09:00
Yukihiro "Matz" Matsumoto b3b6fe3c07 parser_state->locals may be NULL on some error conditions; fix #2769 2015-04-27 00:52:53 +09:00
Yukihiro "Matz" Matsumoto ed3a253372 Merge pull request #2772 from furunkel/bench_task
Add rake task for benchmarking
2015-04-25 17:55:34 +09:00
furunkel ed03b17bb4 Remove benchmarks not in mruby 2015-04-24 22:10:11 +02:00
furunkel 6110b385a7 Output PNG instead of PDF 2015-04-24 21:58:27 +02:00
furunkel 105f1f38a9 Add some of MRI's benchmarks 2015-04-24 19:34:39 +02:00
furunkel 00518e0a4b Use separate build config directory for benchmark files 2015-04-24 16:24:31 +02:00
furunkel bb1951a8b6 Include name of current build config in data directory name 2015-04-24 14:54:35 +02:00
furunkel 01ee28d89d Rename 2015-04-24 14:22:43 +02:00
furunkel 8f5ec1a60f Let all benchmarks start with bm_ 2015-04-24 14:19:51 +02:00
furunkel 465d7a23c8 Add build files for benchmarkings; add mandelbrot benchmark 2015-04-24 13:40:54 +02:00
furunkel 96d66f6d24 Don't echo to stdout 2015-04-23 22:34:22 +02:00
furunkel a96b871c46 Add task for running and plotting benchmarks 2015-04-23 22:27:19 +02:00
Yukihiro "Matz" Matsumoto 6246483f12 Merge pull request #2766 from furunkel/builtin_overflow
Use builtins for overflow math if possible
2015-04-19 08:22:48 +09:00
Yukihiro "Matz" Matsumoto 0f31f16015 Merge pull request #2768 from kou/suppress-write-strings-warnings
Suppress warnings generated by -Wwrite-strings
2015-04-19 08:21:51 +09:00
Kouhei Sutou 09419874c8 Suppress warnings generated by -Wwrite-strings
Here are suppressed warnings:

    src/fmt_fp.c: In function 'fmt_fp':
    src/fmt_fp.c:124:16: warning: initialization discards 'const' qualifier from pointer target type
         char *ss = (t&32)?"inf":"INF";
                    ^
    src/fmt_fp.c:125:17: warning: assignment discards 'const' qualifier from pointer target type
         if (y!=y) ss=(t&32)?"nan":"NAN";
                     ^
    mrbgems/mruby-string-ext/src/string.c: In function 'mrb_str_succ_bang':
    mrbgems/mruby-string-ext/src/string.c:302:27: warning: assignment discards 'const' qualifier from pointer target type
           if (e == b) prepend = "1";
                               ^
    mrbgems/mruby-string-ext/src/string.c:305:27: warning: assignment discards 'const' qualifier from pointer target type
           if (e == b) prepend = "a";
                               ^
    mrbgems/mruby-string-ext/src/string.c:308:27: warning: assignment discards 'const' qualifier from pointer target type
           if (e == b) prepend = "A";
                               ^
    mrbgems/mruby-bin-mruby/tools/mruby/mruby.c: In function 'main':
    mrbgems/mruby-bin-mruby/tools/mruby/mruby.c:213:13: warning: assignment discards 'const' qualifier from pointer target type
         cmdline = args.cmdline ? args.cmdline : "-";
                 ^
    mrbgems/mruby-bin-debugger/tools/mrdb/cmdbreak.c: In function 'print_breakpoint':
    mrbgems/mruby-bin-debugger/tools/mrdb/cmdbreak.c:159:3: warning: initialization discards 'const' qualifier from pointer target type
       char* enable_letter[] = {BREAK_INFO_MSG_DISABLE, BREAK_INFO_MSG_ENABLE};
       ^
    mrbgems/mruby-bin-debugger/tools/mrdb/cmdbreak.c:159:3: warning: initialization discards 'const' qualifier from pointer target type
2015-04-18 21:43:58 +09:00
Kouhei Sutou 058dc7bd41 Enable -Wwrite-strings by default for GCC 2015-04-18 21:43:40 +09:00
Tomoyuki Sahara ae4fc77675 Merge pull request #39 from jbreeden/master
Correct File::NULL for Windows
2015-04-18 06:50:32 +09:00
Jared Breeden 6d6be18d4e Removing redundant platform check 2015-04-17 15:45:14 -04:00
Jared Breeden 7f8324a2ed Merge branch 'master' of https://github.com/iij/mruby-io 2015-04-17 15:40:35 -04:00
Jared Breeden 36343cf098 Correct File::NULL for Windows 2015-04-17 15:39:11 -04:00
furunkel 08c877699a Use builtins for overflow math if possible 2015-04-17 17:37:09 +02:00
Yukihiro "Matz" Matsumoto e79afd4c74 Merge pull request #2765 from miura1729/original2
Fix to avoid warning
2015-04-17 23:49:31 +09:00
Miura Hideki eb3af3752f Fix to avoid warning 2015-04-17 20:04:07 +09:00
Yukihiro "Matz" Matsumoto ee59f8b8b2 Merge pull request #2762 from miura1729/original
Add test of negative arguments for Integer#%
2015-04-17 17:49:29 +09:00
Miura Hideki a21d3f627e Add test of negative arguments for Integer#% 2015-04-17 17:26:12 +09:00
Jared Breeden c0738a74c6 Excluding wait call for windows 2015-04-05 17:21:02 -04:00
Tomoyuki Sahara cfbc8a8995 Merge pull request #38 from jbreeden/master
Excluding wait call for windows
2015-04-05 09:23:29 +09:00
Tomoyuki Sahara e92fd76248 wait for child processes when we close pipes. fixes #37. 2015-04-03 10:05:09 +09:00
Yukihiro "Matz" Matsumoto fa824e324b Merge pull request #2755 from Yuuhei-Okazaki/fix_maxbreakpoint_reference
fix maximum value of the index when access breakpoints.
2015-04-03 08:31:37 +09:00
Yukihiro "Matz" Matsumoto d77249f006 Merge pull request #2754 from cremno/remove-unnecessary-inttypes.h-inclusion
remove unnecessary <inttypes.h> inclusion
2015-04-03 08:30:44 +09:00
Yukihiro "Matz" Matsumoto cb3e1433a4 Merge pull request #2753 from cremno/vs2015-has-inline-kw
MSVC 2015 implements inline keyword
2015-04-02 23:07:31 +09:00
Yuhei Okazaki 06435f5bc7 fix maximum value of the index when access breakpoints. 2015-03-31 10:52:10 +09:00
cremno 18fdf7e03f remove unnecessary <inttypes.h> inclusion
The format specifier macros were needed to portably print a mrb_int,
because mrb_raisef() originally called vsnprintf(). It doesn't anymore
since 18b2683b97 and the mrb_int format
specifier macros are already gone.
2015-03-30 21:01:16 +02:00
cremno 6424569a63 MSVC 2015 implements inline keyword
Apparently the C compiler of Visual Studio 2015 CTP6 finally implements
inline as inline and not only as _inline and __inline.
2015-03-30 20:13:23 +02:00
Yukihiro "Matz" Matsumoto 0573306f51 Merge pull request #2750 from cremno/call-c11-timespec_get
mruby-time: call ISO C11's timespec_get() if available
2015-03-23 14:11:19 +09:00
Yukihiro "Matz" Matsumoto 2249afce25 Merge pull request #2751 from cremno/refactor-write_pool_block
refactor write_pool_block()
2015-03-23 14:10:11 +09:00
cremno 7985f75dfa refactor write_pool_block()
No need to write the same assertion in each case (except the default
one). Instead we can assert after the switch statement.
2015-03-22 23:10:38 +01:00
cremno c47cc0c3bb call C11's timespec_get()
gettimeofday() is an obsolescent POSIX function which may be removed in
a future version. POSIX recommends using clock_gettime() (also POSIX)
instead, but it isn't available on OS X or Windows (at least with MSVC
and older MinGW versions).

Whereas timespec_get() is part of ISO C11 and mruby uses some small
other C11 features too. It isn't universally available yet either, but
it might be in the future. And Visual C++ 2015 implements it! Since
mruby strives for ISO C and not POSIX compatibility, I think it's a
reasonable choice.

TIME_UTC is used instead of __STDC_VERSION__, because if TIME_UTC is
defined, then most likely timespec_get() is too. This isn't true in case
of  __STDC_VERSION__ (see MSVC).
2015-03-22 22:52:12 +01:00
Yukihiro "Matz" Matsumoto 17b7745593 Merge branch 'master' of github.com:mruby/mruby 2015-03-21 11:20:52 +09:00
Yukihiro "Matz" Matsumoto 4cf9b2fd1c execute ensure clause only when skipping call frame; fix #2726 2015-03-21 11:20:44 +09:00
Yukihiro "Matz" Matsumoto dc757f70fd Merge pull request #2747 from jbreeden/vcpp_exceptions
Fix exceptions for visualcpp
2015-03-20 00:28:46 +09:00
Jared Breeden f6f70c86db Fix exceptions for visualcpp 2015-03-18 20:14:54 -04:00
Yukihiro "Matz" Matsumoto 0e218f5356 Merge pull request #2746 from tarosay/tarosa
I modified the undefined frexpl in cygwin of make
2015-03-16 19:34:29 +09:00
Tarosa 52f35b83e2 I have added the #ifdef __CYGWIN32__ to modify the fmt_fp.c 2015-03-16 19:22:47 +09:00
Tarosa f6dc516319 I modified the undefined frexpl in cygwin of make 2015-03-16 18:34:08 +09:00
Yukihiro "Matz" Matsumoto f32393a820 Merge pull request #2740 from govm/stack_extend-in-mrb_f_send
Fix #2739 stack_extend in mrb_f_send
2015-03-06 00:22:58 +09:00
Go Saito 16b5986d14 stack_extend in mrb_f_send
mrb_f_send needs stack_extend like OP_SEND

Signed-off-by: Go Saito <gos@iij.ad.jp>
2015-03-05 17:41:34 +09:00
Yukihiro "Matz" Matsumoto 7d67c573d7 Merge pull request #2738 from kou/use-ptrdiff-t
Use ptrdiff_t to suppress signedness warning
2015-02-28 20:43:18 +09:00
Kouhei Sutou 42359d6241 Use ptrdiff_t to suppress signedness warning
3df3216179 says so but there is no warning
with GCC 4.9 on my Debian GNU/Linux environment.
2015-02-28 15:30:18 +09:00
Yukihiro "Matz" Matsumoto 414678d61a Merge pull request #2736 from cremno/delete-prototypes-of-undefined-functions
delete prototypes of undefined functions
2015-02-27 17:15:59 +09:00
Yukihiro "Matz" Matsumoto 3cba701672 fix MSVC initialization issue by a patch from @dyama; close #2734 2015-02-27 17:14:32 +09:00
Yukihiro "Matz" Matsumoto 3df3216179 change size_t to ptrdiff_t to silence signedness warnings; #2732 2015-02-27 17:14:03 +09:00
cremno 893f937922 delete prototypes of undefined functions 2015-02-26 09:56:03 +01:00
Yukihiro "Matz" Matsumoto a1d4992187 Merge pull request #2732 from kou/fix-a-crash-bug-on-raise-after-realloc
Fix a crash bug on raising after realloc
2015-02-26 14:40:02 +09:00
Kouhei Sutou 3fefe52ffb Fix a crash bug on raising after realloc
The following program reproduces this problem:

    #include <mruby.h>

    static mrb_value
    recursive(mrb_state *mrb, mrb_value self)
    {
      mrb_int n;

      mrb_get_args(mrb, "i", &n);

      if (n == 0) {
        mrb_raise(mrb, E_RUNTIME_ERROR, "XXX");
      } else {
        mrb_funcall(mrb, self, "recursive", 1, mrb_fixnum_value(n - 1));
      }

      return self;
    }

    int
    main(void)
    {
      mrb_state *mrb;

      mrb = mrb_open();

      mrb_define_method(mrb, mrb->kernel_module, "recursive", recursive,
                        MRB_ARGS_REQ(1));
      mrb_funcall(mrb, mrb_top_self(mrb), "recursive", 1, mrb_fixnum_value(30));

      mrb_close(mrb);
    }

Recursive method call isn't required. It's just for expanding call info
stack.

If mrb_realloc() is called in cipush(), cibase address is changed. So,
we shouldn't compare ci before mrb_realloc() and cibase after
mrb_realloc(). It accesses unknown address and causes crash.
2015-02-25 00:13:40 +09:00
Yukihiro "Matz" Matsumoto a2a272ca8e Merge pull request #2730 from kou/fix-no-expression-case
Fix a bug that no expression case doesn't return valid value
2015-02-24 22:07:36 +09:00
Kouhei Sutou 4b4ddd5a28 Fix a bug that no expression case doesn't return valid value
Here is a script that reproduces this problem:

     x = case
         when true; 1
         end
     p x # => main # 1 is expected
2015-02-24 20:53:12 +09:00
Yukihiro "Matz" Matsumoto 68f60714dc Merge pull request #2729 from kou/fix-if-and-no-value-returned-case
Fix a bug that if and no return value case can't return true clause value
2015-02-24 14:29:47 +09:00
Yukihiro "Matz" Matsumoto d0bc006a73 Merge pull request #2728 from govm/fix-dereference-invalid-argv
fix pointer dereference after realloc
2015-02-24 14:28:14 +09:00
Kouhei Sutou 584d6de3c2 Fix a bug that if and no return value case can't return true clause value
Here is a script that reproduce this problem:

     x = if true
           1
         else
           case 2
           when 3
           end
           4
         end
     p x # => nil # 1 is expected
2015-02-24 00:16:41 +09:00
Go Saito 42d23084b7 fix pointer dereference after realloc
In src/vm.c: mrb_funcall_with_block
stack_extend may realloc mrb->c->stbase, if argv points on mruby's stack,
then it points invalid address after stack_extend.

e.g. src/class.c: mrb_instance_new

This code:

```ruby
class A
  def initialize(a0,a1,a2,a3,a4)
    a0.is_a? Array
  end
end

def f(a0,a1,a2,a3,a4)
  A.new(a0,a1,a2,a3,a4)
  f(a0,a1,a2,a3,a4)
end

f(0,1,2,3,4)
```

is expected to get exception
```
stack level too deep. (limit=(0x40000 - 128)) (SystemStackError)
```

but get segfault.

Signed-off-by: Go Saito <gos@iij.ad.jp>
2015-02-23 11:25:21 +09:00
Yukihiro "Matz" Matsumoto 44d8a40bac add a prototype declaration for mrb_fiber_resume(); ref #1269 2015-02-19 11:38:05 +09:00
Yukihiro "Matz" Matsumoto 0609abb3f7 new API function mrb_fiber_resume(); ref #1269 2015-02-19 10:02:43 +09:00
Yukihiro "Matz" Matsumoto 80c343aec9 add description comment to mrb_fiber_yield() 2015-02-19 10:02:02 +09:00
Yukihiro "Matz" Matsumoto 9248cdd6cc silence warnings in fmt_fp.c 2015-02-16 14:50:01 +09:00
Yukihiro "Matz" Matsumoto a88a20d51f Merge pull request #2723 from cremno/use-musl-fmt_fp
re-implement mrb_float_to_str()
2015-02-16 14:42:01 +09:00
cremno 6f893b5183 re-implement mrb_float_to_str()
The new implementation is backwards incompatible, but I couldn't find
any usage outside mruby and I also couldn't think of a different and
good name.

All ISO C99 printf conversion specifiers for floating point numbers and
an optional precision are supported.

It is largely based on code from the MIT licensed musl libc
(http://www.musl-libc.org/) and its floating point printing is exact
(unlike the current code behind Float#to_s).
2015-02-13 09:33:03 +01:00
Yukihiro "Matz" Matsumoto 1fa081a646 Merge pull request #2722 from sgnr/disable-stdio-enable-backtraces
Make backtraces work again under DISABLE_STDIO
2015-02-13 12:31:26 +09:00
Yukihiro "Matz" Matsumoto a32ec182dd Merge pull request #2721 from kou/add-more-debug-flags
Add more debug flags for GCC based compilers
2015-02-13 12:28:42 +09:00
Tomoyuki Sahara 1629e86063 add IPv6 constants defined in RFC3493. 2015-02-13 11:35:36 +09:00
Simon Génier 40e4eb599c DISABLE_STDIO does not disable backtraces. 2015-02-12 13:18:59 -05:00
Kouhei Sutou a88cda8ac6 Add more debug flags for GCC based compilers
We can use `#define`-ed macros in GDB with `-g3` flag.

We can run code step by step in GDB with `-O0` flag.
2015-02-10 19:00:30 +09:00
Yukihiro "Matz" Matsumoto 789177c8fe Merge pull request #2719 from suzukaze/delete-temp-variable
Delete temp variable
2015-02-07 17:50:54 +09:00
Jun Hiroe ac131c9052 Remove eql_p variable in mrb_struct_eql func 2015-02-07 01:46:56 +09:00
Jun Hiroe 7dff6ab75a Remove eql_p variable in mrb_struct_equal func 2015-02-07 01:46:45 +09:00
Yukihiro "Matz" Matsumoto 43881f6b97 Merge pull request #2718 from matsumoto-r/update-mruby-config
mruby-config supports MRUBY_LDFLAGS_BEFORE_LIBS in libmruby.flags.mak
2015-02-07 00:49:02 +09:00
Yukihiro "Matz" Matsumoto f5026f9b6c Merge pull request #2717 from sgnr/missing-lastpc-on-funcall-cfunc
Fix possible segfault when accessing backtrace with MRB_WORD_BOXING.
2015-02-07 00:48:08 +09:00
MATSUMOTO Ryosuke 7367bf6ffe mruby-config supports MRUBY_LDFLAGS_BEFORE_LIBS in libmruby.flags.mak 2015-02-06 07:15:54 -08:00
Yukihiro "Matz" Matsumoto 1346456c6c Merge pull request #2716 from kou/fix-ensure-context-on-break-and-return
Fix ensure with yield context on break and return
2015-02-07 00:13:14 +09:00
Simon Génier df382dea73 Fix possible segfault when accessing backtrace with MRB_WORD_BOXING. 2015-02-05 15:12:21 -05:00
Kouhei Sutou 8cb40fcda7 Fix ensure with yield context on break and return
How to reproduce:

    class A
      def x
        yield
      ensure
        y
      end

      def y
      end
    end

    # Work
    A.new.x do
    end

    # Not work
    # trace:
    # 	[2] /tmp/a.rb:5:in A.x
    # 	[0] /tmp/a.rb:15
    # /tmp/a.rb:5: undefined method 'y' for main (NoMethodError)
    A.new.x do
      break
    end

    # trace:
    # 	[2] /tmp/a.rb:5:in A.call
    # 	[0] /tmp/a.rb:19
    # /tmp/a.rb:5: undefined method 'y' for main (NoMethodError)
    lambda do
      A.new.x do
        return
      end
    end.call

`self` in ensure is broken when yield and break/return are used.
2015-02-05 22:40:25 +09:00
Yukihiro "Matz" Matsumoto 4957c85269 Merge pull request #2715 from suzukaze/fix-dump.c
Replace int with mrb_bool in dump_bigendian_p func
2015-02-03 07:23:09 +09:00
Jun Hiroe b88c8b40d6 Replace int with mrb_bool in dump_bigendian_p func 2015-02-02 14:18:10 +09:00
Yukihiro "Matz" Matsumoto bc9c47d518 allow endian specification of mrb files by mrbc -e/-E
`mruby -b` now accepts both big/little endian mrb (compiled binary) files.

`mrbc` generates mrb files in big endian for .mrb files and in native endian
for C files (with -B option specified) by default.  If you are cross compiling,
you need to specify target endian by -e/-E options if it is different from
host endian.
2015-02-02 09:34:24 +09:00
Yukihiro "Matz" Matsumoto 089f1f6c75 block_given? should work with nested block; fix #2695 close #2712 2015-01-31 13:51:25 +09:00
Yukihiro "Matz" Matsumoto 02b54e5379 avoid block_given? in loop method for simplicity 2015-01-31 10:44:58 +09:00
Yukihiro "Matz" Matsumoto f01882a8e0 Merge pull request #2714 from xxuejie/use-setter-macro-when-necessary
Use setter macro instead of directly setting values
2015-01-26 16:11:58 +09:00
Xuejie "Rafael" Xiao d63e45a014 Use setter macro instead of directly setting values 2015-01-26 10:52:06 +08:00
Yukihiro "Matz" Matsumoto 23e69edd2d Merge pull request #2713 from BenMorganIO/grammar-in-doc-updates
update grammar and preposition for debugger readme
2015-01-25 19:48:02 +09:00
Ben A Morgan cc11ee15b4 update grammar and preposition for debugger readme 2015-01-25 02:01:46 -08:00
Yukihiro "Matz" Matsumoto 8af688e2c9 Merge pull request #2710 from sdottaka/fix-window-build
tasks/ruby_ext.rake: Fix build error when file path includes \1 or \2.  ...
2015-01-23 01:15:44 +09:00
sdottaka a99fb39dc1 tasks/ruby_ext.rake: Fix build error when file path includes \1 or \2. #2709 2015-01-22 20:27:29 +09:00
Yukihiro "Matz" Matsumoto 8aba34301b String#[]= should support negative position; close #2707 2015-01-19 22:13:34 +09:00
Yukihiro "Matz" Matsumoto d764632f86 Merge pull request #2680 from sdottaka/add-fflush
mrdb, mirb: Add fflush() so that a external program can read output imme...
2015-01-19 08:30:52 +09:00
Yukihiro "Matz" Matsumoto 1c48be7822 Merge pull request #2706 from furunkel/master
Don't use Build.current if possible
2015-01-19 00:13:14 +09:00
Julian Aron Prenner 959a5cff60 Don't use Build.current if possible 2015-01-18 15:45:48 +01:00
Yukihiro "Matz" Matsumoto 7137ee88b5 Merge pull request #2705 from sdottaka/mrdb-step-into-proc-call
mrdb: fix crash when stepping into Proc.call
2015-01-18 20:24:46 +09:00
Yukihiro "Matz" Matsumoto f9e43724bf Merge pull request #2704 from takahashim/update-version-readme
update stable version number in README
2015-01-18 12:11:26 +09:00
sdottaka af51a4ac9d mrdb: fix crash when stepping into Proc.call
How to reproduce:

```
cat a.rb
Proc.new { 1 }.call

echo step | mrdb a.rb
```
2015-01-18 10:00:56 +09:00
takahashim c0f5be7858 update stable version number in README 2015-01-18 00:45:41 +09:00
Yukihiro "Matz" Matsumoto 16884b87af Merge pull request #2702 from takahashim/fix-string-match
fix infinite loop in String#match(arg) when arg is String
2015-01-14 09:33:41 +09:00
takahashim bcceeba09b fix infinite loop in String#match(arg) when arg is String 2015-01-14 02:18:56 +09:00
Yukihiro "Matz" Matsumoto d405eb5541 Merge pull request #2701 from suzukaze/string.upto
Add String#upto
2015-01-13 20:27:19 +09:00
Jun Hiroe e998094297 Add String#upto 2015-01-13 16:32:30 +09:00
Yukihiro "Matz" Matsumoto 4aef1ad209 Merge pull request #2700 from takahashim/string-ljust
add String#ljust into mruby-string-ext
2015-01-13 16:19:46 +09:00
Yukihiro "Matz" Matsumoto 1ab79ac414 Merge pull request #2699 from takahashim/fix-recursive-struct
fix Segmentation fault on Struct#inspect due to recursive Struct object
2015-01-13 16:18:50 +09:00
takahashim 1b606025ed add String#ljust into mruby-string-ext 2015-01-12 22:16:29 +09:00
takahashim 9dff0aedb1 fix Segmentation fault on Struct#inspect due to recursive Struct object 2015-01-12 20:08:53 +09:00
Yukihiro "Matz" Matsumoto 53da1fb5a1 Merge pull request #2697 from cubicdaiya/use-sizeof
Use sizeof() instead of strlen().
2015-01-10 10:50:21 +09:00
Yukihiro "Matz" Matsumoto 70851aaf57 Merge pull request #2696 from furunkel/master
Properly implement directory tasks
2015-01-08 08:58:07 +09:00
Julian Aron Prenner edf7729d89 Correctly handle relative paths 2015-01-07 09:31:30 +01:00
Julian Aron Prenner 432afa2c42 Properly implement directory tasks 2015-01-06 21:23:19 +01:00
Yukihiro "Matz" Matsumoto dc39d2290a Merge pull request #2694 from cubicdaiya/use-mrb-exc-new-str-lit
Use mrb_exc_new_str_lit().
2015-01-04 17:11:37 +09:00
Tatsuhiko Kubo 5fac7a73cb Use mrb_exc_new_str_lit(). 2015-01-03 23:34:13 +09:00
Yukihiro "Matz" Matsumoto 3c41ad4018 Merge pull request #2693 from cubicdaiya/remove-duplicate-declarations
Removed duplicated declarations.
2015-01-03 23:02:43 +09:00
Tatsuhiko Kubo dae42ffe54 Removed duplicated declarations.
* `mrb_show_version()`
 * `mrb_show_copyright()`
2015-01-03 22:56:36 +09:00
Tatsuhiko Kubo 2b753167ca Use sizeof() instead of strlen(). 2015-01-03 22:37:11 +09:00
Yukihiro "Matz" Matsumoto 465ce1e528 Merge pull request #2692 from cubicdaiya/error-handling-mrb-open
fixed error-handling for mrb_open().
2015-01-03 21:10:19 +09:00
Tatsuhiko Kubo df5f83cb84 fixed error-handling for mrb_open().
When mrb_open() is called again, it is not checked.
2015-01-03 20:56:49 +09:00
Yukihiro "Matz" Matsumoto 2c4b0eeff8 Merge pull request #2691 from deuwert/tidyup-test-time
Round execution time
2015-01-03 20:20:36 +09:00
Daniel Bovensiepen a3111f144c Round execution time 2015-01-03 17:53:32 +08:00
sdottaka 71548aabb7 Add fflush() (2) 2015-01-03 14:52:11 +09:00
Yukihiro "Matz" Matsumoto 3dea108857 Merge pull request #2690 from furunkel/master
Set correct build dir for bins
2015-01-03 13:04:20 +09:00
Julian Aron Prenner 1aef549971 Set correct build dir for bins 2015-01-02 14:47:57 +01:00
Yukihiro "Matz" Matsumoto 7d4b516ca3 Merge pull request #2689 from cubicdaiya/remove-null-checks
Remove redundant NULL checks for mrb_malloc().
2015-01-01 13:13:50 +09:00
Tatsuhiko Kubo 606095f2fe Remove redundant NULL checks for mrb_malloc(). 2015-01-01 05:12:41 +09:00
Yukihiro "Matz" Matsumoto 4046368ef3 Merge pull request #2687 from suzukaze/avoid_block_given
Avoid block_given? in mrbgem:enum.rb to reduce method calls
2014-12-27 20:12:55 +09:00
Yukihiro "Matz" Matsumoto baa0ee4133 Merge pull request #2686 from cubicdaiya/use-suitable-type
Use suitable type.
2014-12-27 20:12:09 +09:00
Jun Hiroe 3a21c9b6d7 Avoid block_given? in mrbgem:enum.rb to reduce method calls 2014-12-27 18:17:29 +09:00
Tatsuhiko Kubo 093560e7d1 Use suitable type. 2014-12-27 10:18:18 +09:00
Tomoyuki Sahara e4006cb53a Socket::Option requires iij/mruby-pack. 2014-12-26 16:12:41 +09:00
Tomoyuki Sahara 0d05a22602 don't call undefined method. fixes #15. 2014-12-26 16:00:50 +09:00
Tomoyuki Sahara 7b17158f88 remove unused variables. 2014-12-26 13:36:11 +09:00
Tomoyuki Sahara a09858af61 syscalls may return sockaddr shorter than sizeof(struct sockaddr) on Linux. 2014-12-26 13:27:39 +09:00
Tomoyuki Sahara a960a6f931 failed to add... 2014-12-26 11:19:53 +09:00
Tomoyuki Sahara 3a22166c67 debug UNIXSocket and UNIXServer. 2014-12-26 11:16:03 +09:00
Tomoyuki Sahara 3a97a453c4 rewrite IO.for_fd.
IO.for_fd should call IO#initialize to initialize the created object
properly.  It cannot be implemented in Ruby.
2014-12-26 11:09:07 +09:00
Tomoyuki Sahara c455544ee2 better error message. 2014-12-26 11:08:18 +09:00
Yukihiro "Matz" Matsumoto ef3bbd2e64 avoid block_given? in enum.rb to reduce method calls 2014-12-25 15:59:22 +09:00
Yukihiro "Matz" Matsumoto 6eeaef705d Merge pull request #2685 from sdottaka/fix-typo-in-mruby-eval
mruby-eval: fix typo
2014-12-24 01:07:18 +09:00
Yukihiro "Matz" Matsumoto bb3447173b khash.h: keep key/value table accessible from original hashtable during resize; fix #2682 2014-12-23 22:28:33 +09:00
Yukihiro "Matz" Matsumoto 7f630d41ab Merge pull request #2684 from kou/fix-splat-and-multiple-assignments
Fix splat and multiple assignments
2014-12-23 22:19:20 +09:00
sdottaka 79f703ecba mruby-eval: fix typo 2014-12-23 22:17:07 +09:00
Kouhei Sutou 5ec676aa37 Fix splat and multiple assignments
Case1: From variable

Code:

    a = [1, 2, 3, 4, 5]
    b, c, *d = a

    p [a, b, c, d]

Before:

    [[1, 2, 3, 4, 5], 1, 2, []]

After:

    [[1, 2, 3, 4, 5], 1, 2, [3, 4, 5]]

Ruby:

    [[1, 2, 3, 4, 5], 1, 2, [3, 4, 5]]

Case2: From variables

Code:

    a = [1, 2, 3]
    b = [4, 5, 6, 7]
    c, d, *e, f, g = *a, *b

    p [a, b, c, d, e, f, g]

Before:

    [[1, 2, 3], [4, 5, 6, 7], 1, 2, [], 6, 7]

After:

    [[1, 2, 3], [4, 5, 6, 7], 1, 2, [3, 4, 5], 6, 7]

Ruby:

    [[1, 2, 3], [4, 5, 6, 7], 1, 2, [3, 4, 5], 6, 7]

Case 3: "for"

Code:

    a = [1, 2, 3, 4, 5, 6, 7]
    for b, c, *d, e, f in [a] do
      p [a, b, c, d, e, f]
    end

Before:

    [[1, 2, 3, 4, 5, 6, 7], 1, 2, [], nil, nil]

After:

    [[1, 2, 3, 4, 5, 6, 7], 1, 2, [3, 4, 5], 6, 7]

Ruby:

    [[1, 2, 3, 4, 5, 6, 7], 1, 2, [3, 4, 5], 6, 7]
2014-12-23 21:16:01 +09:00
Yukihiro "Matz" Matsumoto e618438882 Merge pull request #2681 from sdottaka/mrdb-break-windows
mrdb: fix that break command cannot handle Windows paths
2014-12-20 10:39:58 +09:00
sdottaka 80a742df51 mrdb: fix that break command cannot handle Windows paths
Before fix:
```
$ mrdb c:\tmp\b.rb
(c:\tmp\b.rb:1) break c:\tmp\b.rb:3
Class name 'c' is invalid.
```

After fix:
```
$ mrdb c:\tmp\b.rb
(c:\tmp\b.rb:1) break c:\tmp\b.rb:3
Breakpoint 1: file c:\tmp\b.rb, line 3.
```
2014-12-20 08:32:28 +09:00
Yukihiro "Matz" Matsumoto 10e9a1a167 now retrieves number of arguments of blocks from OP_ENTER op code; close #2671 2014-12-19 19:45:20 +09:00
Yukihiro "Matz" Matsumoto 358dd61107 block_given? should return correct value when called in blocks; close #2678
avoid a loop to find parent's callinfo using mrb->c->cibase[env->cioff]
2014-12-19 19:05:27 +09:00
Yukihiro "Matz" Matsumoto 5014bfb50d block_given? should return false on top-level; ref #2678 2014-12-19 18:51:14 +09:00
sdottaka 9a0fb6f91b mrdb, mirb: Add fflush() so that a external program can read output immediately. 2014-12-19 16:09:55 +09:00
Tomoyuki Sahara 1d1f273ca9 Merge pull request #35 from tmtm/fix-read-create-many-objects
FIX: IO#read create a large number of objects.
2014-12-18 11:33:06 +09:00
TOMITA Masahiro 42752bffce FIX: IO#read create a large number of objects. 2014-12-18 00:41:59 +09:00
Yukihiro "Matz" Matsumoto 2732879f3e String#[]: float handling merged to #2677 2014-12-17 20:19:52 +09:00
Yukihiro "Matz" Matsumoto 545c5eecc0 Merge branch 'h2so5-string-nil-index' 2014-12-17 20:10:08 +09:00
Yukihiro "Matz" Matsumoto 4319eaaa45 try to convert not only nil but every objects to fixnums; ref #2677 2014-12-17 20:08:26 +09:00
h2so5 05b00a14c5 String#[] should reject nil index 2014-12-17 14:01:39 +09:00
Tomoyuki Sahara e7dbe6e87a Merge pull request #33 from iij/revert-32-fix-read-create-many-objects
Revert "FIX: IO#read create a large number of objects."
2014-12-17 13:39:59 +09:00
Tomoyuki Sahara e82c1d3f38 Revert "FIX: IO#read create a large number of objects." 2014-12-17 13:37:15 +09:00
Tomoyuki Sahara 50721e9bf8 Merge pull request #32 from tmtm/fix-read-create-many-objects
FIX: IO#read create a large number of objects.
2014-12-17 13:35:34 +09:00
Yukihiro "Matz" Matsumoto 5b203ead1e mruby-eval: proc from env may be NULL; close #2676 2014-12-17 12:35:19 +09:00
Yukihiro "Matz" Matsumoto ed56d56dab avoid out-of-bounds access of irep->lv; ref #2671, fix #2675
allocation size of irep->iv is irep->nlocals-1.
2014-12-17 11:14:14 +09:00
Yukihiro "Matz" Matsumoto a19a6edb7c mrb_str_new(mrb, "", len) creates an unmodifiable string object; ref #2674 2014-12-17 08:06:44 +09:00
Yukihiro "Matz" Matsumoto 0c4d053a94 Merge pull request #2674 from suzukaze/string.prepend
Add String#prepend
2014-12-17 07:45:45 +09:00
Jun Hiroe 7ea38ce473 Add String#prepend 2014-12-17 02:23:36 +09:00
TOMITA Masahiro 9b13a59a55 FIX: IO#read create a large number of objects. 2014-12-17 01:46:23 +09:00
Yukihiro "Matz" Matsumoto ab72410456 eval() should preserve stack in env properly; fix #2671 2014-12-17 01:10:19 +09:00
Yukihiro "Matz" Matsumoto fcbb7ec49d Fix crash if #inspect does not return a string value 2014-12-16 19:26:40 +09:00
Tomoyuki Sahara ee347f3417 Merge pull request #31 from tmtm/fix-sysread-segv
FIX: IO#sysread occurs SEGV
2014-12-16 09:07:45 +09:00
TOMITA Masahiro be9e203563 FIX: IO#sysread occurs SEGV 2014-12-15 20:24:01 +09:00
Yukihiro "Matz" Matsumoto 05e6513fb4 Merge pull request #2669 from suzukaze/string.insert
Add String#insert
2014-12-13 15:40:37 +09:00
Jun Hiroe 45a442a9d7 Add String#insert 2014-12-13 15:31:22 +09:00
Yukihiro "Matz" Matsumoto f1481105b7 Merge pull request #2668 from sdottaka/fix-crash-for-inspect
Fix crash if #inspect does not return a string value
2014-12-12 23:12:48 +09:00
sdottaka fe01ce5b02 Fix crash if #inspect does not return a string value
case 1
~~~
class A; def inspect; 1; end; end
A.new.a
~~~

case 2

~~~
class A
  def self.inspect
    1
  end
  alias_method :a, :b
end
~~~
2014-12-12 23:05:22 +09:00
Yukihiro "Matz" Matsumoto 96d02b1268 Merge pull request #2667 from murasesyuka/usage_message_is_used_switches_instead_of_option
fix usage message
2014-12-12 22:13:06 +09:00
Yukihiro "Matz" Matsumoto 4078670bca mrb_p() should print mrb_obj_as_string() if #inspect does not return a string value 2014-12-12 21:32:02 +09:00
Yukihiro "Matz" Matsumoto 9723d6e4ba mirb dies if #inspect returns a non-string value; fix #2666 2014-12-12 13:14:56 +09:00
Tomoyuki Sahara 723db886e1 add Socket::Option#inspect
without this, mirb dies.
https://github.com/mruby/mruby/pull/2666
2014-12-12 12:38:43 +09:00
Tomoyuki Sahara 121475638d add "I" and "i". 2014-12-12 12:12:41 +09:00
Tomoyuki Sahara 2103bc99ba style 2014-12-12 12:12:19 +09:00
Tomoyuki Sahara 669fe705cc "i" and "I". 2014-12-12 12:01:58 +09:00
murase_syuka 77c6bfe287 fix usage message 2014-12-11 06:54:15 +09:00
Yukihiro "Matz" Matsumoto 44c29e88ae block_given did not work with nested block invocation for some cases; fix #2665 2014-12-11 00:36:18 +09:00
Yukihiro "Matz" Matsumoto 4eff93632f mrb_parser_dump() did not work with block arguments 2014-12-11 00:08:56 +09:00
Yukihiro "Matz" Matsumoto b48514bdcb Merge pull request #2663 from iij/pr-fix-string-utf8-aref
adding mruby-string-utf8 breaks String#[float]
2014-12-05 14:54:59 +09:00
Tomoyuki Sahara 5f68be7190 String#[] accepts float. 2014-12-05 13:42:58 +09:00
ksss e61c469724 IO.popen fd set close_on_exec flag by default 2014-12-04 10:25:03 +09:00
ksss 9439b981d8 Opened fd should be set FD_CLOEXEC by default 2014-12-04 10:25:03 +09:00
Yukihiro "Matz" Matsumoto ea828944ef Merge branch 'master' of github.com:mruby/mruby 2014-12-02 15:44:32 +09:00
Yukihiro "Matz" Matsumoto 64d1d10492 Merge pull request #2660 from cremno/fix-isblank-for-visual-studio-versions-older-than-2013
fix ISBLANK() for Visual Studio < 2013
2014-12-02 12:02:38 +09:00
cremno f6d15cfc38 fix ISBLANK() for Visual Studio < 2013 (ref #2658)
Visual Studio versions older than 2013 lack C99's isblank().
Since only ASCII characters are passed to it, implement it
directly without calling the locale-specific isblank().
2014-12-02 00:43:45 +01:00
Yukihiro "Matz" Matsumoto 4c70b5c644 should not pop register when value from multiple assignment required 2014-12-01 08:06:23 +09:00
Yukihiro "Matz" Matsumoto 260cad689a Merge pull request #2656 from murasesyuka/bugfix/mruby-bin-debugger_enforce_the_c99
adhoc fix for pass build
2014-11-29 09:32:44 +09:00
murase_syuka 39b4caea81 closing to Local Scope 2014-11-29 01:02:40 +09:00
Yukihiro "Matz" Matsumoto 09c6ca936c preserve ICLASS in ci->target_class; fix #2657; ensuring #1467 #1470 #1493 still works 2014-11-28 20:35:06 +09:00
Yukihiro "Matz" Matsumoto bcf8ad87e6 add multiple assignment decomposition test 2014-11-27 16:21:48 +09:00
Yukihiro "Matz" Matsumoto e4ca706530 wrong register adjustment 2014-11-27 16:21:15 +09:00
murase_syuka 1248e2ba8a adhoc fix for pass build 2014-11-27 01:12:01 +09:00
Yukihiro "Matz" Matsumoto dd14973697 Merge pull request #2655 from tmtm/fix-numeric-step
Fix: Numeric#step infinite loop.
2014-11-26 08:34:51 +09:00
TOMITA Masahiro bbab89e730 Fix: Numeric#step infinite loop. 2014-11-26 01:34:07 +09:00
Yukihiro "Matz" Matsumoto 1365151dcb Merge pull request #2652 from cremno/mrdb-add-missing-null-termination
mrdb: add missing null-termination
2014-11-26 01:05:04 +09:00
Yukihiro "Matz" Matsumoto bf0875d2bb Merge branch 'master' of github.com:mruby/mruby 2014-11-26 01:04:24 +09:00
Yukihiro "Matz" Matsumoto e1a7fa925e add "fall through" comment 2014-11-26 01:03:57 +09:00
Robert Mosolgo 0133d9ac70 fix(String) String#[] accepts float; close #2650 #2651 2014-11-26 01:03:38 +09:00
Yukihiro "Matz" Matsumoto 2de7c5073c Merge branch 'master' of github.com:mruby/mruby 2014-11-26 00:50:37 +09:00
Yukihiro "Matz" Matsumoto 28bd33297a wrong register number adjustment in multiple assignment; fix #2654 2014-11-26 00:43:39 +09:00
Yukihiro "Matz" Matsumoto c424892c5e OP_APOST local variable display was wrong 2014-11-26 00:43:39 +09:00
cremno 553b9df306 free memory used by breakpoints 2014-11-26 00:43:39 +09:00
cremno 1cc6eaca2a free return value of dirname() 2014-11-26 00:43:39 +09:00
Tomoyuki Sahara d1fee5892a IO.sysopen does retry. closes #26. 2014-11-25 16:26:34 +09:00
Hiroshi Mimaki c5f480ebfd Merge pull request #2646 from cremno/mrdb-fix-memory-leaks
mrdb: fix two memory leaks
2014-11-25 14:16:42 +09:00
Hiroshi Mimaki 251dbca8e2 Merge pull request #2644 from cremno/mrdb-minor-changes
mrdb: minor changes
2014-11-25 14:11:57 +09:00
Yukihiro "Matz" Matsumoto 0a8e8bd046 Merge pull request #2653 from cremno/remove-unnecessary-_win32-preprocessor-check
remove unnecessary _WIN32 preprocessor check
2014-11-25 12:09:39 +09:00
Tomoyuki Sahara e7cd024498 Merge pull request #29 from sdottaka/fix-for-msvc
Fix broken build for Visual C++
2014-11-25 10:29:07 +09:00
cremno 94f1ad6cc1 remove unnecessary _WIN32 preprocessor check
SIZE_MAX < UINT32_MAX is false on Win32 / Win64.
2014-11-25 02:04:30 +01:00
cremno 5f1e90fc58 add missing null-termination 2014-11-25 01:46:06 +01:00
Yukihiro "Matz" Matsumoto 87ce13f91d Merge branch 'master' of github.com:mruby/mruby 2014-11-23 23:31:47 +09:00
Yukihiro "Matz" Matsumoto 6d00974a98 Merge pull request #2649 from tmtm/fix-string-slice
Fix String#slice! raise TypeError or return invalid value.
2014-11-23 23:31:36 +09:00
TOMITA Masahiro 0a0afa7c6a Fix String#slice! raise TypeError or return invalid value. 2014-11-23 21:26:50 +09:00
Yukihiro "Matz" Matsumoto 9ec00ef182 align indent of local variable names in codedump() 2014-11-23 07:36:58 +09:00
sdottaka 24007b80b4 Fix broken build for Visual C++ 2014-11-22 17:48:59 +09:00
Yukihiro "Matz" Matsumoto 2c04f4029f Merge pull request #2648 from cubicdaiya/use_lit_for_mrdb
use mrb_str_xxx_lit for mrdb.
2014-11-22 17:39:56 +09:00
Yukihiro "Matz" Matsumoto bce75e2746 should support recursive mlhs decomposition, e.g. (a,b),c = [1,2],3 2014-11-22 12:16:59 +09:00
Tatsuhiko Kubo 48a04ff1b4 use mrb_str_xxx_lit for mrdb. 2014-11-22 10:43:01 +09:00
Yukihiro "Matz" Matsumoto b28ec1bc88 Merge pull request #2645 from cremno/mrdb-fix-heap-use-after-free
mrdb: fix heap-use-after-free
2014-11-20 12:46:07 +09:00
cremno c9c0f9a79b remove const type qualifier
clang 3.5.0 with -Wextra produces a -Wignored-qualifiers diagnostic.
2014-11-20 02:39:48 +01:00
cremno c2bc44e131 don't convert function pointer to object pointer 2014-11-20 02:39:47 +01:00
cremno 337395c1ee remove cast
C99+TC3, 7.19.7.1p2: [...] the fgetc function obtains that character as
an unsigned char converted to an int [...]
2014-11-20 02:39:46 +01:00
cremno 6619fd338a free memory used by breakpoints 2014-11-20 01:20:30 +01:00
cremno a232dc6084 free return value of dirname() 2014-11-20 01:15:27 +01:00
cremno 83c48ff966 fix heap-use-after-free 2014-11-20 00:55:46 +01:00
Yukihiro "Matz" Matsumoto 88195a7c99 Merge pull request #2641 from sdottaka/super-fix
Fix an error when calling a method implemented in C by super() with argu...
2014-11-19 19:27:57 +09:00
Yukihiro "Matz" Matsumoto 4eabf7d91c [ci skip] run spell checker on doc/debugger/README.md and fixed typos mentioned from @bovi and @rmosolgo; ref #2640 2014-11-19 19:25:08 +09:00
sdottaka 820f6d147f Fix an error when calling a method implemented in C by super() with arguments. This fix makes the following code workable:
Expected:

class MRBTime < Time; def self.new; super(2012, 4, 21); end; end
MRBTime.new # => Sat Apr 21 00:00:00 2012

Actual:

class MRBTime < Time; def self.new; super(2012, 4, 21); end; end
MRBTime.new # => can't convert nil into Integer (TypeError)
2014-11-19 13:29:22 +09:00
Hiroshi Mimaki 4e4bfb08cb Merge pull request #2640 from mruby-Forum/v1.1.0
mruby-1.1.0
2014-11-19 09:02:10 +09:00
Yukihiro "Matz" Matsumoto 5c6d6309b6 separate mrb_notimplement() and mrb_notimplement_m(); ref #2636 2014-11-19 01:03:19 +09:00
Yukihiro "Matz" Matsumoto 17507e4460 [ci skip] rephrasing about mailing list description; ref #2639 2014-11-19 00:55:51 +09:00
Yukihiro "Matz" Matsumoto cd4f3c85b4 Merge pull request #2639 from suzukaze/fix-mailing-list-description
Fix mailing list description; ref #2635
2014-11-19 00:53:42 +09:00
Yukihiro "Matz" Matsumoto 7c3f9c8ce7 Merge pull request #2637 from rmosolgo/not-implemented-error-msg
fix mrb_notimplement typo
2014-11-19 00:51:47 +09:00
mimaki b473043acf mruby-1.1.0 2014-11-18 23:35:19 +09:00
mimaki e5bacc03f2 Add mruby debugger (mrdb) 2014-11-18 23:33:32 +09:00
Jun Hiroe 80e60dcc21 Fix mailing-list description 2014-11-18 15:31:16 +09:00
Tomoyuki Sahara a2f45bf8d1 Merge pull request #28 from ksss/file-size
Implement FileTest.size
2014-11-18 10:35:12 +09:00
Robert Mosolgo 8dc4d9d973 fix mrb_notimplement typo 2014-11-17 12:13:19 -08:00
Yukihiro "Matz" Matsumoto 9980bc20bb Merge pull request #2636 from ksss/mrb_notimplement
Implement C API mrb_notimplement
2014-11-17 17:55:23 +09:00
ksss 9a06cfa9d8 Implement C API mrb_notimplement 2014-11-17 17:42:20 +09:00
ksss a44ada616e Implement FileTest.size
- File.size delegate to FileTest.size
- File.size more faster by reading i-node value
2014-11-16 14:55:45 +09:00
Tomoyuki Sahara 379c5a6d88 Merge pull request #25 from matz/gc_on_enfile
garbage collect when open(2) fails with ENFILE or EMFILE
2014-11-13 09:27:11 +09:00
Yukihiro "Matz" Matsumoto b50093ad28 garbage collect when open(2) fails with ENFILE or EMFILE 2014-11-13 01:50:46 +09:00
Yukihiro "Matz" Matsumoto 70c9866751 add Float::{INFINITY,NAN} if available 2014-11-12 15:46:31 +09:00
Yukihiro "Matz" Matsumoto 887e9f4225 Merge branch 'master' of github.com:mruby/mruby 2014-11-10 11:47:12 +09:00
Yukihiro "Matz" Matsumoto 385fc5ec3b Merge pull request #2634 from xxuejie/fix-mrb-iv-check-prototype
Fix mrb_iv_check function decleration
2014-11-10 11:46:23 +09:00
Xuejie "Rafael" Xiao 164cb87c5b Fix mrb_iv_check function decleration 2014-11-10 10:12:40 +08:00
Yukihiro "Matz" Matsumoto 4c7e812bc0 Merge branch 'master' of github.com:mruby/mruby 2014-11-08 12:57:33 +09:00
Yukihiro "Matz" Matsumoto fbadd660d1 Merge pull request #2633 from southwolf/patch-1
Modify Arduino build config for IDE >= 1.5.7
2014-11-08 12:56:29 +09:00
Yukihiro "Matz" Matsumoto cd4467d014 Merge pull request #2631 from mimaki/sizeof_format_not_supported
%zu format is not supported by MSVC
2014-11-08 12:55:43 +09:00
SouthWolf d452be5ba6 change BIN_PATH for new gc in Arduino IDE >= 1.5.7 2014-11-08 11:32:30 +08:00
SouthWolf 6be0dd7de6 Modify Arduino build config for IDE >= 1.5.7
Arduino IDE >= 1.5.7 Changed ARDUINO_PATH from `Contents/Resources/Java` to `Contents/Java`, mentioned in #2632
2014-11-08 11:10:11 +08:00
Hiroshi Mimaki c29185ff13 %zu format is not supported by MSVC 2014-11-06 13:30:42 +09:00
Yukihiro "Matz" Matsumoto 3e0575ecb1 update teeny of MRUBY_VERSION; ref #2629 2014-11-04 22:19:40 +09:00
Yukihiro "Matz" Matsumoto 8a6e600562 avoid using rewind(3) to load mrb files 2014-11-04 14:05:36 +09:00
Yukihiro "Matz" Matsumoto 0e2ab2210c read whole mrb file at once to calculate correct padding offset; ref #2630 2014-11-04 10:12:46 +09:00
Yukihiro "Matz" Matsumoto 0e40468809 specify alignment specifier for GCC and MSC; ref #2630 2014-11-04 07:10:41 +09:00
Yukihiro "Matz" Matsumoto be844f9284 Fix misaligned access when reading irep; close #2630
Add padding bytes before iseq block that may be used as mrb_code[].
Note that dumped mrb format has changed.

Based on a patch from kimu_shu <alfvegardrisc@gmail.com>
2014-11-04 02:41:42 +09:00
Yukihiro "Matz" Matsumoto 23db5331a6 Merge pull request #2628 from fenrir-naru/cygwin_host
Under cygwin host, ncurses.a is only available instead of termcap.a.
2014-10-31 22:09:53 +09:00
M.Naruoka 14bc76d578 Under cygwin host, ncurses.a is only available instead of termcap.a. 2014-10-31 16:48:50 +09:00
Yukihiro "Matz" Matsumoto 378aa8a9c8 avoid wrong ArgumentError from mrb_get_args() when surrounding method takes more than one argument; ref #2627 2014-10-30 10:31:06 +09:00
Yukihiro "Matz" Matsumoto 5bd3d9bc27 add cast to return from aget_index(); ref #2627 2014-10-30 10:27:05 +09:00
Yukihiro "Matz" Matsumoto 69beaea296 Merge pull request #2627 from mattn/fix-2626
Handle Array#[float, int] Close #2626
2014-10-30 10:25:57 +09:00
mattn eaa0296fc5 Handle Array#[float, int] Close #2626 2014-10-29 19:27:20 +09:00
Yukihiro "Matz" Matsumoto cbbf840440 use mrb_get_args to parse Integer() option; ref #2625 2014-10-29 13:22:04 +09:00
Yukihiro "Matz" Matsumoto 73593f7d19 Merge pull request #2625 from suzukaze/add-kernel.Integer
Add kernel#Integer
2014-10-29 13:17:50 +09:00
Jun Hiroe 28c804621a Add Kernel.Integer 2014-10-29 01:30:30 +09:00
Jun Hiroe 5235e54137 Fix mrb_convert_to_integer. 2014-10-29 01:30:30 +09:00
Yukihiro "Matz" Matsumoto aec12c30e2 Merge pull request #2624 from suzukaze/refactor-for_body
Refactor for_body func
2014-10-28 23:43:29 +09:00
Jun Hiroe ad77ed8bf3 Refactor for_body func 2014-10-28 23:31:25 +09:00
Yukihiro "Matz" Matsumoto f4260a851a Merge pull request #2623 from suzukaze/fix-indent
Fix indent
2014-10-28 23:26:48 +09:00
Yukihiro "Matz" Matsumoto 5347fb923d Merge pull request #2621 from suzukaze/fix-parse_string
Replace int with mrb_bool in parse_string func
2014-10-28 23:26:23 +09:00
Yukihiro "Matz" Matsumoto 5d25047344 Merge pull request #2622 from suzukaze/fix-local_var_p
Replace int with mrb_bool in local_var_p func
2014-10-28 23:25:38 +09:00
Jun Hiroe ec7dbee4b1 Fix indent 2014-10-28 01:52:50 +09:00
Jun Hiroe 832b529679 Replace int with mrb_bool in parse_string func 2014-10-28 00:11:34 +09:00
Jun Hiroe 9ca1745833 Replace int with mrb_bool in local_var_p func 2014-10-28 00:11:16 +09:00
Yukihiro "Matz" Matsumoto 9d8be78f3a Merge pull request #2620 from suzukaze/refactor-yylex
Refactor yylex func
2014-10-27 18:00:37 +09:00
Jun Hiroe 34175bf41f Refactor yylex func 2014-10-27 01:27:00 +09:00
Yukihiro "Matz" Matsumoto 0e3b3bbc08 Merge pull request #2619 from suzukaze/refactor-mrbc_context_new
Refactor mrbc_context_new func
2014-10-27 00:47:25 +09:00
Jun Hiroe 7bd2a8508e Refactor mrbc_context_new func 2014-10-27 00:29:00 +09:00
Yukihiro "Matz" Matsumoto 2ff67f8d47 Merge pull request #2618 from suzukaze/add-kernel.Float
Add Kernel#Float
2014-10-25 03:12:42 +09:00
Jun Hiroe 140e9bbf4b Add Kernel.Float 2014-10-24 01:55:55 +09:00
Yukihiro "Matz" Matsumoto d3c7e117ef Merge pull request #2617 from suzukaze/add-kernel.Hash
Add Kernel#Hash
2014-10-23 23:42:34 +09:00
Jun Hiroe 9e05366451 Add Kernel.Hash 2014-10-21 23:48:44 +09:00
Yukihiro "Matz" Matsumoto 5616208e1a Merge pull request #2616 from suzukaze/add-kernel.String
Add Kernel#String
2014-10-21 09:20:40 +09:00
Jun Hiroe de04d3f080 Add Kernel.String 2014-10-20 22:35:58 +09:00
Yukihiro "Matz" Matsumoto 69ba4f0ed5 instance_methods etc should not include undef'ed method names; based on a patch from @cremno; fix #2613 2014-10-20 11:11:26 +09:00
Yukihiro "Matz" Matsumoto cee3dc58d6 Merge pull request #2612 from suzukaze/refactor-mrb_f_array
Refactor mrb_f_array func
2014-10-20 09:15:25 +09:00
Jun Hiroe 9b1d9a7901 Refactor mrb_f_array func 2014-10-19 20:06:27 +09:00
Yukihiro "Matz" Matsumoto 4fd28deff9 refactoring C part of #2611 2014-10-19 19:39:02 +09:00
Yukihiro "Matz" Matsumoto c6669a328d Merge pull request #2611 from suzukaze/add-kernel.Array
Add Kernel.Array
2014-10-19 19:33:39 +09:00
Jun Hiroe b6edf24a01 Add Kernel.Array 2014-10-19 19:25:31 +09:00
Yukihiro "Matz" Matsumoto 3f06307317 need addtional type check to avoid SEGV; ref #2609 2014-10-18 11:26:30 +09:00
Yukihiro "Matz" Matsumoto 3ff5081650 context proc may be cfunc; fix #2609 2014-10-17 15:48:58 +09:00
Yukihiro "Matz" Matsumoto c5a23e6a0d remove header prototype of mrb_exc_print; close #2607 2014-10-15 21:21:58 +09:00
Yukihiro "Matz" Matsumoto 3a94255495 Merge pull request #2608 from mrbrdo/fix-typo
fix typo (i->idx)
2014-10-15 21:19:03 +09:00
Jan Berdajs aff2be4b40 fix typo (i->idx) 2014-10-15 14:11:00 +02:00
Yukihiro "Matz" Matsumoto b4cc962c3a add similar range check for tm->usec as well 2014-10-03 14:58:59 +09:00
Yukihiro "Matz" Matsumoto 95b3a70291 always check range before casting time_t to mrb_int 2014-10-03 14:57:22 +09:00
Yukihiro "Matz" Matsumoto 88d14e03d0 time_t may overflow mrb_int when word boxing is used 2014-10-03 11:10:09 +09:00
Yukihiro "Matz" Matsumoto 2b3675bca1 word_boxing.h used int to represent symbols; use mrb_sym instead 2014-10-03 11:02:06 +09:00
Yukihiro "Matz" Matsumoto f03c23572d Merge pull request #2602 from Hiroyuki-Matsuzaki/fix_cygwin_gcc_warning
fixed. cygwin-gcc(ver4.8.3) warning in conv_digit()
2014-10-02 21:03:33 +09:00
Yukihiro "Matz" Matsumoto c08321ef23 remove accidental check-in of mruby-thread gem 2014-10-02 20:43:04 +09:00
Hiroyuki Matsuzaki e77ea4e5f2 fixed. cygwin-gcc(ver4.8.3) warning in conv_digit() 2014-10-02 19:50:58 +09:00
Yukihiro "Matz" Matsumoto ff663075e4 Merge pull request #2601 from mimaki/mrblib_absolute_path
Change mrblib's source path to absolute path
2014-10-02 17:59:40 +09:00
Yukihiro "Matz" Matsumoto 83992ee163 cast MRB_ENV_STACK_LEN to (mrb_int); ref #2600 2014-10-02 17:59:01 +09:00
Yukihiro "Matz" Matsumoto 906b62d50f Merge pull request #2600 from mimaki/fix_msvc_warnings
Pacify MSVC warnings for numeric.c, proc.c, and symbol.c
2014-10-02 17:50:27 +09:00
Hiroshi Mimaki 62c58d3dad Change mrblib's source path to absolute path 2014-10-02 15:23:10 +09:00
Hiroshi Mimaki ed15477c74 Pacify MSVC warnings for numeric.c, proc.c, and symbol.c 2014-10-02 13:37:49 +09:00
Yukihiro "Matz" Matsumoto 6b956f1c1b use __init_array_start to determine readonly data section;
b72e94f used _etext and _edata to distinguish C string literals from heap allocated strings,
but using _edata, global char arrays may be considered as string literals.  to avoid the issue,
we have to use __init_array_start, which might be less portable.  you can still use _edata, by
using MRB_NO_INIT_ARRAY_START.
2014-10-02 09:27:39 +09:00
Yukihiro "Matz" Matsumoto ae1403004b load.c to use mrb_ro_data_p() 2014-10-01 00:01:36 +09:00
Yukihiro "Matz" Matsumoto b72e94fa6b mrbconf.h option MRB_USE_ETEXT_EDATA to reduce memory.
on platforms with _etext and _edata, mruby can distinguish string literals so that it avoids memory allocation to copy them.
for example, on my Linux box (x86 32bit), memory consumed by mrbtest decreased from 8,168,203 to 8,078,848 (reduced 88KB).
2014-09-30 23:48:57 +09:00
Yukihiro "Matz" Matsumoto bbf24b8463 mrb_sym2name_len() should initialize lenp even when proper symbol does not exist 2014-09-30 22:46:19 +09:00
Yukihiro "Matz" Matsumoto 7a7dcd12e5 remove unnecessary trailing comma to remove pre C99 declaration error with -Wdeclaration-after-statement 2014-09-30 22:40:55 +09:00
Yukihiro "Matz" Matsumoto 4a55b42984 O(1) mrb_sym2name_len(); close #2591
instead of adding sym->name hash table, linear symbol table is added, and reduced name->sym hash table size.
2014-09-30 20:15:27 +09:00
Yukihiro "Matz" Matsumoto 3e3048ddd1 Merge pull request #2599 from SatoshiOdawara/fix_target_class_in_instance_eval
target_class should not be TT_ICLASS in instance_eval(string); ref #1152
2014-09-30 10:14:25 +09:00
Yukihiro "Matz" Matsumoto d85cce9539 Merge pull request #2598 from SatoshiOdawara/fix_lv_scope_eval
fixed. closures scope in eval(string)
2014-09-30 10:13:58 +09:00
Satoshi Odawara a10d36e0a2 target_class should not be TT_ICLASS in instance_eval(string); ref #1152 2014-09-29 17:53:08 +09:00
Satoshi Odawara 2551d14ff1 fixed. closures scope in eval(string) 2014-09-29 16:41:51 +09:00
Yukihiro "Matz" Matsumoto b090f43251 Merge pull request #2597 from kou/remove-duplicated-declaration
Remove duplicated mrb_print_backtrace() declaration
2014-09-28 20:36:20 +09:00
Kouhei Sutou 55dca8337e Remove duplicated mrb_print_backtrace() declaration
It is declared in mruby.h.
2014-09-27 23:53:25 +09:00
Yukihiro "Matz" Matsumoto 50e4df83cf Merge pull request #2596 from take-cheeze/fix_args
Fix `mrb_get_args` arguments type error found by mruby-clang-plugin.
2014-09-21 23:30:39 +09:00
take_cheeze 524c9152d3 Fix mrb_get_args arguments types found by mruby-clang-plugin. 2014-09-21 22:43:13 +09:00
Yukihiro "Matz" Matsumoto a12a9bfb8f Merge pull request #2595 from drbrain/80_column_README
Wrap README, etc. to 80 columns
2014-09-21 12:00:00 +09:00
Eric Hodel b7fc0f95e5 Wrap CONTRIBUTING.md to 80 columns 2014-09-21 11:07:36 +09:00
Eric Hodel 03a8d0c0ae Wrap INSTALL to 80 columns 2014-09-21 11:04:40 +09:00
Eric Hodel a12d8e32b1 Wrap README.md to 80 columns 2014-09-21 10:59:27 +09:00
Yukihiro "Matz" Matsumoto 5f7b0580b7 code reduce by using mrb_get_args("n") 2014-09-19 03:03:53 +09:00
Yukihiro "Matz" Matsumoto 147fbf1c12 Module#const_defined? to take second optional argument as CRuby; fix #2593 2014-09-19 03:02:07 +09:00
Yukihiro "Matz" Matsumoto 95c7f570e1 change class argument of mrb_const_defined_at from struct RClass* to mrb_value to make it consistent with mrb_const_defined; ref #2593 2014-09-19 02:51:52 +09:00
Yukihiro "Matz" Matsumoto 6b34166ba5 const_defined? to check superclasses; ref #2593 2014-09-19 02:41:20 +09:00
Yukihiro "Matz" Matsumoto 50f54529f2 to_hash/to_a check in Hash[] should only be done when only one argument is given; ref #2594 2014-09-19 01:14:50 +09:00
Yukihiro "Matz" Matsumoto 02b2ac8de2 Merge pull request #2594 from yasuyuki/hash
Implement Hash[]
2014-09-19 00:36:33 +09:00
INOUE Yasuyuki 5f16c41753 copy documentation comment from CRuby 2014-09-18 17:43:38 +09:00
INOUE Yasuyuki d30aadf306 remove line number from raise message 2014-09-18 17:37:48 +09:00
INOUE Yasuyuki e66d86a5fb refactor Hash generator loop 2014-09-18 16:07:27 +09:00
Yukihiro "Matz" Matsumoto e4bd48f3f7 Merge pull request #2592 from miura1729/original2
update outdated links to the original program.
2014-09-17 09:23:23 +09:00
Miura Hideki 8f883e5b20 update outdated links to the original program. 2014-09-16 20:08:47 +09:00
Yukihiro "Matz" Matsumoto 6057b2e378 change mrb_sym type from uint16_t to uint32_t 2014-09-15 01:48:08 +09:00
Yukihiro "Matz" Matsumoto 48c5321dca constify pointer from RARRAY_PTR to detect potential write barrier bugs.
if you see compiler errors due to this commit, you'd better to use array-modifying
functions, e.g. mrb_ary_set() or mrb_ary_push(), otherwise you might see nasty
GC bugs in the future.  if you are sure what you are doing, replace `RARRAY_PTR(ary)`
by `mrb_ary_ptr(ary)->ptr`. but be warned.
2014-09-12 12:42:39 +09:00
Yukihiro "Matz" Matsumoto 7ea8803e06 add benchmark/bm_app_lc_fizzbuzz.rb 2014-09-10 10:09:34 +09:00
Yukihiro "Matz" Matsumoto c01082e23c Merge pull request #2590 from cubicdaiya/issues/inline2
Add inline to str_with_class().
2014-09-09 09:57:30 +09:00
Tatsuhiko Kubo cfb321e877 Add inline to str_with_class(). 2014-09-09 00:44:49 +09:00
Yukihiro "Matz" Matsumoto d23bc85b54 Merge branch 'master' of github.com:mruby/mruby 2014-09-08 23:05:32 +09:00
Yukihiro "Matz" Matsumoto 63e34c30e0 Merge pull request #2589 from take-cheeze/fix_msvc_cxx
Fix MSVC C++ ABI build. Close #2588.
2014-09-08 23:05:08 +09:00
take_cheeze 380be0e829 Fix MSVC C++ ABI build. Close #2588. 2014-09-08 15:43:17 +09:00
Yukihiro "Matz" Matsumoto 902a4da271 remove execution bit from benchmark/fib39.rb 2014-09-08 14:24:53 +09:00
Yukihiro "Matz" Matsumoto 89e9df2681 fixed wandering filename problem 2014-09-08 01:20:43 +09:00
INOUE Yasuyuki 5603b8d79f implement Hash.[] 2014-09-06 22:50:06 +09:00
Yukihiro "Matz" Matsumoto cc98f191fa Merge pull request #2587 from take-cheeze/fix_def_gem_load
Fix default gem loading in `generate_gem_table`.
2014-09-05 16:43:37 +09:00
take_cheeze e6ae5c8672 Fix default gem loading in generate_gem_table. 2014-09-05 15:25:24 +09:00
Yukihiro "Matz" Matsumoto 3f70edbd16 support native byteorder in mrb files; ref 3492be 2014-09-05 11:09:44 +09:00
Yukihiro "Matz" Matsumoto 5b235a8bfa condition refactoring in load.c 2014-09-05 10:55:09 +09:00
Yukihiro "Matz" Matsumoto 81c894a1c6 add some MRB_API to function prototypes 2014-09-05 00:54:51 +09:00
Yukihiro "Matz" Matsumoto 8696986994 Merge branch 'cremno-add-symbol-table-overflow-check' 2014-09-05 00:47:36 +09:00
Yukihiro "Matz" Matsumoto 9b4ec380d2 use uint16_t instead of short; ref #2568 2014-09-05 00:47:22 +09:00
Yukihiro "Matz" Matsumoto 33e44a612c refactor MACRO to avoid local variable name conflict; ref #2585 2014-09-04 23:59:27 +09:00
Yukihiro "Matz" Matsumoto 606307d371 Merge pull request #2585 from cremno/get-rid-of-shadowing-variables-mrbgems
get rid of shadowing variables (mrbgems)
2014-09-04 23:52:57 +09:00
Yukihiro "Matz" Matsumoto f25d95a23f Merge pull request #2586 from cremno/fix-strict-aliasing-rule-violation
fix strict aliasing rule violation
2014-09-04 23:51:59 +09:00
cremno 610d1d4afa fix strict aliasing rule violation 2014-09-04 12:34:37 +02:00
cremno fec2c66ea8 get rid of shadowing variables (mrbgems)
Mostly renaming, except that the definition of struct accessor methods
is now done in a new function.
2014-09-04 12:31:52 +02:00
Yukihiro "Matz" Matsumoto 6b302d80a3 instance variable name validation based on <ctype.h>; fix #2584 2014-09-04 18:36:28 +09:00
Yukihiro "Matz" Matsumoto 32aee72d29 wrong iseq conversion flag 2014-09-04 18:28:56 +09:00
Yukihiro "Matz" Matsumoto 3492be401a avoid iseq allocation from static irep binary. it reduces 424KB allocation for mrbtest 2014-09-04 17:16:34 +09:00
Yukihiro "Matz" Matsumoto dc3c91dfdc rename a local variable current_node -> nodetype; ref #2583 2014-09-04 08:33:18 +09:00
Yukihiro "Matz" Matsumoto 27ac09be9d Merge pull request #2583 from cremno/get-rid-of-shadowing-variables
get rid of shadowing variables
2014-09-04 08:31:33 +09:00
cremno 26bbc81e12 get rid of shadowing variables
Mostly by renaming the shadowing variable.
If a shadowing variable was deleted,
the shadowed one can be used instead.
2014-09-03 10:00:37 +02:00
Yukihiro "Matz" Matsumoto 1fdf47d71a Merge pull request #2582 from iij/pr-attr-accessor-save-arena
save and restore arena index to prevent arena overflow.
2014-09-03 11:02:52 +09:00
Tomoyuki Sahara 2fd49b2b9f save and restore arena index to prevent arena overflow. 2014-09-03 10:44:38 +09:00
Yukihiro "Matz" Matsumoto f6e7de5fa8 Merge pull request #2581 from cubicdaiya/issues/use_lit
Use mrb_str_cat_lit() instead of mrb_str_cat_cstr() for string-literals.
2014-09-03 09:01:12 +09:00
Tatsuhiko Kubo b9acd20aef Use mrb_str_cat_lit() instead of mrb_str_cat_cstr() for string-literals. 2014-09-03 01:43:46 +09:00
Yukihiro "Matz" Matsumoto 80c37a4138 Merge pull request #2580 from suzukaze/refactor-kernel.c
Refactor kernel.c
2014-09-02 22:51:02 +09:00
Jun Hiroe f7a7426d7e Refactor mrb_obj_is_kind_of_m() in kernel.c 2014-09-02 19:40:29 +09:00
Jun Hiroe 3e40cc6974 Refactor obj_is_instance_of() in kernel.c 2014-09-02 19:40:23 +09:00
Yukihiro "Matz" Matsumoto 90ba47ccfe implement attr_reader and attr_writer in C; use cfunc closure to speed-up 2014-09-02 16:41:38 +09:00
Yukihiro "Matz" Matsumoto 6c7b0d88e8 refactor valid instance variable name check 2014-09-02 16:37:40 +09:00
Yukihiro "Matz" Matsumoto 471c43ff96 move mrb_proc_new_cfunc_with_env() to the core 2014-09-02 13:03:32 +09:00
Yukihiro "Matz" Matsumoto 7c49d56ce6 attr_reader and attr_writer should return nil 2014-09-01 16:58:04 +09:00
Yukihiro "Matz" Matsumoto 7ac68809d3 remove ci->nreg initialization from cipush() 2014-09-01 15:38:25 +09:00
Yukihiro "Matz" Matsumoto 296b0571be remove unnecessary MRB_API from mrb_num_div(); close #2578 2014-08-30 16:15:31 +09:00
Yukihiro "Matz" Matsumoto e91389f922 Merge pull request #2577 from cremno/remove-obsolete-macros
delete obsolete macros (mrb_basic + mrb_object)
2014-08-30 10:24:48 +09:00
Yukihiro "Matz" Matsumoto 5e9689c449 Merge pull request #2576 from cremno/correctly-validate-symbol-length
correctly validate symbol length
2014-08-30 10:24:14 +09:00
cremno 17b0d658fc delete obsolete macros (mrb_basic + mrb_object)
Over a year ago is not "soon" anymore. See:
88483fad00
243669308d
2014-08-29 16:47:28 +02:00
cremno c219c2a15e use RITE_LV_NULL_MARK for better readability
The comment didn't say why the length is reserved.
Using RITE_LV_NULL_MARK makes things a bit clearer.
2014-08-29 15:53:52 +02:00
cremno 0e28f4b973 add sym_validate_len() to validate symbol length
This also fixes an off-by-one in mrb_check_intern().
2014-08-29 15:53:51 +02:00
Yukihiro "Matz" Matsumoto 607795ffdd more OP_MOVE swap detection in peephole optimization 2014-08-29 16:24:12 +09:00
Yukihiro "Matz" Matsumoto 3c4cd5428a allow no_optimize esp. for debugger 2014-08-29 15:09:14 +09:00
Yukihiro "Matz" Matsumoto 56384139a8 Merge pull request #2573 from cubicdaiya/issues/remove_unused_macro
Remove unused macro.
2014-08-29 11:56:05 +09:00
Tatsuhiko Kubo 6b8e06a5b9 Remove unused macro.
OutOfRange() is no longer used.
2014-08-29 02:22:55 +09:00
Yukihiro "Matz" Matsumoto a3c34c165b Merge pull request #2572 from cubicdaiya/issues/fprintf_error_handlings
Fix error handlings for fprintf() and fputs() to file.
2014-08-29 01:10:44 +09:00
Yukihiro "Matz" Matsumoto 9e4b012478 Merge pull request #2570 from cubicdaiya/issues/unify_duplicated_functions
Unify and rename duplicated functions (noregexp() and regexp_check()).
2014-08-29 01:09:33 +09:00
Yukihiro "Matz" Matsumoto 15b9771abc git push origin masterMerge branch 'cubicdaiya-issues/declare_mrb_api' 2014-08-29 01:07:12 +09:00
Tatsuhiko Kubo 5fa30aeaea Fix mismatches for MRB_API declarations. 2014-08-29 01:06:22 +09:00
Yukihiro "Matz" Matsumoto abd7cad4fd adjust node lineno of muiti line statements 2014-08-29 01:06:22 +09:00
Yukihiro "Matz" Matsumoto 4b546e2ca4 print lineno of dumping node 2014-08-29 01:06:22 +09:00
Yukihiro "Matz" Matsumoto 7477d0c18c revert 6c1dfc9; ref #2525 #2565 2014-08-29 01:06:22 +09:00
Yukihiro "Matz" Matsumoto 4077240b81 adjust node lineno of muiti line statements 2014-08-29 00:53:02 +09:00
Yukihiro "Matz" Matsumoto d4aee563f0 print lineno of dumping node 2014-08-29 00:53:02 +09:00
Tatsuhiko Kubo db29a25ada Rename functions for avoinding symbol confiliction.
Add prefix(mrb) to noregexp() and regexp_check().
2014-08-28 19:18:52 +09:00
Tatsuhiko Kubo d958aa2cb1 Unify duplicated functions (noregexp() and regexp_check()). 2014-08-28 19:13:57 +09:00
Yukihiro "Matz" Matsumoto c457aa2193 revert 6c1dfc9; ref #2525 #2565 2014-08-28 11:53:03 +09:00
Yukihiro "Matz" Matsumoto 1abbfecd9f Merge pull request #2569 from dycoon/issue2525
add write barrier to env on pop call info poped. #2525
2014-08-28 11:39:52 +09:00
dycoon 77b2ec30ff add write barrier to env on pop call info poped. #2525 2014-08-28 09:14:40 +09:00
Tatsuhiko Kubo 7d9b5132a5 Fix error handlings for fputs(). 2014-08-28 05:29:25 +09:00
Tatsuhiko Kubo 921798be01 Fix error handlings for fprintf(). 2014-08-28 05:19:09 +09:00
Yukihiro "Matz" Matsumoto 7a25b53301 Merge pull request #2567 from cubicdaiya/issues/space_after_comma2
Add a missing space after ",".
2014-08-27 23:48:34 +09:00
Yukihiro "Matz" Matsumoto 0d40047793 Merge pull request #2566 from cubicdaiya/issues/null_check
Remove discareded NULL checks and use mrb_malloc() instead of mrb_realloc().
2014-08-27 23:48:06 +09:00
cremno 89b27648dd add symbol table overflow check
Since raising an error might intern a few new strings, some symbols need
to be reserved. 8 should be sufficient.

If the real limit has been reached, mrb_bug() is called.
2014-08-27 12:51:10 +02:00
Tatsuhiko Kubo 3202938099 Add a missing space after ",". 2014-08-27 19:13:40 +09:00
Tatsuhiko Kubo cc22ec85b9 Use mrb_malloc() instead of mrb_realloc(). 2014-08-27 18:58:26 +09:00
Tatsuhiko Kubo bf173b320f Remove discareded NULL checks. 2014-08-27 18:58:26 +09:00
Yukihiro "Matz" Matsumoto ecda19f402 Merge pull request #2565 from cremno/remove-unused-msvc-strtoll-fallback
remove unused MSVC strtoll fallback
2014-08-26 09:16:46 +09:00
Yukihiro "Matz" Matsumoto d0ced41f6e Merge pull request #2563 from cremno/printf-cast-variables-to-expected-type
printf: cast variables to the expected type
2014-08-26 09:16:25 +09:00
Yukihiro "Matz" Matsumoto 3979dd0250 Merge pull request #2564 from cremno/use-mrb_stringize
use MRB_STRINGIZE
2014-08-26 09:15:50 +09:00
cremno 3ac4c24534 remove unused MSVC strtoll fallback 2014-08-26 00:52:31 +02:00
cremno bdaa12de1d use MRB_STRINGIZE
It's defined in mruby/version.h which gets included in mruby.h, so it's
safe to use.
2014-08-26 00:32:06 +02:00
cremno bdf6ce34ce printf: cast variables to the expected type
%x expects unsigned int and %p expects void *

GCC emits a diagnostic about %p/void* in pedantic mode:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=26542
2014-08-26 00:30:33 +02:00
Yukihiro "Matz" Matsumoto 73a012c808 Merge pull request #2561 from cubicdaiya/issues/space_EOL
Remove spaces in end-of-line.
2014-08-26 02:25:05 +09:00
Yukihiro "Matz" Matsumoto ecc77829ce Merge pull request #2562 from cubicdaiya/issues/pow_flo
Fix and add test for Numeric#pow behavior.
2014-08-26 02:24:18 +09:00
Tatsuhiko Kubo bd6dc0da77 Add test for Numeric#pow. 2014-08-25 17:18:24 +09:00
Tatsuhiko Kubo 0e9f98c430 Fix Numeric#pow behavior.
* Before

2 ** -1 #=> 0

 * After

2 ** -1 #=> 0.5
2014-08-25 17:17:37 +09:00
Tatsuhiko Kubo 6961317fb3 Remove spaces in end-of-line. 2014-08-25 16:49:15 +09:00
Yukihiro "Matz" Matsumoto b01b3c4472 Merge pull request #2555 from cubicdaiya/issues/reduce_strlen
Use sizeof() instead of strlen().
2014-08-22 20:42:47 +09:00
Tatsuhiko Kubo 6c7ba826dd Use sizeof() instead of strlen(). 2014-08-22 20:37:34 +09:00
Yukihiro "Matz" Matsumoto 84b245066e Merge pull request #2553 from bggd/patch-6
Fix build failed on VS2012
2014-08-22 20:04:47 +09:00
bggd dc1dcba935 Update math.c 2014-08-22 16:51:04 +09:00
Yukihiro "Matz" Matsumoto e3d92d8cf8 Merge pull request #2552 from cubicdaiya/issues/eval_return_value_mrb_method_search
Remove a discarded comparison.
2014-08-22 07:56:12 +09:00
Yukihiro "Matz" Matsumoto 26398996f9 Merge pull request #2550 from cubicdaiya/issues/unify_include_guards
Unify include guard styles and header comments.
2014-08-22 07:55:38 +09:00
Yukihiro "Matz" Matsumoto 5aa6f8ba96 Merge pull request #2551 from cubicdaiya/issues/use_mrb_str_cat_lit
use mrb_str_cat_lit() instead of mrb_str_cat_cstr().
2014-08-22 00:31:00 +09:00
Yukihiro "Matz" Matsumoto 015087c57f Merge pull request #2549 from kkkkkt/fix_indent_and_refactor
changed to call check_cv_name_str in check_cv_name_sym and adjust indent
2014-08-21 23:13:24 +09:00
Tatsuhiko Kubo 45103ebc20 use mrb_str_cat_lit() instead of mrb_str_cat_cstr(). 2014-08-21 16:51:08 +09:00
kkkkkt d94469ac23 changed to call check_cv_name_str in check_cv_name_sym and adjust indent 2014-08-21 13:56:43 +09:00
Tatsuhiko Kubo 3b904e9408 Unify include guard styles and header comments. 2014-08-21 13:27:37 +09:00
Tatsuhiko Kubo 3f685533b8 Remove a discarded comparison.
mrb_method_search() does not return NULL.
Instead it raises an exception.
So it is not necessary to evaluate
a return value of mrb_method_search().
2014-08-21 12:43:20 +09:00
Yukihiro "Matz" Matsumoto 4d72d65db1 Merge pull request #2548 from take-cheeze/mrb_data_init
Add API `mrb_data_init` to initialize `MRB_TT_DATA` tagged instance.
2014-08-20 23:42:05 +09:00
Yukihiro "Matz" Matsumoto ae28365341 Merge branch 'master' of github.com:mruby/mruby 2014-08-20 23:39:48 +09:00
Yukihiro "Matz" Matsumoto e73a091343 Merge branch 'cubicdaiya-issues/scope_new_error_handlings' 2014-08-20 23:38:49 +09:00
Yukihiro "Matz" Matsumoto 05ede52239 should use non NULL scope for raise_error(); ref #2547 2014-08-20 23:38:37 +09:00
Yukihiro "Matz" Matsumoto 399f88fa7b Merge pull request #2546 from cubicdaiya/issues/emptylines
Remove empty lines.
2014-08-20 23:34:37 +09:00
take_cheeze b3d0585fe5 Add API mrb_data_init to initialize MRB_TT_DATA tagged instance. 2014-08-20 22:42:35 +09:00
Tatsuhiko Kubo ae2d49811a Fix allocation-error-handlings for scope_new(). 2014-08-20 12:25:29 +09:00
Tatsuhiko Kubo 2b283393c6 Remove empty lines. 2014-08-20 12:07:36 +09:00
Yukihiro "Matz" Matsumoto f6f31a8ecd Merge pull request #2545 from cubicdaiya/issues/use_null_insteadof_zero
Use specified macro(NULL) instead of magic-number.
2014-08-20 09:26:46 +09:00
Yukihiro "Matz" Matsumoto 1251b0d5c9 Merge pull request #2542 from cubicdaiya/issues/mrb_pool_realloc_error_handlings
Fix error handling for mrb_pool_realloc().
2014-08-20 09:26:11 +09:00
Yukihiro "Matz" Matsumoto bceaade168 Merge pull request #2543 from cubicdaiya/issues/mrb_open_allocf_error_handlings
Fix error handling for mrb_open_allocf().
2014-08-20 09:25:33 +09:00
Yukihiro "Matz" Matsumoto 28cf769a6e Merge pull request #2544 from cubicdaiya/issues/mrb_open_core_error_handling
Fix error handlings for mrb_open_core().
2014-08-20 09:25:10 +09:00
Tatsuhiko Kubo effc44f265 Fix error handlings for mrb_open_core(). 2014-08-20 05:48:09 +09:00
Tatsuhiko Kubo 53a7549e1c Fix error handling for mrb_open_allocf().
When DISABLE_GEMS is not defined and
a return value of mrb_open_core() is NULL,
mrb_open_allocf() may cause SEGV.
2014-08-20 05:15:21 +09:00
Tatsuhiko Kubo 5ee00453e0 Fix error handling for mrb_pool_realloc().
mrb_pool_alloc() may return NULL.
2014-08-20 05:07:40 +09:00
Tatsuhiko Kubo ae306793f2 Use specified macro(NULL) instead of magic-number. 2014-08-20 04:34:03 +09:00
Yukihiro "Matz" Matsumoto d49f8517a6 Merge pull request #2540 from cubicdaiya/issues/read_irep_record_error_handlings
Fix error hanldlings in read_irep_record().
2014-08-19 21:52:23 +09:00
Yukihiro "Matz" Matsumoto c7fda2232b Merge pull request #2541 from cubicdaiya/issues/codegen_error_handling
Fix error handling for mrb_generate_code().
2014-08-19 20:11:59 +09:00
Tatsuhiko Kubo e035508efd Fix error handling for mrb_generate_code().
The return value of mrb_generate_code()
must be null-checked before referencing.
2014-08-19 17:50:07 +09:00
Tatsuhiko Kubo ff9582833d Fix error hanldlings in read_irep_record().
read_irep_record_1() and read_irep_record() may return NULL.
2014-08-19 17:42:20 +09:00
Yukihiro "Matz" Matsumoto f62dc56ba2 Merge pull request #2539 from cubicdaiya/issues/mirb_error_handlings
Fix error handlings in mirb.
2014-08-19 16:18:06 +09:00
Tatsuhiko Kubo 55ee7fe79c Fix error handlings in mirb.
mrb_parser_new() and mrb_generate_code() may return NULL.
2014-08-19 16:04:48 +09:00
Yukihiro "Matz" Matsumoto 444e4b7976 Merge pull request #2538 from kkkkkt/refactor-method
refactor mruby method(fix indent. remove temporary value etc)
2014-08-19 10:32:39 +09:00
kkkkkt 2f1d12c717 revert mrb_equal method 2014-08-18 18:54:46 +09:00
kkkkkt 9da37cdfd1 refactor mruby method(fix indent. remove temporary value, duplicate procedure) 2014-08-18 10:58:48 +09:00
Yukihiro "Matz" Matsumoto 98a95530c2 Merge pull request #2537 from chasonr/math-functions
Improve replacement math functions for Visual C++.
2014-08-16 17:56:02 +09:00
Yukihiro "Matz" Matsumoto 47ab5138d2 Merge pull request #2536 from kkkkkt/refactor-classc
Refactor classc
2014-08-16 17:55:04 +09:00
chasonr e23deaafc2 Improve replacement math functions for Visual C++. 2014-08-15 23:15:45 -04:00
go kikuta 14c36f9f21 use mrb_false_value instead of mrb_bool_value 2014-08-16 02:08:51 +09:00
go kikuta 1c3d05b5b6 refactor class.c methods (fix indent, remove unneed temp value. ) 2014-08-16 02:06:05 +09:00
Yukihiro "Matz" Matsumoto ea959d4436 Merge pull request #2535 from kkkkkt/remove-unused-variable
removed unused variable in range_beg_len
2014-08-16 01:16:23 +09:00
go kikuta d5fd823d82 removed unused variable in range_beg_len 2014-08-16 01:09:40 +09:00
Yukihiro "Matz" Matsumoto 6496195d21 Merge pull request #2533 from suzukaze/fix-indents
Fix indents in numeric.c
2014-08-15 22:59:18 +09:00
Yukihiro "Matz" Matsumoto c066cf4585 Merge pull request #2534 from suzukaze/refactor-numeric.c
Refactor flo_mod func in numeric.c
2014-08-15 22:59:00 +09:00
Jun Hiroe 2ba257ccb4 Fix indents in numeric.c 2014-08-15 20:51:43 +09:00
Jun Hiroe 9b176207a4 Refactor flo_mod func in numeric.c 2014-08-15 20:50:20 +09:00
Yukihiro "Matz" Matsumoto 8a2291b2cd Merge pull request #2532 from chasonr/float-to-string
Remove some roundoff from mrb_flo_to_str
2014-08-14 12:43:06 +09:00
chasonr f7389bb1e6 Remove some roundoff from mrb_flo_to_str 2014-08-13 23:31:22 -04:00
Yukihiro "Matz" Matsumoto 6c1dfc9566 need to add space for receiver to proc env; fix #2525 2014-08-13 23:58:32 +09:00
Yukihiro "Matz" Matsumoto 2b9e5e751b add write barrier when iv is copied 2014-08-13 22:55:32 +09:00
Yukihiro "Matz" Matsumoto 170ba511f2 remove unnecessary mrb_float casting; ref #2531 2014-08-13 21:58:52 +09:00
Yukihiro "Matz" Matsumoto 598ff395b4 Merge pull request #2531 from kkkkkt/refactor-numeric-hash-method
refactor mrb_hash_shift, num_pow, flo_eq, flo_finite_p method
2014-08-13 21:57:46 +09:00
kkkkkt a9b37bff4b refactor mrb_hash_shift, num_pow, flo_eq, flo_finite_p method 2014-08-13 18:26:58 +09:00
Yukihiro "Matz" Matsumoto ad7085e475 Merge pull request #2529 from kkkkkt/change-string-method-mrb-aspec
changed some string method's mrb-aspec
2014-08-12 18:46:06 +09:00
kkkkkt b27738f036 changed some string method's mrb-aspec 2014-08-12 16:20:02 +09:00
Yukihiro "Matz" Matsumoto fa3629b42c Merge pull request #2527 from iij/pr-remove-mrb_str_bytesize
mrb_str_bytesize is a carbon copy of mrb_str_size.  remove it.
2014-08-11 20:31:34 +09:00
Tomoyuki Sahara c4f5c2473a mrb_str_bytesize is a carbon copy of mrb_str_size. remove it.
mruby core does not support any character encodings but ASCII.
2014-08-11 17:46:40 +09:00
Yukihiro "Matz" Matsumoto 712ad32b2a Merge pull request #2526 from iij/pr-test-only-gem
fix build when neither src nor mrblib directory exists.
2014-08-11 17:43:33 +09:00
Tomoyuki Sahara 547f3177a9 fix build when neither src nor mrblib directory exists. 2014-08-11 17:30:21 +09:00
Yukihiro "Matz" Matsumoto 2d5943b696 Merge pull request #2524 from mattn/fix-succ
Fix String#succ. "-".succ should be "."
2014-08-11 17:24:11 +09:00
Yukihiro "Matz" Matsumoto 4c0f40f6a5 Merge pull request #2523 from kkkkkt/changed_string_method_comment
changed mrb_str_size and mrb_str_bytesize comments.
2014-08-11 17:22:37 +09:00
mattn 4ece1e3e29 "-a-a-".succ should be "-a-b-" 2014-08-11 15:00:44 +09:00
mattn 3103d063e2 Fix String#succ. "-a-".succ should be "-b-" 2014-08-11 14:28:05 +09:00
mattn 34f40b0a01 Fix String#succ. "-".succ should be "." 2014-08-11 14:01:10 +09:00
kkkkkt 513be0052e changed mrb_str_size and mrb_str_bytesize comments. 2014-08-11 12:02:31 +09:00
Yukihiro "Matz" Matsumoto 2b74fa54de Merge pull request #2503 from cremno/dont-always-generate-gem-functions
don't always generate gem functions
2014-08-09 23:34:38 +09:00
Yukihiro "Matz" Matsumoto f3f54cb619 Merge pull request #2522 from dycoon/debug_timer
timer on windows bug fixed.
2014-08-09 22:09:48 +09:00
dycoon e7249e4590 timer on windows bug fixed. 2014-08-09 21:40:52 +09:00
Yukihiro "Matz" Matsumoto 67153b0f17 Merge pull request #2521 from kou/fix-class-variable-and-singleton-class-method
Fix a bug that class variable can't be referenced from class method
2014-08-09 15:52:41 +09:00
Kouhei Sutou e75e2083fd Fix a bug that class variable can't be referenced from class method
Class method defined in singleton class should be evaluated in class
context not singleton class context.

fix #2515
2014-08-09 15:06:17 +09:00
Yukihiro "Matz" Matsumoto 39488f0baf git push origin masterMerge branch 'mattn-string-succ' 2014-08-08 23:16:30 +09:00
Yukihiro "Matz" Matsumoto 7a5d3c19c6 remove test for succ on Unicode (non-ASCII) char; #2520 2014-08-08 23:16:12 +09:00
Yukihiro "Matz" Matsumoto 0381de3ee6 Merge branch 'string-succ' of https://github.com/mattn/mruby into mattn-string-succ 2014-08-08 23:15:14 +09:00
Tomoyuki Sahara 190264b3c8 Merge pull request #23 from jbreeden/master
Correcting E_NOTIMP_ERROR reference
2014-08-08 21:34:15 +09:00
mattn dc0c354658 Add String#succ, String#succ!, String#next, String#next! 2014-08-08 17:58:07 +09:00
Yukihiro "Matz" Matsumoto b54682bb8e Merge pull request #2519 from SatoshiOdawara/fix_context_of_eval
fixed evaluation context of eval(string) and instance_eval(string)
2014-08-08 17:13:27 +09:00
Satoshi Odawara 432e8e9ea9 fixed evaluation context of eval(string) and instance_eval(string) 2014-08-08 16:59:40 +09:00
Yukihiro "Matz" Matsumoto 569c7dec5f move StopIteration to core; close #2518 2014-08-08 16:08:53 +09:00
Yukihiro "Matz" Matsumoto 0e45aa0066 Merge pull request #2517 from kkkkkt/remove_nonneed_space
removed non-need space
2014-08-08 12:11:40 +09:00
Yukihiro "Matz" Matsumoto b609054f75 Merge pull request #2516 from suzukaze/fix-typo-gc
Fix typo in gc.c
2014-08-08 12:11:03 +09:00
go kikuta 513f24e908 removed non-need space 2014-08-07 23:11:10 +09:00
Jun Hiroe 33ace171c4 Fix typo in gc.c 2014-08-07 21:16:32 +09:00
Yukihiro "Matz" Matsumoto 918d4dc85c Merge pull request #2512 from suzukaze/gc-state-root
Rename GC_STATE_NONE GC_STATE_ROOT
2014-08-07 00:01:31 +09:00
Yukihiro "Matz" Matsumoto f42e6287b8 Merge pull request #2513 from suzukaze/refactor-gc
Refactor incremental_sweep_phase() in gc.c
2014-08-07 00:00:31 +09:00
Jun Hiroe 5eb3a8caa6 Refactor incremental_sweep_phase() in gc.c 2014-08-06 23:22:05 +09:00
Yukihiro "Matz" Matsumoto 62776e8940 Merge pull request #2511 from bggd/patch-5
Fix a typo in etc.c
2014-08-06 23:11:27 +09:00
Jun Hiroe 21f583783d Rename GC_STATE_NONE GC_STATE_ROOT 2014-08-06 22:59:48 +09:00
bggd d95f77c1cb Fix a typo in etc.c 2014-08-06 21:36:36 +09:00
Yukihiro "Matz" Matsumoto 8dbf7787d5 Merge pull request #2510 from cremno/mruby-strip-use-mrb_open_core
mruby-strip doesn't need mrbgems
2014-08-06 11:48:10 +09:00
Yukihiro "Matz" Matsumoto 1ff32cfb3a Merge pull request #2509 from suzukaze/refactor-gc
Refactor obj_free() in gc.c
2014-08-06 11:47:28 +09:00
Jun Hiroe 3569723ab3 Refactor obj_free() in gc.c 2014-08-05 23:16:01 +09:00
Yukihiro "Matz" Matsumoto fce644df59 Merge pull request #2508 from iij/pr-mrb-str-to-cstr-returns-mutable
revert accidental constify.
2014-08-05 16:32:52 +09:00
Tomoyuki Sahara 412b9eb827 revert accidental constify. 2014-08-05 15:02:27 +09:00
Yukihiro "Matz" Matsumoto e41fd5c0d6 Merge pull request #2507 from kkkkkt/add_cos_tan_testcase
added Math.cos and Math.tan test case
2014-08-05 14:30:19 +09:00
Akito Mochizuki 0761b17245 update implemented methods table 2014-08-05 11:51:05 +09:00
Yukihiro "Matz" Matsumoto 0786d86bfe git push origin masterMerge branch 'suzukaze-add-gc-docs' 2014-08-05 11:29:16 +09:00
Yukihiro "Matz" Matsumoto 58cb1a2e8b write barrier doc update 2014-08-05 11:29:08 +09:00
kkkkkt 9c78fc8443 added Math.cos and Math.tan test case 2014-08-05 11:27:50 +09:00
Yukihiro "Matz" Matsumoto 920ce88b50 Merge branch 'add-gc-docs' of https://github.com/suzukaze/mruby into suzukaze-add-gc-docs 2014-08-05 11:21:45 +09:00
Jun Hiroe b20121f9e6 Add write_barrier docs 2014-08-05 02:10:02 +09:00
Yukihiro "Matz" Matsumoto 53687a849b Merge branch 'master' of github.com:mruby/mruby 2014-08-04 22:36:09 +09:00
Yukihiro "Matz" Matsumoto a18c575614 Merge pull request #2502 from cremno/fix-range_beg_len-linkage
fix linkage of range_beg_len and mrb_range_beg_len
2014-08-04 22:35:41 +09:00
cremno cc4c22c5f5 mruby-strip doesn't need mrbgems
Reduces executable size by more than 50% (409->171 KB).
2014-08-04 12:26:36 +02:00
Yukihiro "Matz" Matsumoto ea80e82852 Merge branch 'master' of github.com:mruby/mruby 2014-08-04 16:28:02 +09:00
cremno 3bf244e67c fix linkage of range_beg_len and mrb_range_beg_len 2014-08-04 05:52:09 +02:00
cremno 6526bb10f0 don't always generate gem functions
If the src and mrblib directories of a mrbgem don't exist or don't
include "usable" files (for tools like mirb), then functions for gem
initialization and finalization don't have to be generated.
2014-08-04 05:50:05 +02:00
Yukihiro "Matz" Matsumoto 0fa3668e91 Merge pull request #2498 from cremno/msvc-snprintf
MSVC: add simple (v)snprintf implementation
2014-08-04 10:51:32 +09:00
Yukihiro "Matz" Matsumoto 29bfbac86d Merge pull request #2501 from cremno/static-mrb_str_size
change linkage of mrb_str_size to internal
2014-08-04 10:48:11 +09:00
Yukihiro "Matz" Matsumoto 50a6b48d53 Merge pull request #2497 from cremno/fix-conversion-warnings
fix conversion warnings (in gc.c)
2014-08-04 10:44:44 +09:00
Yukihiro "Matz" Matsumoto 37a75b096e Merge pull request #2496 from cremno/remove-unnecessary-char_bit-check
remove unnecessary CHAR_BIT != 8 check
2014-08-04 10:44:05 +09:00
cremno 7dabb33cf0 change linkage of mrb_str_size to internal
Use RSTRING_LEN to get the length.
2014-08-04 01:14:23 +02:00
jbreeden 9a2cbc4122 Correcting E_NOTIMP_ERROR reference 2014-08-03 16:45:46 -04:00
cremno b6e27218ad MSVC: add simple (v)snprintf implementation
_snprintf is not C99's snprintf!

This simple implementation, unlike _snprintf,
always null-terminates and returns the expected
return value (in most cases).
Other C99 behaviors (like format specifiers) require
adding a complete snprintf implementation.
Do we want or need that?

The same applies to vsnprintf (aka _vsnprintf).
2014-08-03 21:15:48 +02:00
cremno a70413c4ea fix conversion warnings
Those warnings are not enabled by default,
but getting rid of them doesn't hurt.
2014-08-03 19:54:31 +02:00
Yukihiro "Matz" Matsumoto db7b01c0b3 turn string obsolete functions into macros 2014-08-04 00:53:58 +09:00
Yukihiro "Matz" Matsumoto 6aa6e75f75 rename obsolete mrb_special_const_p to mrb_immediate_p 2014-08-04 00:50:03 +09:00
Yukihiro "Matz" Matsumoto 206f89e209 add MRB_API modifiers to mruby API functions 2014-08-04 00:47:08 +09:00
Yukihiro "Matz" Matsumoto 0878900fda Time#to_i and Time#usec should care about mrb_int overflow on MRB_INT16; ref #2495 2014-08-03 20:36:20 +09:00
Yukihiro "Matz" Matsumoto 5e5fad2f25 fix typo with MRB_INT16; fix #2495 2014-08-03 20:30:29 +09:00
Yukihiro "Matz" Matsumoto 0ad6a521ec Merge pull request #2494 from suzukaze/refactor-variable.c
Use Boolean macro in variable.c
2014-08-02 21:35:35 +09:00
Jun Hiroe 41fddeded0 Use Boolean macro in variable.c 2014-08-02 13:56:22 +09:00
cremno df21609a20 remove unnecessary CHAR_BIT != 8 check
mruby uses uint8_t which implies CHAR_BIT == 8.
2014-08-02 02:06:42 +02:00
Yukihiro "Matz" Matsumoto 16ddb16608 Merge pull request #2462 from cremno/mirb-malloc-history_path
mirb: allocate `history_path` dynamically
2014-07-30 08:41:26 +09:00
Tomoyuki Sahara e60951a305 add IO#sync and IO#sync= 2014-07-29 10:55:02 +09:00
Yukihiro "Matz" Matsumoto 23b6e22cf0 Merge pull request #2490 from suzukaze/refactor_symbol
Refactor sym_equal() in symbol.c
2014-07-27 19:54:42 +09:00
Jun Hiroe 18d8f9d124 Refactor sym_equal() in symbol.c 2014-07-27 15:56:21 +09:00
Yukihiro "Matz" Matsumoto e2f7e485e7 Merge pull request #2478 from dreamedge/add_module_function
add Module#module_function
2014-07-26 09:35:58 +09:00
Yukihiro "Matz" Matsumoto 875c07a742 Merge pull request #2477 from take-cheeze/allocf_ud
Add field `allocf_ud` to replace current `ud`.
2014-07-24 23:22:58 +09:00
Yukihiro "Matz" Matsumoto 6055ebaf78 Merge pull request #2489 from Ancurio/silence_cpp_warn
Silence "unused parameter" warnings in C++
2014-07-24 06:40:51 +09:00
Jonas Kulla ec606e3aa7 Silence "unused parameter" warnings in C++
This has been done already, but the fixes were accidentally
removed in 249f05e7d7.
2014-07-23 21:40:15 +02:00
Yukihiro "Matz" Matsumoto 40e46944a2 Merge pull request #2488 from ksss/leak-test
Fix memory leak for test driver
2014-07-24 00:05:37 +09:00
ksss 67fbcf8b2a Fix memory leak for test driver 2014-07-23 14:14:09 +00:00
Yukihiro "Matz" Matsumoto 1b5584b3c8 check if block is given in eval_under(); fix #2486 2014-07-23 02:08:37 +09:00
Tomoyuki Sahara 1768ee02e5 remove extra ';'. 2014-07-22 23:55:25 +09:00
Yukihiro "Matz" Matsumoto 6d742ef93a Merge pull request #2482 from take-cheeze/exc_tt
Use MRB_TT_EXCEPTION in exception object.
2014-07-22 15:35:16 +09:00
Tomoyuki Sahara 8c34a8d561 Merge pull request #22 from take-cheeze/fix_arg
Fix type of argument passed to mrb_get_args.
2014-07-22 15:30:57 +09:00
Yukihiro "Matz" Matsumoto 4b69121284 restore mrb_get_args() in f_instance_eval to check arguments type 2014-07-22 08:38:38 +09:00
Yukihiro "Matz" Matsumoto 7457da6aa1 exception in instance_eval should not exit mrb_run; fix #2483 2014-07-22 07:29:26 +09:00
take_cheeze 3c96602574 Use MRB_TT_EXCEPTION in exception object. 2014-07-21 23:09:13 +09:00
Yukihiro "Matz" Matsumoto 4cc9e5d8b1 since #1441, NaN boxing with 64bit pointer works; close #2476 2014-07-21 21:55:52 +09:00
Yukihiro "Matz" Matsumoto beafed1104 Merge pull request #2481 from take-cheeze/move_word_box_struct
Move word boxing structs to "mruby/boxing_word.h".
2014-07-21 07:10:14 +09:00
take_cheeze fc8b48faf8 Move word boxing structs to "mruby/boxing_word.h". 2014-07-20 23:02:04 +09:00
Yukihiro "Matz" Matsumoto a3ac3623f0 Merge pull request #2480 from take-cheeze/test_backtrace
Print backtrace of crashed test in verbose mode.
2014-07-20 18:04:06 +09:00
take_cheeze a24729044a Print backtrace of crashed test in verbose mode. 2014-07-19 22:33:13 +09:00
take_cheeze 689541d0fb Fix type of argument passed to mrb_get_args. 2014-07-19 21:37:13 +09:00
dreamedge 0b8a0f4bb4 add Module#module_function 2014-07-18 09:50:54 +09:00
take_cheeze fc9a91c4a6 Add field allocf_ud to replace current ud.
Since some use it as `mrb_state` associated user data.
2014-07-17 21:48:17 +09:00
Yukihiro "Matz" Matsumoto d17506c176 Merge branch 'master' of github.com:mruby/mruby 2014-07-17 01:42:22 +09:00
Yukihiro "Matz" Matsumoto 1dc6a8c872 avoid infinite recursion when error was happened in #inspect; fix #2474 2014-07-17 01:42:03 +09:00
Yukihiro "Matz" Matsumoto ce7dfe97ad Merge pull request #2475 from take-cheeze/full_core_list
Check mrbgem.rake instead of directory to ignore empty directories in full-core gembox.
2014-07-17 01:28:36 +09:00
take_cheeze 568b2c79b1 Check mrbgem.rake instead of directory to ignore empty directories in full-core. 2014-07-16 22:49:06 +09:00
Yukihiro "Matz" Matsumoto 2dcc2444fa need to call write_barrier on every fiber context switch 2014-07-16 12:58:37 +09:00
Yukihiro "Matz" Matsumoto f8aac56df0 git push origin masterMerge branch 'take-cheeze-instance_eval' 2014-07-16 05:22:04 +09:00
Yukihiro "Matz" Matsumoto abf52c7773 remove unused local variables; ref #2473 2014-07-16 05:21:55 +09:00
take_cheeze dd34decdfc Implement string compiling instance_eval method. 2014-07-15 22:33:14 +09:00
Yukihiro "Matz" Matsumoto d5dd3e9472 fiber stack allocation size should be bigger than irep->nregs 2014-07-15 17:17:58 +09:00
Yukihiro "Matz" Matsumoto 472a1c244e backtrace supression condition was wrong; fix #2472 2014-07-15 08:34:34 +09:00
Yukihiro "Matz" Matsumoto f116097702 Merge pull request #2471 from take-cheeze/const_defined_at_ret
Use `mrb_bool` as return type of `mrb_const_defined_at`.
2014-07-15 01:19:19 +09:00
Yukihiro "Matz" Matsumoto fc8513dc95 Merge pull request #2464 from take-cheeze/inherit_verbose_flag
Inherit `$mrbtest_verbose` flag in core tests.
2014-07-15 00:06:39 +09:00
take_cheeze a9c52675e6 Set $mrbtest_verbose flag in mrb_init_test_driver. 2014-07-14 21:11:14 +09:00
take_cheeze dbece716ea Use mrb_bool as return type of mrb_const_defined_at. 2014-07-14 21:04:22 +09:00
Yukihiro "Matz" Matsumoto 23c811bda6 Merge pull request #2465 from cubicdaiya/feature/comment_style
use C style comments instead of C++ style comments
2014-07-13 08:12:14 +09:00
Tatsuhiko Kubo 5b5313ec97 use C style comments instead of C++ style comments 2014-07-13 00:24:45 +09:00
Yukihiro "Matz" Matsumoto ee9d409eed Merge pull request #2463 from take-cheeze/fix_rake
Fix rake failure since `mrbtest_objs` isn't flattened.
2014-07-12 23:28:19 +09:00
Yukihiro "Matz" Matsumoto c41f39578c Merge branch 'master' of github.com:mruby/mruby 2014-07-12 23:22:34 +09:00
Yukihiro "Matz" Matsumoto 79fb18445d rescue SystemStackError that comes from inspecting self-referencing Hashes and Arrays; fix #2461 2014-07-12 23:22:20 +09:00
Yukihiro "Matz" Matsumoto 6137bf9e71 avoid print backtrace for SystemStackError 2014-07-12 22:10:48 +09:00
take_cheeze 3b8a797a4c Fix rake failure since mrbtest_objs isn't flattened.
Append generated test object to `@test_objs` of mrbgem spec.
Add method `custom_test_init?` to check whether mrbgem has custom test init function.
2014-07-12 21:41:44 +09:00
Yukihiro "Matz" Matsumoto 4501598f27 use SystemStackError instead of RuntimeError 2014-07-12 21:29:46 +09:00
take_cheeze 4a6c651f82 Run mrbgem and core tests on minimum dependencies.
Solves #2355.

In test drivers:
* Uses `mrb_t_pass_result` to check and pass test result to main `mrb_state`.
* Adds `mrb_init_test_driver` to init test `mrb_state`.
2014-07-12 20:36:45 +09:00
cremno aff65afe97 check the return value of fwrite 2014-07-12 20:36:45 +09:00
Yukihiro "Matz" Matsumoto 61ce5892cc remove spaces after open parens 2014-07-12 20:36:45 +09:00
cremno 02d4949d5d initialize args in parse_args 2014-07-12 20:36:45 +09:00
cremno a0912df6f6 coding style adjustments 2014-07-12 20:36:44 +09:00
cremno fbcb4c20e1 update expected error message in bintest 2014-07-12 20:36:44 +09:00
cremno 85bb1f92ef rewrite stripping
Previous version ignored some errors, and didn't free memory and close files.
Now no memory will be dynamically allocated to simplify error handling.

This commit also fixes a wrong check:

  files[i] = fopen(argv[i], "wb");
  if (!ireps[i]) {

Improve error messages a bit and add missing newline to one.
2014-07-12 20:36:44 +09:00
cremno c9b7cee2f6 check mrb_open return value 2014-07-12 20:36:44 +09:00
take_cheeze c6ce43303d Add SyntaxError test and don't print compilation error to stderr in eval. 2014-07-12 20:36:44 +09:00
take_cheeze d1eea450bf Use mrb_parse_nstring instead in eval. 2014-07-12 20:36:44 +09:00
cremno 82a335643e call mrb_malloc_simple instead of malloc 2014-07-12 11:50:51 +02:00
Yukihiro "Matz" Matsumoto a16a53b5eb Merge pull request #2458 from take-cheeze/min_dep_test
Support minimum dependency test.
2014-07-12 17:50:44 +09:00
take_cheeze 03866f25f8 Run mrbgem and core tests on minimum dependencies.
Solves #2355.

In test drivers:
* Uses `mrb_t_pass_result` to check and pass test result to main `mrb_state`.
* Adds `mrb_init_test_driver` to init test `mrb_state`.
2014-07-12 14:11:18 +09:00
Yukihiro "Matz" Matsumoto 4f66de36c4 Merge pull request #2460 from cremno/mrb_dump_irep_binary-report-fwrite-failure
check the return value of `fwrite`
2014-07-12 09:43:38 +09:00
cremno 9d597f4d9f allocate history_path dynamically
`PATH_MAX` doesn't have to be defined and if it is, then its value is
usually incorrect (possible buffer overflow).
Use `malloc` and `snprintf` instead to prevent this.

https://www.gnu.org/software/hurd/community/gsoc/project_ideas/maxpath.html
2014-07-11 13:03:13 +02:00
cremno 55a31f3f23 check the return value of fwrite 2014-07-11 08:44:01 +02:00
Yukihiro "Matz" Matsumoto ec45dbe16a remove spaces after open parens 2014-07-11 09:11:49 +09:00
Yukihiro "Matz" Matsumoto e79478d0b4 Merge pull request #2457 from cremno/mruby-strip-rewrite
mruby-bin-strip rewrite
2014-07-10 08:45:21 +09:00
cremno 10bd78e85d initialize args in parse_args 2014-07-09 16:57:06 +02:00
cremno c90d923273 coding style adjustments 2014-07-09 16:57:05 +02:00
cremno b4c1a943d1 update expected error message in bintest 2014-07-09 16:57:04 +02:00
cremno 41961ae6d0 rewrite stripping
Previous version ignored some errors, and didn't free memory and close files.
Now no memory will be dynamically allocated to simplify error handling.

This commit also fixes a wrong check:

  files[i] = fopen(argv[i], "wb");
  if (!ireps[i]) {

Improve error messages a bit and add missing newline to one.
2014-07-09 16:49:47 +02:00
cremno 8df63b4d1f check mrb_open return value 2014-07-09 16:29:15 +02:00
Yukihiro "Matz" Matsumoto 835da83ca1 Merge pull request #2456 from take-cheeze/refactor_eval
Refactor eval.
2014-07-09 23:06:24 +09:00
Yukihiro "Matz" Matsumoto 42110dcee1 Merge pull request #2455 from cremno/readint_mrb_int-check-base
invalid base shouldn't silently fail
2014-07-09 23:05:01 +09:00
Yukihiro "Matz" Matsumoto 334b1ac485 Merge pull request #2454 from cremno/remove-mrb_str_body
remove unused `mrb_str_body`
2014-07-09 23:01:37 +09:00
take_cheeze dfe65423da Add SyntaxError test and don't print compilation error to stderr in eval. 2014-07-09 22:03:21 +09:00
take_cheeze b344b29345 Use mrb_parse_nstring instead in eval. 2014-07-09 22:02:33 +09:00
cremno ef59f553a3 invalid base shouldn't silently fail
Revert 44a5809224 and check range of
`base` with `mrb_assert`.
It actually can only be either 2, 8, 10 or 16 (and never 0), unless
mruby sources are modified. But I don't see a reason to impose further
limits.
2014-07-09 13:55:08 +02:00
cremno 881f054cbf remove unused mrb_str_body 2014-07-09 11:56:29 +02:00
Yukihiro "Matz" Matsumoto 023908afc2 remove unused return_value 2014-07-09 17:01:59 +09:00
Yukihiro "Matz" Matsumoto 42d4eb9fe4 Merge pull request #2452 from take-cheeze/test_exc
Use `mrb_print_error` in test error handling.
2014-07-09 13:34:38 +09:00
Tomoyuki Sahara 093f4e2cff mrb_voidp (and other macros) has gone. 2014-07-09 12:24:50 +09:00
Tomoyuki Sahara fa39825b1b refactor. 2014-07-09 10:01:33 +09:00
Tomoyuki Sahara 66a92240de Merge pull request #21 from dreamedge/add_close_on_exec
Add close on exec
2014-07-09 09:34:12 +09:00
Yukihiro "Matz" Matsumoto 506cda5a28 Merge branch 'master' of github.com:mruby/mruby 2014-07-09 07:17:40 +09:00
Yukihiro "Matz" Matsumoto 7baa56bad5 Merge branch 'AE9RB-cleanup_mrb_value' 2014-07-09 07:15:59 +09:00
Yukihiro "Matz" Matsumoto df4c298e3b rename boxing_nix.h to boxing_no.h 2014-07-09 07:06:58 +09:00
Yukihiro "Matz" Matsumoto 61bba9accf rename word boxing functions 2014-07-09 06:40:56 +09:00
Yukihiro "Matz" Matsumoto 0cf86dea0e rename SET_FIXNUM_VALUE to SET_INT_VALUE since it sets mrb_int value 2014-07-09 06:40:19 +09:00
David Turnbull 249f05e7d7 Clean up value.h and mrb_value boxing 2014-07-09 06:32:11 +09:00
dreamedge 78f5f98710 delete debug messages 2014-07-09 05:29:20 +09:00
Yukihiro "Matz" Matsumoto ef432d7524 Merge pull request #2451 from take-cheeze/remove_mem_out_check
Remove unnecessary out of memory check in `ary_expand_capa`.
2014-07-08 23:07:30 +09:00
Yukihiro "Matz" Matsumoto 94c59d0597 Merge pull request #2449 from take-cheeze/mrb_ary_resize
Add new API `mrb_ary_resize`(mruby implementation of `rb_ary_resize`).
2014-07-08 23:01:22 +09:00
take_cheeze ab779b7ad8 Use mrb_print_error to print exception instead of mrb_p. 2014-07-08 22:25:32 +09:00
take_cheeze 5bb0a1fb5e Print error instead of printing return value of report. 2014-07-08 22:24:35 +09:00
dreamedge 7e689e8680 Add IO#close_on_exec=
and a test on test/io.rb
2014-07-08 15:56:56 +09:00
take_cheeze 5b0f900faa Remove unnecessary out of memory check in ary_expand_capa.
Since `mrb_realloc` raises when failed to allocate memory.
2014-07-07 21:58:38 +09:00
dreamedge 59b7c4eaf0 add IO.close_on_exec? 2014-07-07 12:47:53 +09:00
take_cheeze 13d9631e21 Add new API mrb_ary_resize(mruby implementation of rb_ary_resize). 2014-07-06 22:23:29 +09:00
Yukihiro "Matz" Matsumoto 5c50bcd20a reformat else part; ref #2447 2014-07-06 21:00:57 +09:00
Yukihiro "Matz" Matsumoto 1300770cec Merge pull request #2447 from take-cheeze/reduce_ary_clear_alloc
Reduce allocation in shared RArray clearing.
2014-07-06 19:30:29 +09:00
take_cheeze 6cbcbd5290 Reduce allocation in shared RArray clearing. 2014-07-05 21:10:02 +09:00
Yukihiro "Matz" Matsumoto c16bb3fee3 Merge pull request #2446 from take-cheeze/fix_mrb_flo_to_fixnum
Fix type checking in `mrb_flo_to_fixnum`.
2014-07-04 21:52:51 +09:00
take_cheeze a50464fe01 Fix type checking in mrb_flo_to_fixnum. 2014-07-04 16:16:06 +09:00
Yukihiro "Matz" Matsumoto 742f85752d Merge pull request #2444 from take-cheeze/fix_mrb_hash_tbl
Always return non-NULL in `mrb_hash_tbl`.
2014-07-03 23:41:47 +09:00
take_cheeze 77aefa1d03 Always return non-NULL in mrb_hash_tbl. 2014-07-03 22:56:15 +09:00
Yukihiro "Matz" Matsumoto d2910a162d Merge pull request #2442 from suzukaze/use-mrb-str-nofree-macro
Use RSTR_NOFREE_P in state.c
2014-07-03 21:45:28 +09:00
Yukihiro "Matz" Matsumoto 65512f6557 Merge pull request #2443 from suzukaze/use-mrb-str-emebed-macro
Use *_EMBED_* macro in state.c
2014-07-03 21:44:02 +09:00
Yukihiro "Matz" Matsumoto 628615d980 Merge pull request #2432 from take-cheeze/toolchains
Add method `toolchains` and `primary_toolchain` to `MRuby::Build`.
2014-07-03 21:43:12 +09:00
Jun Hiroe 569ea74021 Use *_EMBED_* macro in state.c 2014-07-03 18:26:42 +09:00
Jun Hiroe bd82d7c794 Use RSTR_NOFREE_P in state.c 2014-07-03 18:10:51 +09:00
Yukihiro "Matz" Matsumoto 9a5f98fec8 Merge pull request #2440 from suzukaze/add-pr-docs2
Add a caution to Your Pull Request document. (suggested by Matz) close #2437
2014-07-03 08:49:05 +09:00
Jun Hiroe 954867828b Add a caution to Your Pull Request document. 2014-07-03 08:27:18 +09:00
Yukihiro "Matz" Matsumoto d8cc39e3d3 Merge branch 'master' of github.com:mruby/mruby 2014-07-03 08:12:05 +09:00
Yukihiro "Matz" Matsumoto f452abd138 fiber stack should not be cleared by zero when MRB_NAN_BOXING is set; close #2439 2014-07-03 08:11:52 +09:00
Yukihiro "Matz" Matsumoto 99438947bf Merge pull request #2438 from AE9RB/upstream
Ensure RVALUE is large enough for word boxing types.
2014-07-03 07:19:53 +09:00
David Turnbull 5486e8901a Ensure RVALUE is large enough for word boxing types. 2014-07-02 09:50:38 -07:00
Yukihiro "Matz" Matsumoto bcfcbc94bc Merge pull request #2436 from take-cheeze/mrb_args_arg
Use `MRB_ARGS_ARG(n, o)` instead of `MRB_ARGS_REQ(n) | MRB_ARGS_OPT(o)`.
2014-07-02 22:21:50 +09:00
take_cheeze 8106760077 Use MRB_ARGS_ARG(n, o) instead of MRB_ARGS_REQ(n) | MRB_ARGS_OPT(o). 2014-07-02 21:11:12 +09:00
Yukihiro "Matz" Matsumoto e749267909 time overflow check; ref #2337 2014-07-02 10:28:10 +09:00
Yukihiro "Matz" Matsumoto ad50277549 Merge pull request #2434 from AE9RB/master
Fix MRB_WORD_BOXING by correctly telling GC which mrb_value types are im...
2014-07-02 09:13:37 +09:00
Tomoyuki Sahara 91c285fcfe regen. 2014-07-02 09:12:27 +09:00
Tomoyuki Sahara 04097348e8 more TCP options (for NetBSD). 2014-07-02 09:12:04 +09:00
Tomoyuki Sahara baa40ef2b1 sort. 2014-07-02 09:09:58 +09:00
Tomoyuki Sahara 9c3c267bef Merge pull request #14 from dreamedge/add_tcp_constants
Add TCP_* constants included in "netinet/tcp.h".
2014-07-02 09:08:47 +09:00
David Turnbull ed5c13bc11 Fix MRB_WORD_BOXING by correctly telling GC which mrb_value types are immediate. 2014-07-01 15:23:23 -07:00
dreamedge f3c71cf5da Add TCP_* constants included in "netinet/tcp.h".
ex: TCP_NODELAY, TCP_CORK, ...
2014-07-02 00:30:10 +09:00
Yukihiro "Matz" Matsumoto aa441c2a34 Merge pull request #2433 from take-cheeze/mirb_bool_val
Use `TRUE` instead of `1` in mirb code.
2014-07-02 00:15:09 +09:00
take_cheeze a656daf4c5 Use TRUE instead of 1 in mirb code. 2014-06-30 23:26:23 +09:00
take_cheeze ef57fd55fb Add method toolchains and primary_toolchain to MRuby::Build.
* To check imported toolchains for setting up toolchain specific things.
* `primary_toolchain` returns the main toolchain name of the build.
2014-06-29 20:32:12 +09:00
Yukihiro "Matz" Matsumoto 618ef17c8c Merge pull request #2431 from ksss/warning-objectspace
Reduce warning for enumeration
2014-06-29 18:40:20 +09:00
ksss bdbc1f003e Reduce warning for enumeration
22 enumeration values not handled in switch: 'MRB_TT_FALSE',
'MRB_TT_FREE', 'MRB_TT_TRUE'... [-Wswitch]
2014-06-29 09:52:18 +09:00
Yukihiro "Matz" Matsumoto 684f8ec575 Merge pull request #2430 from SHyx0rmZ/remove-duplicate
Sacrifice some micro-optimization to remove duplicate code
2014-06-28 17:15:30 +09:00
Yukihiro "Matz" Matsumoto 344b7d819f git push origin masterMerge branch 'take-cheeze-fix_each_obj_crash' 2014-06-28 01:09:36 +09:00
Yukihiro "Matz" Matsumoto 9726dbefb4 remove String class initialization in error.c; ref #2429 2014-06-28 01:09:09 +09:00
Yukihiro "Matz" Matsumoto 9a28ae921b ObjectSpace.each_object should filter out internal (i.e. obj->c == NULL) objects; ref #2429 2014-06-28 01:08:23 +09:00
take_cheeze f9076230f2 Fix crash in method call in ObjectSpace.each_object block.
* Filter `MRB_TT_ENV` and `MRB_TT_ICLASS`.
* Set `mrb->string_class` in `mrb_init_exception` instead.
2014-06-28 00:45:47 +09:00
Yukihiro "Matz" Matsumoto 919af61766 initialize nomem_err->mesg->c before exposing to Ruby world; close #2428 2014-06-27 22:39:39 +09:00
Yukihiro "Matz" Matsumoto 4ce0a7653b reduce mrb_funcall in exception allocation 2014-06-27 22:10:21 +09:00
Yukihiro "Matz" Matsumoto 79787df046 Merge branch 'master' of github.com:mruby/mruby 2014-06-27 07:50:59 +09:00
Yukihiro "Matz" Matsumoto 9f8fe6f33d Merge pull request #2427 from suzukaze/fix-typo
Fix typo in doc/api/mruby.h.md
2014-06-27 07:22:54 +09:00
Yukihiro "Matz" Matsumoto 719c9abb61 Merge pull request #2426 from take-cheeze/mrbconf
Document rest mrbconfs.
2014-06-27 07:17:22 +09:00
Patrick Pokatilo 73c086b4c7 Sacrifice some micro-optimization to remove duplicate code 2014-06-26 22:22:21 +02:00
Jun Hiroe 09d8cd69e9 Fix typo in doc/api/mruby.h.md 2014-06-26 21:47:04 +09:00
take_cheeze d7d0c31ade Quote default value. 2014-06-26 21:09:44 +09:00
take_cheeze 2adb4118aa Document left mrbconfs. 2014-06-26 21:08:56 +09:00
Yukihiro "Matz" Matsumoto 729a760f91 Merge branch 'master' of github.com:mruby/mruby 2014-06-25 23:36:04 +09:00
Yukihiro "Matz" Matsumoto c19f5efaaf Merge pull request #2423 from ksss/proc-parameters
Implement Proc#parameters
2014-06-25 23:33:56 +09:00
Yukihiro "Matz" Matsumoto 3f13196cbb Merge pull request #2425 from take-cheeze/mrbconf
Update mrbconf.
2014-06-25 23:32:33 +09:00
take_cheeze 340279885e Add notes about restriction of DISABLE_STDIO. 2014-06-25 21:41:54 +09:00
take_cheeze 090a8889f7 Add documentation of mrb_value config. 2014-06-25 21:34:52 +09:00
ksss 9cafc5e105 Implement Proc#parameters 2014-06-25 16:05:33 +09:00
Yukihiro "Matz" Matsumoto d4e49c9f8f Merge pull request #2422 from ksss/aspec-macro
OP_ENTER use MBR_ASPEC_* macros
2014-06-25 15:05:37 +09:00
ksss f092ef6b14 OP_ENTER: Rewrite split aspec use macros 2014-06-25 13:54:11 +09:00
ksss b0edba434c proc.h: MRB_ASPEC_REST() macro return 1 or 0
MRB_ASPEC_REST() is macro just only checks whether truthy or falsy.
And truthy means exist 1 rest argument in current proc.
2014-06-25 13:54:11 +09:00
Yukihiro "Matz" Matsumoto 9dab02224d Merge branch 'master' of github.com:mruby/mruby 2014-06-25 13:43:13 +09:00
Yukihiro "Matz" Matsumoto 8548aebcfa Merge pull request #2421 from ksss/safe-arity
Proc#arity return 0 when opcode was not OP_ENTER
2014-06-25 13:42:59 +09:00
ksss 19b82944f8 Proc#arity return 0 when opcode was not OP_ENTER 2014-06-25 08:48:08 +09:00
Yukihiro "Matz" Matsumoto 000fae415b Merge branch 'master' of github.com:mruby/mruby 2014-06-25 07:54:00 +09:00
Yukihiro "Matz" Matsumoto dfeadf19da Merge pull request #2420 from ksss/reduce-lv
Not create local variables in scope_new
2014-06-25 07:53:51 +09:00
Yukihiro "Matz" Matsumoto 7a0fbf3a25 Merge branch 'master' of github.com:mruby/mruby 2014-06-25 07:53:39 +09:00
Santa Zhang 17ecbaa23d add a few const qualifier 2014-06-25 07:53:23 +09:00
yui-knk b443bd081a Fix to not print unnecessary comma.
When `n2->car` is 0 and `n2->cdd` is not 0,
unnecessary comma was printed before first local variables.
2014-06-25 07:53:23 +09:00
Yukihiro "Matz" Matsumoto 8e6fc29aac Merge pull request #2419 from santazhang/use-const
add a few const qualifier
2014-06-25 07:41:27 +09:00
ksss 14767a5597 Not create local variables in scope_new 2014-06-25 05:52:07 +09:00
Santa Zhang 8d5f67e6f3 add a few const qualifier 2014-06-24 15:16:13 -04:00
Yukihiro "Matz" Matsumoto faa3c52a8d Merge branch 'master' of github.com:mruby/mruby 2014-06-25 02:37:51 +09:00
Yukihiro "Matz" Matsumoto 9874aafbf0 Merge pull request #2333 from yui-knk/fix/dump
Fix to not print unnecessary comma.
2014-06-25 02:37:39 +09:00
Yukihiro "Matz" Matsumoto 5b590d977f revert #2344 because of #2395 2014-06-25 02:36:02 +09:00
Yukihiro "Matz" Matsumoto 46da47fc5e Merge pull request #2418 from take-cheeze/sym_intern
Add `Symbol#intern`.
2014-06-24 22:41:00 +09:00
take_cheeze 257725cecb Add Symbol#intern. 2014-06-24 21:44:22 +09:00
Yukihiro "Matz" Matsumoto 5561be961e Merge pull request #2416 from take-cheeze/c_api_ref
Start documenting C APIs.
2014-06-24 06:00:48 +09:00
Yukihiro "Matz" Matsumoto 7366615b78 Merge branch 'master' of github.com:mruby/mruby 2014-06-24 05:46:51 +09:00
Yukihiro "Matz" Matsumoto 08cfd9e637 Merge pull request #2415 from take-cheeze/mrbconf_doc
Add mrbconf document.
2014-06-24 04:50:27 +09:00
take_cheeze 2ec79c6e91 Add documentation of state atexit configuration. 2014-06-23 22:19:28 +09:00
take_cheeze 6336dbb653 Add documentation of memory pool configurations. 2014-06-23 22:12:58 +09:00
take_cheeze ae15f264bd Start documenting C APIs. 2014-06-23 21:55:54 +09:00
Yukihiro "Matz" Matsumoto 90ddc2810a Merge branch 'take-cheeze-mrb_open_without_mrbgems' 2014-06-23 20:25:34 +09:00
Yukihiro "Matz" Matsumoto ac0addd98f refacor mrb_open_core() to reduce a local variable 2014-06-23 20:06:17 +09:00
take_cheeze baca365caa rename mrb_open_without_mrbgems to mrb_open_core 2014-06-23 20:06:17 +09:00
take_cheeze 36813c87f6 make default allocf public to use it with mrb_open_without_mrbgems 2014-06-23 20:06:17 +09:00
take_cheeze 6bb56ed920 add mrb_open_without_mrbgems API 2014-06-23 20:06:17 +09:00
Yukihiro "Matz" Matsumoto ad23483f32 Merge branch 'take-cheeze-reduce_new_obj' 2014-06-23 19:51:52 +09:00
take_cheeze 1633469e9c Reduce string creation in Symbol#casecmp by using case!. 2014-06-23 19:51:27 +09:00
take_cheeze 7015493efb Reduce string creation of length, size, empty? method of Symbol extension. 2014-06-23 19:51:27 +09:00
take_cheeze 0a6b54acd6 Reduce new string creation in capitalize, downcase, upcase method of Symbol class extension.
Add test to check unmodified result is working.
2014-06-23 19:51:27 +09:00
Yukihiro "Matz" Matsumoto c938b2f656 Merge pull request #2399 from ksss/cfunc-proc
Proc class should be defined before a first method definition
2014-06-23 09:02:53 +09:00
Yukihiro "Matz" Matsumoto a26599b5c6 Merge pull request #2413 from take-cheeze/summary_doc
Update documentation of `summary` property of mrbgem spec.
2014-06-22 22:23:20 +09:00
take_cheeze ad74bf6d0b Quote required mrbgem spec property. 2014-06-22 22:15:40 +09:00
take_cheeze c9df4ccf07 Update documentation of summary property of mrbgem spec. 2014-06-22 22:15:17 +09:00
Yukihiro "Matz" Matsumoto c43afd68cd Merge pull request #2412 from suzukaze/Fix-doc3
Fix document of  doc/compile/README.md
2014-06-22 17:05:29 +09:00
Yukihiro "Matz" Matsumoto a5f74380b3 Merge pull request #2411 from suzukaze/Fix-docs2
Fix document in doc/mrbgems/README.md
2014-06-22 17:04:37 +09:00
Yukihiro "Matz" Matsumoto f85cf98101 Merge pull request #2410 from suzukaze/Fix-docs
Fix document of doc/mrbconf/README.md
2014-06-22 17:04:08 +09:00
Jun Hiroe e43341b460 Fix document of doc/compile/README.md 2014-06-22 13:11:43 +09:00
Jun Hiroe d1d8bcba5d Fix a document in doc/mrbgems/README.md 2014-06-22 12:52:20 +09:00
Jun Hiroe 5355a4a18b Fix document of doc/mrbconf/README.md 2014-06-22 04:05:36 +09:00
Yukihiro "Matz" Matsumoto 1967afc2c8 Merge pull request #2409 from take-cheeze/syntax_highlight
Syntax highlight code blocks with github flavored markdown.
2014-06-21 23:04:07 +09:00
take_cheeze 18c6950809 Syntax highlight code blocks with github flavored markdown. 2014-06-21 22:04:00 +09:00
Yukihiro "Matz" Matsumoto 45e04c996e clear local variables for the first execution of mrb_context_run(); close #2405 2014-06-21 18:24:26 +09:00
Yukihiro "Matz" Matsumoto 9f25e3f3be Merge pull request #2407 from take-cheeze/mrbconf_update
Update mrbconf document.
2014-06-20 09:03:56 +09:00
take_cheeze e6a263a162 Raise NameError as defined in specification when Struct member isn't found. 2014-06-19 22:06:07 +09:00
take_cheeze a2f5840b60 Add tests to Struct#[] and Struct#[]=. 2014-06-19 22:06:07 +09:00
take_cheeze 3d94022b54 Replace return value result passing with assert_* in Struct test. 2014-06-19 22:06:07 +09:00
take_cheeze dd37c52068 Document GC mrbconfs. 2014-06-19 22:02:19 +09:00
take_cheeze 412c86bb58 Add primitive type configuration document. 2014-06-19 21:39:01 +09:00
take_cheeze 94ae70e8ee Add notes about how to use mrbconf. 2014-06-19 21:28:18 +09:00
Yukihiro "Matz" Matsumoto 49ecd44c7b Merge pull request #2406 from iij/pr_string_slice_bang
Adapt a behavior of String#slice! to other Ruby implementations
2014-06-19 19:17:24 +09:00
Akito Mochizuki ec04fa7e8d Modify return value of String#slice! if idx == self.size 2014-06-19 17:34:17 +09:00
Tomoyuki Sahara ddfc4eb5ef IO#read(0) should return "" immediately. fixes iij/mruby-socket#13. 2014-06-19 09:57:08 +09:00
Yukihiro "Matz" Matsumoto ba0ddb7819 fix conflict resolution mistake 2014-06-19 01:55:39 +09:00
Yukihiro "Matz" Matsumoto af92eb9de6 git push origin masterMerge branch 'yui-knk-replace-assert' 2014-06-18 23:44:31 +09:00
Yukihiro "Matz" Matsumoto a47cc0c211 resolve conflict 2014-06-18 23:44:24 +09:00
Yukihiro "Matz" Matsumoto 61b495c159 Merge branch 'master' of github.com:mruby/mruby 2014-06-18 23:10:20 +09:00
Yukihiro "Matz" Matsumoto b25fd05ee5 Merge branch 'suzukaze-delete-string.slice_comment' 2014-06-18 15:56:54 +09:00
Yukihiro "Matz" Matsumoto 8459b39886 update String#slice doc 2014-06-18 15:56:34 +09:00
Yukihiro "Matz" Matsumoto 42f5b741ea remove superclass test for classes that do not exist in mruby (core) 2014-06-18 15:54:43 +09:00
Yukihiro "Matz" Matsumoto b6982c1927 Merge pull request #2403 from take-cheeze/mrbconf_doc
Start `mrbconf` documentation.
2014-06-18 11:46:27 +09:00
take_cheeze 0ae199ca50 Add mrbconf documentation. 2014-06-17 22:46:52 +09:00
Tomoyuki Sahara 376af5bac3 re-implement TCPServer.accept. fixes #12. 2014-06-17 15:41:42 +09:00
Yukihiro "Matz" Matsumoto abb682eaf1 Merge pull request #2401 from take-cheeze/fixed_state_atexit_stack
Add fixed state atexit stack feature.
2014-06-17 11:54:50 +09:00
Yukihiro "Matz" Matsumoto d9985631e7 Merge pull request #2396 from take-cheeze/superclass_check
Move direct superclass checking to `test/t/superclass.rb`.
2014-06-17 11:51:04 +09:00
Yukihiro "Matz" Matsumoto 44a834f30b Merge pull request #2402 from katmutua/master
[minor-fix]Update value pointer comments
2014-06-17 11:28:14 +09:00
katmutua 17e3203cfc [minor-fix]Minor cleanups on variable.c comments 2014-06-16 14:13:24 -03:00
Yukihiro "Matz" Matsumoto 3dce1fb3ca Merge pull request #2397 from suzukaze/add-string-slice_bang
Implement String#slice!
2014-06-16 19:57:07 +09:00
take_cheeze 62f41ddd3b Add fixed state atexit stack feature.
Adds following macros:
* MRB_FIXED_STATE_ATEXIT_STACK (not defined by default)
  * When defined enables fixed state atexit stack.
* MRB_FIXED_STATE_ATEXIT_STACK_SIZE (default value: 5)
  * This macro will be ignored when `MRB_FIXED_STATE_ATEXIT_STACK` isn't defined.
  * When `mrb_state_atexit` is called more than this value it will raise runtime error.
2014-06-16 16:03:35 +09:00
ksss 907a299790 arity for cfunc is not implemented yet 2014-06-15 22:38:22 +09:00
ksss 1cced27a79 Proc class define before a first method
mrb_define_method setting mrb->proc_class for method proc
2014-06-15 22:34:46 +09:00
Jun Hiroe eab4a7492f Unsupported Regex in mrb_str_aref_m() 2014-06-15 21:21:20 +09:00
Jun Hiroe 00fa8097f9 Implement String#slice_bang 2014-06-15 21:11:54 +09:00
Tomoyuki Sahara 5b65ca3ebb Merge pull request #5 from take-cheeze/float
Add full support of float templates.
2014-06-15 19:54:08 +09:00
take_cheeze 77047b5ed4 Test all ISO defined classes direct superclass except Object class.
Move mrbgems ISO direct superclass test to `superclass.rb`.
Skips test if class isn't defined.
Close #2332.
2014-06-15 17:07:01 +09:00
take_cheeze ec5b055694 Move direct superclass checking to test/t/superclass.rb. 2014-06-15 15:02:21 +09:00
take_cheeze 7b2611ea28 Update supported template list. 2014-06-14 13:25:00 +09:00
take_cheeze 8f4b7ac15c Support float/double unpacking. 2014-06-14 13:25:00 +09:00
take_cheeze 514450e891 Use PACK_FLAG_LITTLEENDIAN. 2014-06-14 13:25:00 +09:00
take_cheeze 7dc2b4f59f Implement g/f/F/G/d/D packing. 2014-06-14 13:24:59 +09:00
take_cheeze f4f968241b Add support of little endian float. 2014-06-14 13:24:49 +09:00
Tomoyuki Sahara a0c4ca2406 Merge pull request #4 from take-cheeze/raise_fix
Fix invalid raise format found with mruby-clang-plugin.
2014-06-14 07:51:42 +09:00
Yukihiro "Matz" Matsumoto 0042e586db Merge pull request #2344 from yui-knk/fix-locals
Change to always use locals->car->car.
2014-06-14 01:03:39 +09:00
Yukihiro "Matz" Matsumoto e4b01da97e Merge pull request #2393 from goyox86/fix-clang-analizer-warnings
Fix clang analizer warnings
2014-06-14 01:01:25 +09:00
Jose Narvaez 61032c5ab0 Rolling back change induced because of 'clang-analizer' report. 2014-06-13 16:50:02 +01:00
Jose Narvaez 45b8562d8d Using 'mrb_assert' instead of an returning 0 while checking s->irep in codegen.c. 2014-06-13 16:44:22 +01:00
Yukihiro "Matz" Matsumoto 774703c5d7 Merge pull request #2394 from take-cheeze/fix_conflict_doc
Fix conflict doc since there is only `add_conflict` method.
2014-06-14 00:14:33 +09:00
take_cheeze d10cda1ac1 Fix conflict doc since there is only add_conflict method. 2014-06-13 22:19:39 +09:00
Jose Narvaez e457b4d686 Merge branch 'master' into fix-clang-analizer-warnings
* master:
  update add_confict document; ref #2391
  Update document by regenerating it.
  Add :doc task to run document generator.
  Add document for `add_conflict` and `add_conflicts`.
2014-06-13 12:37:18 +01:00
Yukihiro "Matz" Matsumoto 40b92e3529 Merge pull request #2392 from take-cheeze/doc_update
Update document and add :doc task.
2014-06-13 20:36:10 +09:00
Yukihiro "Matz" Matsumoto 17da8f3c99 git push origin masterMerge branch 'take-cheeze-conflict_doc' 2014-06-13 20:35:00 +09:00
Yukihiro "Matz" Matsumoto 8c283e15e4 update add_confict document; ref #2391 2014-06-13 20:34:51 +09:00
Jose Narvaez 6b642637b3 Fixed dead assignment in 'parser.y' reported by 'clang-analyzer' 2014-06-13 12:11:28 +01:00
Jose Narvaez 1a8e0ba4e8 Fixed dead assignment in 'parser.y' reported by 'clang-analyzer' 2014-06-13 12:11:23 +01:00
Jose Narvaez a250050077 Fixed dead assignment in 'parser.y' reported by 'clang-analyzer' 2014-06-13 12:06:56 +01:00
Jose Narvaez 13abc9c4a1 Revert "Fixed dereference to null pointer in 'codegen.c' reported by 'clang-analyzer'"
This reverts commit 29f14e728d.
2014-06-13 10:54:18 +01:00
Jose Narvaez e344d662f1 Fixed dereference to null pointer in 'codegen.c' reported by 'clang-analyzer' 2014-06-13 10:50:26 +01:00
Jose Narvaez 29f14e728d Fixed dereference to null pointer in 'codegen.c' reported by 'clang-analyzer' 2014-06-13 10:50:15 +01:00
Jose Narvaez a5cadf4bec Fixed dead increment in 'dump.c' reported by 'clang-analyzer' 2014-06-13 10:13:18 +01:00
Jose Narvaez 44a5809224 Fixed possible division by zero in 'codegen.c' reported by 'clang-analyzer' 2014-06-13 10:09:28 +01:00
Jose Narvaez da55b50409 Fixed dead assignment in 'vm.c' reported by 'clang-analyzer' 2014-06-13 09:44:41 +01:00
take_cheeze 1997420a7f Fix raise format found with mruby-clang-plugin. 2014-06-13 17:42:43 +09:00
Jose Narvaez 4027035cf4 Fixed dead assignment in 'parse.y' reported by 'clang-analyzer' 2014-06-13 09:37:07 +01:00
Jose Narvaez 24c105a251 Fixed dead assignment in 'backtrace.c' reported by 'clang-analyzer' 2014-06-13 09:36:44 +01:00
take_cheeze 502baaba39 Update document by regenerating it. 2014-06-13 17:28:45 +09:00
take_cheeze c07feca570 Add :doc task to run document generator. 2014-06-13 17:28:40 +09:00
take_cheeze 66802d9219 Add document for add_conflict and add_conflicts. 2014-06-13 17:16:32 +09:00
Yukihiro "Matz" Matsumoto 7275096f56 git push origin masterMerge branch 'take-cheeze-add_conflicts' 2014-06-13 12:50:11 +09:00
Yukihiro "Matz" Matsumoto 8ef971a373 remove add_conflicts now; use add_conflict; ref #2390 2014-06-13 12:50:00 +09:00
Yukihiro "Matz" Matsumoto 81db9b7090 Merge branch 'add_conflicts' of https://github.com/take-cheeze/mruby into take-cheeze-add_conflicts 2014-06-13 12:39:55 +09:00
take_cheeze eebb94410f Implement add_conflict. Usage is similar to add_dependency. 2014-06-13 01:07:53 +09:00
Yukihiro "Matz" Matsumoto 2067f1f9ff Merge branch 'master' of github.com:mruby/mruby 2014-06-13 00:42:03 +09:00
Yukihiro "Matz" Matsumoto 2ed7089546 need to call write barrier on hash keys; ref #2375 2014-06-13 00:41:49 +09:00
take_cheeze 6157e50843 Implement add_conflicts. Solve #2383. 2014-06-12 13:57:58 +09:00
Yukihiro "Matz" Matsumoto be3e36cb05 Merge pull request #2389 from ksss/str-mem-leaks
Fix memory leaks in String
2014-06-12 07:36:36 +09:00
Yukihiro "Matz" Matsumoto d0401dccc4 Merge pull request #2387 from suzukaze/refactor-nofree-p
Refactor how to use RSTR_NOFREE_P macro
2014-06-12 07:31:09 +09:00
ksss f1e15b0236 String#clear: use String#replace to simple 2014-06-11 14:46:52 +00:00
ksss bd53818999 str_replace: self should not be shared and nofree 2014-06-11 14:42:18 +00:00
Jun Hiroe 75d1412410 Refactor how to use RSTR_NOFREE_P macro 2014-06-11 23:10:41 +09:00
Yukihiro "Matz" Matsumoto 63be55c77c Merge pull request #2386 from suzukaze/add-nofree-macro
Add NOFREE macros
2014-06-11 12:15:33 +09:00
Jun Hiroe 9c259c501a Add NOFREE macros 2014-06-11 01:00:35 +09:00
Yukihiro "Matz" Matsumoto fe95f44013 rename mrb_atexit to mrb_state_atexit to clarify a func will be called at the end of state, not process; ref #2211 2014-06-10 17:59:56 +09:00
Yukihiro "Matz" Matsumoto 2e7de03fe8 Merge branch 'master' of github.com:mruby/mruby 2014-06-10 13:15:27 +09:00
Yukihiro "Matz" Matsumoto c2f6c33fef reserve a register for a block parameter in a for statement body; ref #2375 2014-06-10 13:15:19 +09:00
Yukihiro "Matz" Matsumoto 87038c2c8d Merge pull request #2381 from monaka/pr-add-include_paths-in-dependency-gems
Append include paths in dependency gems
2014-06-10 11:46:24 +09:00
Masaki Muranaka 4e5315ff41 Add more info about "include_paths and GEM dependency". 2014-06-10 11:02:58 +09:00
Masaki Muranaka 7b6150ab90 Add include_paths in dependency gems. 2014-06-10 10:55:02 +09:00
Tomoyuki Sahara d894de86f4 fd2 is valid if fd2 >= 0. fixes #18. 2014-06-10 10:22:50 +09:00
Tomoyuki Sahara cb84ce30e7 no longer used. 2014-06-10 09:54:23 +09:00
Yukihiro "Matz" Matsumoto 2f8047461f Merge pull request #2377 from monaka/pr-add-dot-s-extension
Add ".s" to source extensions.
2014-06-10 00:38:58 +09:00
Yukihiro "Matz" Matsumoto 74ed32f25c Merge pull request #2378 from monaka/pr-add-tools-dir-to-cxx-files-check-oaths
Find c++ files in tools/.
2014-06-10 00:38:33 +09:00
Yukihiro "Matz" Matsumoto d6882f1b65 Merge pull request #2379 from monaka/pr-do-not-export-include-dir-in-gems-to-core
Do not export include/ dirs in mrbgems to core build.
2014-06-10 00:38:01 +09:00
Yukihiro "Matz" Matsumoto 58e87996b9 should not add extra stack space to callinfo->nregs; maybe related to #2375 2014-06-10 00:32:45 +09:00
Yukihiro "Matz" Matsumoto 6c524af646 NODE_FOR does not introduce new local variables 2014-06-10 00:03:54 +09:00
Yukihiro "Matz" Matsumoto 4c69a9d09e codedump should display proper L(n) for OP_STRING op 2014-06-09 23:37:20 +09:00
Yukihiro "Matz" Matsumoto a036cbea16 Merge pull request #2373 from take-cheeze/static_assert
Add macro `mrb_static_assert`.
2014-06-09 23:27:44 +09:00
Yukihiro "Matz" Matsumoto f1b1a8acd1 Merge pull request #2376 from kou/patch-1
Add a missing space after ","
2014-06-09 23:26:54 +09:00
Yukihiro "Matz" Matsumoto 53c6c77f93 Merge pull request #2374 from take-cheeze/timeat_fix
Fix `Time.at` args spec.
2014-06-09 23:26:01 +09:00
Masaki Muranaka c6d589e049 Do not export include/ dirs in mrbgems to core build.
In the current behavior, include/ dirs in mrbgems are set to
core's compiler.include_paths.
And they are never set to mrbgem's include_paths.
It may cause some dangerous issues because it can change
mruby core's macros by mrbgems.

After this fix, include/ in a gem is used in the gem itself only.
2014-06-09 23:08:13 +09:00
Kouhei Sutou 4f3114dbc9 Add a missing space after "," 2014-06-09 23:00:02 +09:00
Masaki Muranaka 2c144425d9 Find c++ files in tools/.
Some tools may be written in C++.
2014-06-09 22:55:02 +09:00
Masaki Muranaka 9601777893 Add ".s" to source extensions.
It uses ".s" as the source for assembler on some toolchains including GCC.
2014-06-09 22:46:35 +09:00
take_cheeze 4de468e754 Fallback to mrb_assert instead of dirty trick. 2014-06-09 18:47:07 +09:00
take_cheeze d386b35337 Fix Time.at args spec. 2014-06-09 16:34:04 +09:00
take_cheeze 64994a1764 Check RSTRING_EMBED_LEN_MAX with static assert. 2014-06-08 23:16:55 +09:00
take_cheeze 4a27dd0e8a Use _Static_assert when C11 is available and use it in pointer size check. 2014-06-08 23:16:51 +09:00
Yukihiro "Matz" Matsumoto e070fce835 Merge pull request #2372 from monaka/pr-remove-redundant-substitutions
Remove redundant substitutions.
2014-06-08 17:45:37 +09:00
Masaki Muranaka 78176ee7f5 Remove redundant substitutions.
"#{MRUBY_ROOT}/include" is set in Command::Compiler#initialize .
2014-06-08 14:42:21 +09:00
Yukihiro "Matz" Matsumoto 05d4542c10 Merge branch 'master' of github.com:mruby/mruby 2014-06-08 01:42:09 +09:00
take_cheeze aa187956cf Add test for end-of-program marker. 2014-06-08 01:38:44 +09:00
Yukihiro "Matz" Matsumoto d75b84016c do not ignore negative characters (e.g. EOF and partial EOF); fix #2361 fix #2369 2014-06-08 01:38:44 +09:00
Yukihiro "Matz" Matsumoto a13e8f5ee1 revert #2368 due to #2369 2014-06-08 00:48:59 +09:00
Yukihiro "Matz" Matsumoto e7410fd808 Merge pull request #2371 from take-cheeze/end_of_code
Add test for end-of-program marker.
2014-06-07 23:17:42 +09:00
take_cheeze 0fffdd27f2 Add test for end-of-program marker. 2014-06-07 22:41:02 +09:00
Yukihiro "Matz" Matsumoto 6459a98448 move String#clear to mruby-string-ext; ref #2370 2014-06-07 22:28:42 +09:00
Yukihiro "Matz" Matsumoto 76012a885d remove UTF-8 strings from mruby-string-ext test 2014-06-07 22:23:25 +09:00
Yukihiro "Matz" Matsumoto 32e450166f move STR_* macros to mruby/string.h with renaming 2014-06-07 22:16:16 +09:00
Yukihiro "Matz" Matsumoto b0c90141d9 clear shared and nofree flags; ref #2370 2014-06-07 17:24:18 +09:00
Yukihiro "Matz" Matsumoto 20dc629b11 inline str_discard(); ref #2370 2014-06-07 16:51:40 +09:00
Yukihiro "Matz" Matsumoto 24b02955d3 git push origin masterMerge branch 'suzukaze-add-string.clear2' 2014-06-07 16:47:03 +09:00
Jun Hiroe 9709fe79a3 Implement String#clear 2014-06-07 16:15:32 +09:00
Yukihiro "Matz" Matsumoto 04edab4c21 Merge pull request #2368 from take-cheeze/partial_hook_fix
Treat partial hook success '\n' to fix #2361 .
2014-06-06 22:03:02 +09:00
take_cheeze 39bbdd5f2f Add bintest for mrbc. 2014-06-06 21:46:58 +09:00
Yukihiro "Matz" Matsumoto ff4ca4c195 Merge pull request #2367 from take-cheeze/ignore_outfile
Ignore outfile check when `-c`(check syntax only) flag is enabled.
2014-06-06 21:32:35 +09:00
take_cheeze 7f870f601f Treat partial hook success '\n' to fix #2361 .
Now it will parse the #2361 code as:
```
module A
end
module B
end
```
instead of
```
module A
end module B
end
```
2014-06-06 21:29:42 +09:00
take_cheeze 2f614b1a5c Ignore outfile check when -c(check syntax only) flag is enabled. 2014-06-06 19:55:04 +09:00
Yukihiro "Matz" Matsumoto d3fda42eb6 Merge pull request #2359 from take-cheeze/src_gen_dep
Add generator script to dependency so that it will regenerate C codes when it's modified.
2014-06-06 16:38:11 +09:00
Yukihiro "Matz" Matsumoto a8636103a2 git push origin masterMerge branch 'cremno-ascii' 2014-06-06 12:49:55 +09:00
Yukihiro "Matz" Matsumoto 232b8b07e4 Merge branch 'ascii' of https://github.com/cremno/mruby into cremno-ascii 2014-06-06 12:48:48 +09:00
Yukihiro "Matz" Matsumoto ccd871bcca reduce calling mrb_sym2name_len() from struct.c; ref #2365 2014-06-06 09:25:29 +09:00
Yukihiro "Matz" Matsumoto b533917aa6 Merge pull request #2365 from cremno/mruby-struct-function-changes
various mruby-struct function changes
2014-06-06 09:17:37 +09:00
Yukihiro "Matz" Matsumoto 3501524ef8 Merge pull request #2364 from take-cheeze/free_atexit_stack
Release `mrb->atexit_stack` on `mrb_close`.
2014-06-06 09:13:53 +09:00
cremno 71c7d58736 partially revert 1a5841b for mirb
Fix compilation fail caused by GNU Readline and `ISPRINT`.
Also add missing `unsigned char` cast.
2014-06-06 00:13:24 +02:00
cremno 1a5841b4b1 use uppercase US-ASCII ctype macros 2014-06-05 21:00:47 +02:00
cremno f9f864d4dd don't (re-)define ascii_isspace and isascii
`ISSPACE` and `ISASCII` can be used instead.
2014-06-05 20:27:17 +02:00
cremno 69da21bcb4 ISSPACE evaluates its argument multiple times 2014-06-05 20:22:20 +02:00
cremno c4c470696b implement ISASCII correctly 2014-06-05 20:18:23 +02:00
cremno 025b8f7644 mruby-struct: implement mrb_is_(local|const)_id 2014-06-05 18:48:17 +02:00
take_cheeze 4c1fb65d85 Release mrb->atexit_stack on mrb_close. 2014-06-06 01:04:12 +09:00
Yukihiro "Matz" Matsumoto b1dd57efa1 move IS_EVSTR macro that should be private to src/string.c 2014-06-06 00:19:46 +09:00
Yukihiro "Matz" Matsumoto cc28f868f1 remove mrblib/print.rb that only raise NotImplementedError; ref #2354 2014-06-05 22:47:40 +09:00
Yukihiro "Matz" Matsumoto 799c9b30f6 remove eval (that only raises NotImplementedError) from the core; ref #2354 2014-06-05 21:41:28 +09:00
Yukihiro "Matz" Matsumoto 6a96bc46d1 git push origin masterMerge branch 'take-cheeze-atexit' 2014-06-05 14:28:18 +09:00
Yukihiro "Matz" Matsumoto a763d11490 Merge branch 'atexit' of https://github.com/take-cheeze/mruby into take-cheeze-atexit 2014-06-05 13:22:28 +09:00
Yukihiro "Matz" Matsumoto cbbed40295 add nil#to_h; ref #2348 2014-06-05 13:20:17 +09:00
Yukihiro "Matz" Matsumoto e52533a703 update Kernel#raise/fail argument description 2014-06-05 13:17:29 +09:00
cremno 65a7eac1a9 mruby-struct: remove unused functions 2014-06-05 01:31:15 +02:00
cremno 64b0e48dcb mruby-struct: use correct data types 2014-06-05 01:27:39 +02:00
cremno 0249e7dd7f mruby-struct: internal linkage for all functions 2014-06-05 01:16:23 +02:00
Yukihiro "Matz" Matsumoto 9763726e68 Merge branch 'master' of github.com:mruby/mruby 2014-06-04 23:37:22 +09:00
Yukihiro "Matz" Matsumoto 13728e203e add Enumerable#to_h; ref #2348 2014-06-04 23:37:13 +09:00
take_cheeze fb3c2f6b08 Add generator script to dependency so that it will regenerate C codes when it's modified. 2014-06-04 22:53:36 +09:00
Yukihiro "Matz" Matsumoto 172060877a add Hash#to_h; ref #2348 2014-06-04 18:57:31 +09:00
Yukihiro "Matz" Matsumoto bd0e9db1f1 Merge pull request #2358 from cremno/visual-studio-14-ctp-support
upcoming Visual Studio versions provide `snprintf`
2014-06-04 13:48:53 +09:00
cremno 84e1b0a9d0 upcoming Visual Studio versions provide snprintf 2014-06-04 06:04:06 +02:00
Yukihiro "Matz" Matsumoto 8a9e2066c3 mark pre-allocated exception 2014-06-04 11:36:19 +09:00
Yukihiro "Matz" Matsumoto bccd43da71 indent ISO section comments 2014-06-04 11:33:56 +09:00
Yukihiro "Matz" Matsumoto d62ce565c6 use pre-allocated RuntimeError for out-of-memory 2014-06-04 11:33:15 +09:00
Yukihiro "Matz" Matsumoto b01bb33b75 fix String#lines comment; ref mattn@2e1855a 2014-06-04 10:51:09 +09:00
Yukihiro "Matz" Matsumoto 04962ca075 Merge pull request #2357 from mattn/string-lines
Add String#lines
2014-06-04 10:45:11 +09:00
Yukihiro "Matz" Matsumoto e3074eff6f Merge pull request #2356 from mattn/string-codepoints
Add String#chars, String#each_char, String#codepoints, String#each_codepoint
2014-06-04 10:41:24 +09:00
mattn c927277486 Add String#lines 2014-06-04 10:41:07 +09:00
mattn 6d0388c68e Refactor variable definitions 2014-06-04 10:28:34 +09:00
mattn 5410b9c46c arena save/restore 2014-06-04 10:20:51 +09:00
mattn f18771eb42 Add String#chars, String#each_char, String#codepoints, String#each_codepoint 2014-06-04 10:10:58 +09:00
Yukihiro "Matz" Matsumoto 9763eee616 add dependency from mruby-string-utf8 to mruby-string-ext to ensure loading order 2014-06-04 09:47:01 +09:00
Yukihiro "Matz" Matsumoto c31c6c0833 Merge pull request #2352 from suzukaze/fix-indent
Fix indents in mruby-string-utf8
2014-06-04 09:12:46 +09:00
Yukihiro "Matz" Matsumoto 82515722ff Merge pull request #2353 from suzukaze/refactor-string-utf8
Refactor mrb_utf8_strlen() in mruby-string-utf8
2014-06-04 09:12:25 +09:00
Yukihiro "Matz" Matsumoto a789f776c7 Merge pull request #2351 from mattn/add-string-utf8.chr
Add string String#chr for utf8
2014-06-04 09:11:50 +09:00
Yukihiro "Matz" Matsumoto 863abfc298 Merge pull request #2350 from suzukaze/add-string.chr
Implement String#chr
2014-06-04 09:11:23 +09:00
Yukihiro "Matz" Matsumoto c3ed6e3d25 use is_a? Array for String#% argument check as the original PR did in #2349 2014-06-04 09:08:22 +09:00
Jun Hiroe ce45304ec4 Refactor mrb_utf8_strlen() in mruby-string-utf8 2014-06-03 20:56:17 +09:00
Jun Hiroe 73874f4008 Fix indents in mruby-string-utf8 2014-06-03 20:53:51 +09:00
mattn 1fab96668c Add test 2014-06-03 20:33:02 +09:00
mattn ab0b1c4783 Implement String#chr for utf-8 2014-06-03 20:20:30 +09:00
Jun Hiroe e67817fcec Implement String#chr 2014-06-03 19:49:38 +09:00
Yukihiro "Matz" Matsumoto 9fe8653e86 Merge branch 'iij-pr-string-percent' 2014-06-03 16:34:45 +09:00
Yukihiro "Matz" Matsumoto 427ea605e7 Merge branch 'master' of github.com:mruby/mruby 2014-06-03 16:34:21 +09:00
Yukihiro "Matz" Matsumoto 4380f86150 Special treatment for Hashes, not Arrays; ref #2349 2014-06-03 16:33:30 +09:00
Tomoyuki Sahara fe9f3fdd20 add 'String#%'. 2014-06-03 16:31:20 +09:00
Jun Hiroe b81f0d0ffb Add comments in String#lstrip, rstrip, strip, lstring_bang, rstrip_bang and strip_bang 2014-06-03 16:29:42 +09:00
Carson McDonald fe09686c2f Fix mgem test args passing 2014-06-03 16:29:42 +09:00
yui-knk 72305efe61 Remove space. 2014-06-03 16:29:42 +09:00
yui-knk b56a47cc38 Fix indent. 2014-06-03 16:29:42 +09:00
katmutua 4039355fd8 Fix typos in gc 2014-06-03 16:29:42 +09:00
yui-knk 490d946bca Remove space. 2014-06-03 16:29:42 +09:00
Yukihiro "Matz" Matsumoto 037a1d7088 Merge pull request #2348 from takkanm/add_array_to_h
Add Array#to_h
2014-06-03 15:50:52 +09:00
Yukihiro "Matz" Matsumoto b83ff9ff30 Merge pull request #2347 from take-cheeze/nomethod_args
Implement `NoMethodError#args`.
2014-06-03 15:46:16 +09:00
Yukihiro "Matz" Matsumoto 896c131231 Merge pull request #2346 from suzukaze/add-string-comment2
Fix indent in String#casecmp comments
2014-06-03 15:44:13 +09:00
Yukihiro "Matz" Matsumoto 6e94f9bb30 Merge pull request #2345 from suzukaze/add-string-comment
Add comments in String#lstrip, rstrip, strip, lstring_bang, rstrip_bang ...
2014-06-03 14:34:38 +09:00
Mitsutaka Mimura a0b12bf6b4 Add Array#to_h 2014-06-02 23:06:02 +09:00
take_cheeze acec9d1ff1 Implement NoMethodError#args. 2014-06-02 22:38:02 +09:00
Jun Hiroe 85ed19ca4d Fix indent in String#casecmp comments 2014-06-02 22:03:29 +09:00
Jun Hiroe cbe73e93f7 Add comments in String#lstrip, rstrip, strip, lstring_bang, rstrip_bang and strip_bang 2014-06-02 22:00:05 +09:00
Yukihiro "Matz" Matsumoto f370a0f0fd Merge pull request #2343 from carsonmcdonald/fixmgemargspassing
Fix mgem test args passing
2014-06-02 09:39:22 +09:00
yui-knk b5ef16ba03 Change to always use locals->car->car.
When p->locals->car is not NULL and p->locals->car->car is NULL,
local_add_f dose not append sym to p->locals->car->car.
This commit change to append sym to p->locals->car->car.
This will close #2333.
2014-06-02 09:38:24 +09:00
Carson McDonald de8916b1f2 Fix mgem test args passing 2014-06-01 09:51:21 -04:00
Yukihiro "Matz" Matsumoto 991b19b195 Merge pull request #2341 from yui-knk/remove-space
Remove space.
2014-06-01 22:18:04 +09:00
Yukihiro "Matz" Matsumoto cfb288e23d Merge pull request #2342 from yui-knk/fix-indent
Fix indent.
2014-06-01 22:17:42 +09:00
yui-knk 15ab1b7ab0 Fix indent. 2014-06-01 22:07:28 +09:00
yui-knk e413294488 Remove space. 2014-06-01 22:04:51 +09:00
Yukihiro "Matz" Matsumoto a22495df00 Merge branch 'master' of github.com:mruby/mruby 2014-06-01 02:51:24 +09:00
Yukihiro "Matz" Matsumoto 35d4137da1 remove part of 9cd71916 test for same reason as 5306e47 2014-06-01 02:51:04 +09:00
Yukihiro "Matz" Matsumoto c86d7fe834 Merge pull request #2336 from katmutua/master
Fix typos in gc
2014-05-31 23:35:17 +09:00
katmutua 36ab17d8ce Fix typos in gc 2014-05-31 10:42:39 -03:00
Yukihiro "Matz" Matsumoto 2ad2cf2fed Merge pull request #2334 from yui-knk/remove-space
Remove space.
2014-05-31 16:06:36 +09:00
yui-knk c131f69d21 Remove space. 2014-05-31 14:10:30 +09:00
yui-knk 536697f41e Fix to not print unnecessary comma.
When `n2->car` is 0 and `n2->cdd` is not 0,
unnecessary comma was printed before first local variables.
2014-05-31 14:00:30 +09:00
Yukihiro "Matz" Matsumoto 6bf1ee78c8 add internal function mrb_toplevel_run_keep() to keep stack contents; close #2326 2014-05-30 15:25:58 +09:00
Yukihiro "Matz" Matsumoto f38e53ecca Merge pull request #2330 from take-cheeze/struct_set_str
Improve `Struct#[]=`.
2014-05-29 11:57:39 +09:00
take_cheeze 32bfa1f15c Add invalid key type check in Struct#[]=. 2014-05-28 23:21:13 +09:00
take_cheeze 7bc4d08f71 Support string key in Struct#[]=. 2014-05-28 23:14:28 +09:00
Yukihiro "Matz" Matsumoto 415b8fc6b0 Merge pull request #2329 from bggd/patch-4
Fix invalid array initialize for VS2012
2014-05-28 13:16:53 +09:00
bggd 69c2b8310f Fix invalid array initialize for VS2012 2014-05-28 11:04:28 +09:00
Yukihiro "Matz" Matsumoto 0f432e9028 Merge pull request #2324 from yui-knk/fix-indent
fix indent.
2014-05-27 15:03:06 +09:00
yui-knk 5fd1eaec58 fix indent. 2014-05-27 08:48:12 +09:00
Yukihiro "Matz" Matsumoto 6cf5618b44 Merge branch 'master' of github.com:mruby/mruby 2014-05-25 23:19:35 +09:00
Yukihiro "Matz" Matsumoto 6d6957078e no one uses Array.try_convert, so removed it that discourages duck typing; close #2317 2014-05-25 23:18:45 +09:00
Yukihiro "Matz" Matsumoto 84116c26c9 Merge pull request #2320 from yui-knk/test-enumerable
Replace assert_true with assert_equal.
2014-05-25 22:38:25 +09:00
Yukihiro "Matz" Matsumoto 77942f70a5 Merge pull request #2316 from ksss/test-exception
Exception#exception fix test
2014-05-25 22:37:10 +09:00
Yukihiro "Matz" Matsumoto 7c30097183 Merge pull request #2315 from suzukaze/fix-test-proc
Fix assert_equal argument order in test/t/proc.rb
2014-05-25 22:36:05 +09:00
Yukihiro "Matz" Matsumoto af38511c1b Merge pull request #2314 from take-cheeze/fiber_test_refactor
Use `assert_*` method instead of using result value in fiber test.
2014-05-25 22:35:34 +09:00
Yukihiro "Matz" Matsumoto 3925ce9f6e Merge pull request #2312 from take-cheeze/kind_of
Use `assert_kind_of` instead in `Proc#inspect` test.
2014-05-25 22:34:40 +09:00
Yukihiro "Matz" Matsumoto 218d188936 Merge pull request #2318 from yui-knk/fix-typo
fix typo.
2014-05-25 22:33:38 +09:00
yui-knk 83986e2636 Replace assert_true with assert_equal. 2014-05-25 20:19:41 +09:00
yui-knk 2f952a8f95 Change to use assert method. 2014-05-25 18:56:33 +09:00
yui-knk 6bdeebe3b0 fix typo. 2014-05-25 18:50:43 +09:00
ksss bc0cf69a83 Exception#exception fix test
Exception.exception is not call Exception#exception.
Test for Exception#exception should call Exception#exception method.
2014-05-25 11:18:39 +09:00
Jun Hiroe 6a2eced74e Fix assert_equal argument order in test/t/proc.rb 2014-05-25 00:34:40 +09:00
take_cheeze 2d25a15b3b Use assert_* method instead of using result value.
Use `do ... end` for test block.
2014-05-24 23:39:53 +09:00
take_cheeze 2c451dd1fc Use assert_kind_of instead. 2014-05-24 23:18:03 +09:00
Yukihiro "Matz" Matsumoto 229e7fe245 Merge pull request #2310 from ksss/class-segv
Should not call inherited method when class nothing
2014-05-24 00:17:19 +09:00
ksss 7fe34d8f49 Should not call inherited method
when class nothing
2014-05-23 23:56:01 +09:00
Yukihiro "Matz" Matsumoto 5900bb376f Merge pull request #2305 from take-cheeze/doc_update
Update C++ extensions in build instruction document.
2014-05-23 07:39:58 +09:00
take_cheeze 8bbde64ead Update C++ extensions in build instruction document. 2014-05-22 22:06:38 +09:00
Yukihiro "Matz" Matsumoto 9be81e7429 call Class#initialize from Class.new; ref ISO 15.2.3.3.1 2014-05-22 14:44:59 +09:00
Yukihiro "Matz" Matsumoto 00f2144692 allocate object after mrb_get_args() 2014-05-22 14:18:03 +09:00
Yukihiro "Matz" Matsumoto fc557085d8 Merge pull request #2304 from ksss/class-new
Class.new do not call `class_eval'
2014-05-22 14:12:03 +09:00
Yukihiro "Matz" Matsumoto ccaf3e35aa Merge pull request #2303 from ksss/module-initialize
Module#initialize set created object for block argument
2014-05-22 14:10:11 +09:00
Yukihiro "Matz" Matsumoto 267eb74abc Merge branch 'master' of github.com:mruby/mruby 2014-05-22 08:22:18 +09:00
Yukihiro "Matz" Matsumoto f25897cd05 Merge pull request #2282 from yui-knk/check-before-malloc
Change range_check before mrb_obj_alloc.
2014-05-22 08:22:05 +09:00
Yukihiro "Matz" Matsumoto 69a094dc24 git push origin masterMerge branch 'take-cheeze-refactor_dump' 2014-05-22 08:21:10 +09:00
Yukihiro "Matz" Matsumoto 79a6574ac8 remove unnecessary assignment; ref #2301 2014-05-22 08:20:54 +09:00
Yukihiro "Matz" Matsumoto c52838cadb Merge pull request #2286 from suzukaze/refactor-kernel
Use boolean macro in kernel.c
2014-05-22 01:01:16 +09:00
ksss 1f3d7e939f Class.new add test case 2014-05-22 00:11:40 +09:00
ksss c28b46bcf6 Class.new do not call `class_eval'
and set self for block argument
2014-05-22 00:00:46 +09:00
ksss 0bd8e48773 Module#initialize set created object
for block argument
2014-05-21 23:09:19 +09:00
take_cheeze 3fa19357b3 Reduce children filenames listing.
It is executed per each debug filenames in irep to same ireps(children).
2014-05-21 22:00:11 +09:00
take_cheeze 87eec261e0 Reduce filename table creation in irep dumping to once. 2014-05-21 21:57:33 +09:00
Yukihiro "Matz" Matsumoto f4570d411d Merge pull request #2301 from mimaki/fix-load-mrb-segv
mrb_load_irep_file() caused SEGV
2014-05-21 18:03:58 +09:00
Yukihiro "Matz" Matsumoto a11f994e01 direct invocation of instance_eval 2014-05-21 18:00:48 +09:00
mimaki e52f1bd74e Check mrbc_context is null 2014-05-21 17:12:03 +09:00
Yukihiro "Matz" Matsumoto 74da72409e direct invocation of module_eval; ref #2298 2014-05-21 14:49:06 +09:00
Yukihiro "Matz" Matsumoto a6f26514a5 break in blocks cannot cross C function boundaries; fix #2298 2014-05-21 09:00:30 +09:00
Yukihiro "Matz" Matsumoto abbb8c5c31 Merge pull request #2300 from yui-knk/fix-comment
Correct comment in exception test.
2014-05-20 23:16:26 +09:00
Yukihiro "Matz" Matsumoto ee274ba30f Merge pull request #2299 from take-cheeze/cc_ext
Support extension '.cc' in source code listing.
2014-05-20 23:16:05 +09:00
yui-knk 756bfa6cd2 Correct comment in exception test. 2014-05-20 23:02:47 +09:00
take_cheeze 9ac23ae214 Support extension '.cc' in globbing. 2014-05-20 22:52:08 +09:00
Yukihiro "Matz" Matsumoto 929328ad3b Merge pull request #2295 from ksss/module-initialize
Implement Module#initialize (15.2.2.4.31)
2014-05-20 16:22:11 +09:00
Yukihiro "Matz" Matsumoto 3cbae53541 move prototype of mrb_format() from error.h to mruby.h; ref #2274 2014-05-20 14:53:42 +09:00
Yukihiro "Matz" Matsumoto 7195600dbf Merge branch 'master' of github.com:mruby/mruby 2014-05-20 11:27:06 +09:00
Yukihiro "Matz" Matsumoto 4b6de9dea6 update raise in ensure test 2014-05-20 11:25:17 +09:00
Yukihiro "Matz" Matsumoto 3fc8f0435a correct comment; ref #2297 2014-05-20 11:24:15 +09:00
Yukihiro "Matz" Matsumoto b0477f1d3f Merge branch 'add-exception-test' of https://github.com/yui-knk/mruby into yui-knk-add-exception-test 2014-05-20 11:22:49 +09:00
Yukihiro "Matz" Matsumoto 4004e122a2 Merge pull request #2296 from take-cheeze/core_local_vars
Move `Kernel.local_variables` to core.
2014-05-20 11:21:31 +09:00
yui-knk f55851cb74 Add 'Raise in rescue' test to exception. 2014-05-20 00:02:03 +09:00
take_cheeze d8d07a2345 Move Kernel.local_variables to core. 2014-05-19 22:05:02 +09:00
ksss c4a225f0be mrb_include_module support class and module
that not have methods each other
2014-05-19 19:29:33 +09:00
ksss ffbf90bdc8 Implement Module#initialize (15.2.2.4.31) 2014-05-19 19:28:42 +09:00
Yukihiro "Matz" Matsumoto c4268f67d0 UINT16_MAX as symbol length is reserved; ref #2294 2014-05-19 18:43:32 +09:00
Yukihiro "Matz" Matsumoto 54c2dcf231 allow NULL (no variable) in lvar section of mrb format; fix #2294
This fix use UINT16_MAX for NULL symbol tag, that means maximum symbol length
is not UINT16_MAX-1.
2014-05-19 18:39:37 +09:00
Yukihiro "Matz" Matsumoto 91a025b1e6 reimplement Range#size using double with fixing corner cases; ref #2293 2014-05-19 18:04:27 +09:00
Yukihiro "Matz" Matsumoto 90fa54767a Merge pull request #2293 from suzukaze/range.size
Add Range#size
2014-05-19 16:48:27 +09:00
Jun Hiroe 4b3ff090ab Add Range#size 2014-05-19 16:17:10 +09:00
Yukihiro "Matz" Matsumoto 67c5d554a3 Merge pull request #2291 from carsonmcdonald/removeivtest
Add test for remove_instance_variable
2014-05-19 15:01:48 +09:00
Yukihiro "Matz" Matsumoto ef01692c54 Merge pull request #2289 from take-cheeze/local_variables_iso
Add ISO index to `Kernel.local_variables`.
2014-05-19 15:00:57 +09:00
Yukihiro "Matz" Matsumoto c0e6f5f801 Merge pull request #2290 from take-cheeze/eval_iso
Add ISO index to `Kernel.eval` and `Kernel#eval`.
2014-05-19 14:07:43 +09:00
Carson McDonald aa2e03cdf6 Add test for remove_instance_variable 2014-05-18 15:53:11 -04:00
take_cheeze 3aeb4568ab Add ISO index to Kernel.eval and Kernel#eval. 2014-05-18 23:45:24 +09:00
take_cheeze 0f742392b5 Add ISO index to Kernel.local_variables. 2014-05-18 23:34:56 +09:00
Yukihiro "Matz" Matsumoto a1d11762dc Merge pull request #2288 from ksss/define-class
support class define in singleton class
2014-05-18 23:02:35 +09:00
ksss ef4f29be70 support class define in singleton class 2014-05-18 12:55:35 +00:00
Yukihiro "Matz" Matsumoto 4a6650b191 Merge pull request #2287 from yui-knk/add-space
Add a space aftre bracket.
2014-05-18 21:09:04 +09:00
Yukihiro "Matz" Matsumoto 85e36b52aa Merge pull request #2285 from suzukaze/fix-indent
Fix indent in mrb_hash_to_hash()
2014-05-18 21:07:58 +09:00
Yukihiro "Matz" Matsumoto a600963ccf Merge pull request #2284 from yui-knk/use-macro
Use boolean macro in exc_equal.
2014-05-18 21:07:28 +09:00
Yukihiro "Matz" Matsumoto d4db72d721 Merge pull request #2283 from yui-knk/delete-space
Remove space.
2014-05-18 21:07:01 +09:00
Yukihiro "Matz" Matsumoto 3979cb0433 Merge pull request #2281 from ksss/doc-test
instance method name use "#" instead of "." for assert
2014-05-18 21:05:13 +09:00
yui-knk 45305686fe Add a space aftre bracket. 2014-05-18 19:40:17 +09:00
Jun Hiroe 47c964bc18 Use boolean macro in kernel.c 2014-05-18 15:37:01 +09:00
Jun Hiroe d330e5b102 Fix indent in mrb_hash_to_hash() 2014-05-18 15:33:41 +09:00
yui-knk 3422805fc4 Use boolean macro in exc_equal. 2014-05-18 14:25:44 +09:00
yui-knk 087bab2335 Remove space. 2014-05-18 13:32:34 +09:00
yui-knk 1f3957afe4 Change range_check before mrb_obj_alloc. 2014-05-18 11:59:54 +09:00
ksss 464bbbddc7 instance method name use "#" instead of "." for assert 2014-05-18 10:54:23 +09:00
Yukihiro "Matz" Matsumoto 1f6d8d73bd Merge pull request #2276 from yui-knk/add-comment
Add comment to Fixnum Class.
2014-05-17 16:07:00 +09:00
yui-knk 76593ee0e7 Add comment to Fixnum Class. 2014-05-17 13:51:16 +09:00
Yukihiro "Matz" Matsumoto 5e5ca8de53 Merge pull request #2275 from suzukaze/refactor-string.c-2
Refactor string.c Fix #2267
2014-05-17 13:32:55 +09:00
Jun Hiroe 932efe53e9 Refactor mrb_str_intern() in string.c 2014-05-17 13:22:43 +09:00
Jun Hiroe 944b395083 Refactor mrb_str_equal_m in string.c 2014-05-17 13:22:43 +09:00
Jun Hiroe cf680f05fb Refactor mrb_str_new() in string.c 2014-05-17 13:20:00 +09:00
Yukihiro "Matz" Matsumoto a1a5eae925 Merge pull request #2273 from suzukaze/refactor-range.c
Use boolean macro in mrb_range_initialize()
2014-05-17 13:05:28 +09:00
Yukihiro "Matz" Matsumoto 54d627bd00 Merge pull request #2270 from suzukaze/refactor-class.c
Use boolean macro
2014-05-17 13:05:05 +09:00
Yukihiro "Matz" Matsumoto d77e521e9c Merge pull request #2269 from suzukaze/delete-semicolon
Delete unnecessary semicolon
2014-05-17 13:04:38 +09:00
Yukihiro "Matz" Matsumoto 274c99c478 Merge pull request #2268 from yui-knk/replace-tab
Replace tab with spaces.
2014-05-17 12:54:28 +09:00
Jun Hiroe 0725aacfeb Use boolean macro in mrb_range_initialize() 2014-05-17 09:58:40 +09:00
Jun Hiroe bcd8980c78 Use boolean macro 2014-05-17 02:08:01 +09:00
Jun Hiroe 0388e373d0 Delete unnecessary semicolon 2014-05-17 00:52:00 +09:00
yui-knk 0c96ba4bd8 Replace tab with spaces. 2014-05-17 00:49:08 +09:00
Yukihiro "Matz" Matsumoto 13db4da204 Merge pull request #2266 from suzukaze/fix-indent
Fix indents
2014-05-17 00:32:51 +09:00
Jun Hiroe 7328169a13 Fix indents 2014-05-17 00:20:32 +09:00
Yukihiro "Matz" Matsumoto 265f1b9952 Merge pull request #2265 from suzukaze/refactor
Add new line behind return type
2014-05-17 00:15:13 +09:00
Yukihiro "Matz" Matsumoto 0e50d8e8f4 Merge pull request #2264 from ksss/const_missing
const_missing error message more detail
2014-05-17 00:14:48 +09:00
Yukihiro "Matz" Matsumoto 4821ea7c67 Merge pull request #2263 from suzukaze/replace-tab-with-space
Replace tabs with spaces in eval.c
2014-05-17 00:14:19 +09:00
Yukihiro "Matz" Matsumoto f2f8c72254 Merge pull request #2262 from ksss/doc-opcode
[DOC] fix op code doc
2014-05-17 00:13:56 +09:00
Yukihiro "Matz" Matsumoto 4ac310897e Merge pull request #2261 from take-cheeze/fix_2259
Fix #2259 .
2014-05-17 00:10:30 +09:00
Jun Hiroe 665bc37288 Add new line behind return type 2014-05-16 22:46:41 +09:00
Jun Hiroe ff890c191c Replace tabs with spaces in eval.c 2014-05-16 22:40:14 +09:00
ksss 066c2772e8 const_missing error message more detail 2014-05-16 22:26:47 +09:00
ksss 6a7f133d02 include/mruby/opcode.h fix operation doc
src/vm.c fix operation doc
[ci skip]
2014-05-16 20:44:54 +09:00
take_cheeze 49cf477688 Fix #2259 . 2014-05-16 19:58:36 +09:00
Yukihiro "Matz" Matsumoto 41b46ca1ed register<nlocals may not have a local variable name (e.g. a block arg); fix #2258 2014-05-16 00:04:55 +09:00
Yukihiro "Matz" Matsumoto 60051de401 Merge pull request #2257 from miura1729/original2
Suport block in Kernel#eval
2014-05-15 21:02:53 +09:00
Miura Hideki da8d07d5d4 Suport block in Kernel#eval 2014-05-15 20:28:26 +09:00
Yukihiro "Matz" Matsumoto 9dae3f67d6 compile mruby-bin-strip gem by default 2014-05-15 17:14:00 +09:00
Yukihiro "Matz" Matsumoto f0b86f36c3 move mrb_irep_remove_lv from etc.c to mruby-bin-strip gem 2014-05-15 17:13:16 +09:00
take_cheeze e0064acac7 Implement LVAR section removing option in mruby-strip. 2014-05-15 15:15:06 +09:00
take_cheeze 30e0dc7956 Support LVAR section removing. 2014-05-15 15:08:30 +09:00
Yukihiro "Matz" Matsumoto c2f77c7836 Merge branch 'master' of github.com:mruby/mruby 2014-05-15 12:09:05 +09:00
Yukihiro "Matz" Matsumoto 0651051ded allow quit/exit to work within mirb; fix #2253 close #2254
also allow spaces around quit/exit.
2014-05-15 12:07:02 +09:00
Yukihiro "Matz" Matsumoto 157bebf437 Merge pull request #2255 from mitchblank/master
two trivial fixes
2014-05-15 08:58:21 +09:00
Mitchell Blank Jr 688602eb81 Fix incorrect info in minirake's help message -- "-q" is the default, not "-v" 2014-05-14 14:15:13 -07:00
Mitchell Blank Jr 493025c3af print_r() and print_lv() should only be compiled in for ENABLE_STDIO 2014-05-14 14:13:56 -07:00
Yukihiro "Matz" Matsumoto 6f6f50d529 adjust signedness in mruby-eval gem 2014-05-14 23:17:11 +09:00
Yukihiro "Matz" Matsumoto 2be348a0f1 mv opcode.h -> include/mruby/opcode.h and remove duplication from mruby-eval gem 2014-05-14 23:14:08 +09:00
Miura Hideki f10331cfe6 Modify eval for access outer local variable 2014-05-14 21:42:39 +09:00
Yukihiro "Matz" Matsumoto 27df1a84bc Kernel.local_variables to list UPVAR as well 2014-05-14 17:38:27 +09:00
Yukihiro "Matz" Matsumoto 232ec102d6 Merge branch 'take-cheeze-dump_lv' 2014-05-14 17:36:22 +09:00
Yukihiro "Matz" Matsumoto 9184d254e2 resize register number in LVAR section from 32bits to 16bits 2014-05-14 17:32:30 +09:00
Yukihiro "Matz" Matsumoto 7a5d8a40fe rename lv section header from LOCV to LVAR 2014-05-14 17:26:45 +09:00
Yukihiro "Matz" Matsumoto 10459a5eb2 Merge branch 'dump_lv' of https://github.com/take-cheeze/mruby into take-cheeze-dump_lv 2014-05-14 11:27:41 +09:00
Yukihiro "Matz" Matsumoto 625988eea1 Merge pull request #2249 from yui-knk/fix-iso
Add ISO No. to Integer#divmod  test.
2014-05-14 08:52:50 +09:00
yui-knk b9e9ce9237 Add ISO No. to Integer#divmod test. 2014-05-14 08:48:04 +09:00
Yukihiro "Matz" Matsumoto e1b84143c6 Merge pull request #2248 from carsonmcdonald/mulfix
Another change to fix issue #2244
2014-05-14 01:19:27 +09:00
Yukihiro "Matz" Matsumoto 1a462131c0 Merge pull request #2247 from yui-knk/fix-include
Replace from include <>, to include "".
2014-05-14 01:12:43 +09:00
Carson McDonald f0fed9dbec Consolidate muliptlication into one place 2014-05-13 11:46:47 -04:00
Carson McDonald 01988e3be7 Make sure c is large enough if there is an overflow 2014-05-13 11:46:29 -04:00
yui-knk 681b932d98 Replace from include <>, to include "". 2014-05-13 23:30:58 +09:00
Yukihiro "Matz" Matsumoto 33b2975c9d Merge pull request #2246 from take-cheeze/fix_codedump
Remove unnecessary newline in `OP_GETGLOBAL` codedump.
2014-05-13 23:19:21 +09:00
Yukihiro "Matz" Matsumoto c12f64271a fix overflow error like #2244 on MRB_WORD_BOXING 2014-05-13 23:15:44 +09:00
take_cheeze f2450928b2 Remove unnecessary newline in OP_GETGLOBAL codedump. 2014-05-13 22:47:43 +09:00
Yukihiro "Matz" Matsumoto 190d9ebbe2 should use mrb_type() for the sake of MRB_WORD_BOXING 2014-05-13 21:47:32 +09:00
Yukihiro "Matz" Matsumoto 971e6abadb Merge branch 'master' of github.com:mruby/mruby 2014-05-13 20:18:06 +09:00
Yukihiro "Matz" Matsumoto 0265b47833 remove unnecessary semicolons from a38f8f 2014-05-13 20:17:54 +09:00
Yukihiro "Matz" Matsumoto 15a2003aeb Merge pull request #2190 from cremno/mrbtest-mrb_int-constants
test fixnum overflow for add, sub and mul
2014-05-13 18:16:52 +09:00
Yukihiro "Matz" Matsumoto a38f8fe606 support comments in user-input; also add checks for buffer overflow 2014-05-13 16:03:41 +09:00
Yukihiro "Matz" Matsumoto 4e357a4963 protect argument array from GC in OP_ENTER 2014-05-13 16:01:30 +09:00
Yukihiro "Matz" Matsumoto 5867167ffd add dependency information based on #2239; fix #2236, close #2239 2014-05-13 13:08:18 +09:00
Yukihiro "Matz" Matsumoto 59a4a286c2 Merge branch 'master' of github.com:mruby/mruby 2014-05-13 12:59:34 +09:00
Yukihiro "Matz" Matsumoto f454f827ee should not use String#<< which is defined in mruby-string-ext; use Array#join instead; ref #2239 2014-05-13 12:59:21 +09:00
Yukihiro "Matz" Matsumoto 40378f9519 Merge pull request #2243 from yui-knk/fix-iso
Fix ISO No.
2014-05-13 12:49:11 +09:00
yui-knk 935a4ccce7 Fix ISO No. 2014-05-13 09:48:02 +09:00
Yukihiro "Matz" Matsumoto b584eaf64b Merge branch 'master' of github.com:mruby/mruby 2014-05-13 09:14:11 +09:00
Yukihiro "Matz" Matsumoto b4657182da convert &arg using to_proc; fix #2242 2014-05-13 09:13:33 +09:00
Yukihiro "Matz" Matsumoto 53fa535d2b Merge pull request #2241 from take-cheeze/rebuild_irep
Rebuild no mrb_open mrbgems test when config file is modified.
2014-05-13 08:48:03 +09:00
Yukihiro "Matz" Matsumoto 01a1f02c6e Merge pull request #2240 from suzukaze/fix-hash-test
Fix Hash test
2014-05-13 08:42:36 +09:00
take_cheeze 6a15f42ec5 Rebuild no mrb_open mrbgems test when config file is modified. 2014-05-12 21:37:54 +09:00
Jun Hiroe ab2ce33859 Fix Hash test 2014-05-12 20:47:44 +09:00
Yukihiro "Matz" Matsumoto bcbf078ebd Merge pull request #2235 from yui-knk/add-scr_e
Add scr_e, to not reassign to e.
2014-05-12 18:59:00 +09:00
yui-knk ac58d1bdf6 Rename e to exception, scr_e to script_error. 2014-05-12 13:50:49 +09:00
Yukihiro "Matz" Matsumoto 98ecbdafd5 Merge pull request #2238 from kyab/fix_chipkitmax32_build_config
Disable C++ exception for chipKIT Max32 example build_config
2014-05-12 09:28:39 +09:00
kyab da3b69a852 Disable C++ exception for chipKIT Max32 example build_config 2014-05-11 23:56:22 +09:00
yui-knk e07099d81b Add scr_e, to not reassign to e. 2014-05-11 19:28:34 +09:00
Yukihiro "Matz" Matsumoto b1eb337a34 Merge pull request #2231 from kyab/update_example_build_config
Update example build_config to include host build setting
2014-05-11 17:26:45 +09:00
Yukihiro "Matz" Matsumoto 9f7651fa65 Merge pull request #2234 from suzukaze/refactor
Refactor functions in kernel.c
2014-05-11 17:25:50 +09:00
Yukihiro "Matz" Matsumoto 434f0a6dbb Merge pull request #2233 from suzukaze/fix-indent
Fix indents in kernel.c
2014-05-11 17:22:41 +09:00
Yukihiro "Matz" Matsumoto ad8cb8cab1 Merge pull request #2232 from kyab/fix_msvc_warning_random.c
Pacify MSVC warnings for random.c
2014-05-11 17:21:08 +09:00
Jun Hiroe d973bcff0e Refactor mrb_equal_m() 2014-05-11 03:58:07 +09:00
Jun Hiroe 50d9d974e0 Refacotr mrb_obj_not_equal_m() 2014-05-11 03:55:51 +09:00
Jun Hiroe 2f1b4eb144 Refactor mrb_obj_equal_m() 2014-05-11 03:54:07 +09:00
Jun Hiroe 1eb6c1e963 Fix indents 2014-05-11 03:48:32 +09:00
kyab 203740bac5 Pacify MSVC warnings for random.c 2014-05-10 23:50:57 +09:00
kyab 2f22829097 Update example build_config to include host build setting 2014-05-10 23:27:39 +09:00
Yukihiro "Matz" Matsumoto 2d8db3c6bf Merge pull request #2230 from take-cheeze/doc_update
Fix document generator to remove trailing space in generated document.
2014-05-10 22:43:25 +09:00
take_cheeze b03330b3e4 Fix document generator to remove trailing space in generated document.
Update generated document.
2014-05-10 22:08:40 +09:00
Yukihiro "Matz" Matsumoto fb77b033a5 Merge pull request #2229 from yui-knk/add-comment-each_pair
Add comment to Hash#each_pair. And change the line
2014-05-10 20:54:18 +09:00
yui-knk d88a9d761f Add comment to Hash#each_pair. And change the line
Add comment about ISO.
Current place is misleading so change line No.
2014-05-10 20:16:19 +09:00
Yukihiro "Matz" Matsumoto 98e035ae09 Merge pull request #2228 from suzukaze/add-comments-to-hash
Add comments to Hash methods
2014-05-10 19:43:40 +09:00
Jun Hiroe 012c32ad0a Add comments to Hash methods 2014-05-10 18:11:07 +09:00
Yukihiro "Matz" Matsumoto adea2ca371 Merge pull request #2223 from yui-knk/fix-nameerror
Delete unused NameError#new. And add test.
2014-05-10 13:11:00 +09:00
Yukihiro "Matz" Matsumoto e59c6a1100 Merge pull request #2226 from yui-knk/hash-merge-error
Change to raise TypeError (Hash#merge, #merge!)
2014-05-10 11:14:55 +09:00
Yukihiro "Matz" Matsumoto 3e2c5da443 Merge pull request #2225 from ksss/proc-segv
OP_ENTER fix segmentation fault
2014-05-10 11:14:10 +09:00
yui-knk 658a00ba49 Change to raise TypeError (Hash#merge, #merge!) 2014-05-10 10:18:15 +09:00
ksss 7dbfe19fc6 OP_ENTER fix segmentation fault 2014-05-10 09:43:32 +09:00
yui-knk 1a00a34cc2 Delete unused NameError#new. And add test. 2014-05-10 01:12:52 +09:00
Yukihiro "Matz" Matsumoto e07a3731d1 Merge pull request #2221 from yui-knk/add-exception-test
Add exception test
2014-05-10 00:48:44 +09:00
Yukihiro "Matz" Matsumoto 7f899d7752 Merge pull request #2222 from take-cheeze/remove_proc_meth
Remove use of mruby-proc-ext method in core test.
2014-05-10 00:47:43 +09:00
Yukihiro "Matz" Matsumoto 8152373d99 Merge pull request #2219 from kyab/fix_msvc_warning_time.c
Pacify MSVC warnings for time.c
2014-05-10 00:47:14 +09:00
Yukihiro "Matz" Matsumoto c302b86fa0 Merge pull request #2220 from yui-knk/refactor-test
Refactoring test to use assert_nothing_raised.
2014-05-10 00:46:22 +09:00
Yukihiro "Matz" Matsumoto 48ac1f74f1 Merge pull request #2218 from take-cheeze/move_method
Move `__method__` to mruby-kernel-ext since it's not ISO method.
2014-05-10 00:45:34 +09:00
yui-knk 8b6bfd1a25 Add assert to Exception#inspect test. 2014-05-10 00:07:20 +09:00
take_cheeze 9a5ef1a127 Remove use of mruby-proc-ext method. 2014-05-10 00:07:03 +09:00
yui-knk faee698746 Refactoring test to use assert_nothing_raised. 2014-05-09 23:40:41 +09:00
kyab 4a05dce4a3 pacify MSVC warnings for time.c 2014-05-09 23:38:05 +09:00
take_cheeze d0c0beb880 Move __method__ to mruby-kernel-ext since it's not ISO method. 2014-05-09 22:44:10 +09:00
Yukihiro "Matz" Matsumoto 64b30b65ee Merge pull request #2216 from iij/pr-mirb-link-termcap
libreadline requires libtermcap on OpenBSD.
2014-05-09 14:45:25 +09:00
Tomoyuki Sahara 6a41149585 libreadline requires libtermcap on OpenBSD. 2014-05-09 14:26:12 +09:00
Yukihiro "Matz" Matsumoto b8e524bb9e Merge pull request #2214 from ksss/proc-clear
OP_ENTER clean block object in register
2014-05-09 12:00:53 +09:00
Yukihiro "Matz" Matsumoto 78f2d283a7 Merge pull request #2215 from yui-knk/fix-typo-test
Add ISO No. to String#inspect test.
2014-05-09 12:00:25 +09:00
Yukihiro "Matz" Matsumoto a9488618ce Merge pull request #2213 from suzukaze/add-hash.key
Add Hash#key
2014-05-09 11:59:28 +09:00
Yukihiro "Matz" Matsumoto 0b23d10a96 Merge pull request #2212 from yui-knk/add-range-test
Add tests for Range#to_s Range#inspect.
2014-05-09 11:43:25 +09:00
yui-knk 6932e9e142 Add ISO No. to String#inspect test. 2014-05-09 08:43:39 +09:00
ksss 06a67df950 OP_ENTER clean block object in register 2014-05-09 08:04:36 +09:00
Tomoyuki Sahara 9ee9c271d1 Merge pull request #20 from windwiny/patch-1
compatible 32 bit windows
2014-05-09 02:33:00 +09:00
Jun Hiroe dc4c042df5 Add Hash#key 2014-05-09 00:46:33 +09:00
yui-knk 60d2b51cc0 Add tests for Range#to_s Range#inspect. 2014-05-08 23:50:11 +09:00
take_cheeze 64300b2c43 Add API mrb_atexit().
`mrb_final_mrbgems` will be called as mrb_state atexit function.
Maybe useful in #1844.
2014-05-08 22:19:14 +09:00
Yukihiro "Matz" Matsumoto c071ad13a9 Merge pull request #2210 from yui-knk/fix-typo
fix typo
2014-05-08 20:50:04 +09:00
yui-knk aac3992195 fix typo 2014-05-08 13:55:30 +09:00
Yukihiro "Matz" Matsumoto 91cc8949e8 use mrb_field_write_barrier_value() in hash.c 2014-05-08 11:09:08 +09:00
Yukihiro "Matz" Matsumoto b34e24b07d use mrb_field_write_barrier_value() in array.c 2014-05-08 11:06:41 +09:00
Yukihiro "Matz" Matsumoto 606cb68c16 Merge pull request #2209 from yui-knk/fix-include
Replace from include <>, to include "".
2014-05-08 08:53:10 +09:00
Yukihiro "Matz" Matsumoto d25d343eee Merge pull request #2208 from yui-knk/array-error
Make Array#[]= raise IndexError.
2014-05-08 08:51:36 +09:00
yui-knk 27167f8de0 Replace from include <>, to include "". 2014-05-08 08:46:55 +09:00
yui-knk eafc4dd0af Make Array#[]= raise IndexError.
If second param is negative, Array#[] raise IndexError.
2014-05-08 00:17:17 +09:00
Yukihiro "Matz" Matsumoto 09b9c7762d Merge pull request #2207 from take-cheeze/time_def
Remove `Time` defined check in mruby-time gem test.
2014-05-07 22:12:28 +09:00
windwiny dc61ef1c65 compatible 32 bit windows 2014-05-07 20:33:12 +08:00
take_cheeze f0154d6e3a Remove Time defined check in test. 2014-05-07 21:21:18 +09:00
Yukihiro "Matz" Matsumoto c7ef2205e1 Merge pull request #2206 from mattn/fix_build_mingw
Fix build on mingw32/64: struct timeval isn't defined in default. See: 6...
2014-05-07 11:02:45 +09:00
mattn 0b5fe0ad6f Fix build on mingw32/64: struct timeval isn't defined in default. See: 642477ef6a 2014-05-07 10:18:57 +09:00
Yukihiro "Matz" Matsumoto ad2e6d0c7a Merge pull request #2204 from take-cheeze/kernel_fail
Implement Kernel.fail and Kernel#fail .
2014-05-07 08:47:01 +09:00
Yukihiro "Matz" Matsumoto 14e5c3732e Merge pull request #2205 from ksss/proc-m2
OP_ENTER fix variable assignment
2014-05-07 08:45:50 +09:00
take_cheeze 2fca5f3353 Add mruby-kernel-ext to default gembox. 2014-05-07 00:01:38 +09:00
take_cheeze 208bafba2d Move Kernel#fail definition to mruby-kernel-ext mrbgem. 2014-05-07 00:01:30 +09:00
ksss 0c3226db04 OP_ENTER fix variable assignment 2014-05-06 23:30:02 +09:00
take_cheeze 98a610831a Implement Kernel.fail and Kernel#fail . 2014-05-06 21:29:35 +09:00
Yukihiro "Matz" Matsumoto 12915f9577 Merge pull request #2203 from yui-knk/add-call-seq
Add a comment to ObjectSpace.each_object.
2014-05-06 13:31:25 +09:00
yui-knk c2732a160a Add a comment to ObjectSpace.each_object. 2014-05-06 12:41:23 +09:00
Yukihiro "Matz" Matsumoto a776e3a1eb Merge pull request #2202 from akuroda/pr_refactor_fix_mod
refactor fix_mod
2014-05-06 00:11:16 +09:00
Akira Kuroda c445c6c7da refactor fix_mod
fix unreachable condition
use b
2014-05-05 23:43:37 +09:00
Yukihiro "Matz" Matsumoto 260d38d5ee Merge pull request #2200 from cremno/add-functions-for-safe-addition-and-subtraction
Add functions for safe addition and subtraction
2014-05-05 22:54:55 +09:00
Yukihiro "Matz" Matsumoto 2ceb71f970 Merge pull request #2201 from take-cheeze/day_of_week
Implement day of week methods.
2014-05-05 22:53:39 +09:00
Yukihiro "Matz" Matsumoto f0b0a2dd62 Merge pull request #2199 from cremno/use-memmove
fix memcpy-param-overlap
2014-05-05 22:47:39 +09:00
take_cheeze 7bab3d0bb2 Implement day of week methods. 2014-05-05 22:41:16 +09:00
cremno cf8df563c0 add function for checked mrb_int subtraction 2014-05-05 15:28:26 +02:00
cremno 0f39304265 add function for checked mrb_int addition 2014-05-05 15:24:22 +02:00
cremno ff03cea79b temporary macros for checked arithmetic functions 2014-05-05 15:22:42 +02:00
Yukihiro "Matz" Matsumoto 02cabf8fa7 Merge pull request #2198 from suzukaze/add-hash.keep_if
Add Hash#keep_if
2014-05-05 21:17:14 +09:00
Yukihiro "Matz" Matsumoto e620c666d9 Merge pull request #2196 from suzukaze/refactor-load.c
Refactor read_lineno_record_1() in load.c
2014-05-05 21:08:48 +09:00
Yukihiro "Matz" Matsumoto d44035f26f Merge pull request #2194 from suzukaze/refactor-string.c2
Refactor string.c
2014-05-05 21:08:08 +09:00
Jun Hiroe dcad562f73 Add Hash#keep_if 2014-05-05 20:26:28 +09:00
Yukihiro "Matz" Matsumoto 1ce9060fa9 Merge pull request #2195 from suzukaze/fix-indent-string.c
Fix indents in mrb_str_inspect() of string.c
2014-05-05 20:22:00 +09:00
Yukihiro "Matz" Matsumoto 08338e26c7 Merge pull request #2193 from suzukaze/refactor-string.c
Use mrb_bool instead of mrb_int  in string.c
2014-05-05 20:20:35 +09:00
Yukihiro "Matz" Matsumoto 53fcc40ab2 Merge pull request #2192 from suzukaze/add-hash.invert
Add Hash#invert
2014-05-05 20:18:46 +09:00
Jun Hiroe 37d2690d0f Refactor read_lineno_record_1() in load.c 2014-05-05 13:37:14 +09:00
Jun Hiroe e8afac3ed7 Fix indents in mrb_str_inspect() of string.c 2014-05-05 13:04:58 +09:00
Jun Hiroe 06e56a5004 Refactor mrb_str_hash() 2014-05-05 12:59:42 +09:00
Jun Hiroe b9dc9ccd14 Refacotr mrb_str_substr() 2014-05-05 12:56:20 +09:00
Jun Hiroe fdde840d06 Refactor mrb_str_upcase_bang 2014-05-05 12:51:04 +09:00
Jun Hiroe 2f8de5b32b Refactor mrb_str_split_m() 2014-05-05 12:49:08 +09:00
Jun Hiroe e340babc1e Refactor mrb_str_downcase_bang() 2014-05-05 12:42:57 +09:00
Jun Hiroe c6551e03e0 Refactor mrb_str_capitalize_bang() 2014-05-05 12:40:15 +09:00
Jun Hiroe 015f60fcad Add Hash#invert 2014-05-05 11:15:48 +09:00
cremno 8876c059a7 fix memcpy-param-overlap 2014-05-05 04:07:54 +02:00
Yukihiro "Matz" Matsumoto 5921dd19c5 Merge pull request #2191 from yui-knk/refactor-exc-test
Refactoring exception test.
2014-05-05 10:07:58 +09:00
yui-knk ff90bb1c18 Refactoring exception test.
Change to use assert_equal explicitly.
2014-05-05 09:52:29 +09:00
cremno 964ce6e327 test fixnum overflow for add, sub and mul 2014-05-05 00:19:08 +02:00
cremno 7a8a97ccee add Mrbtest::FIXNUM_{MAX,MIN,BIT} 2014-05-05 00:19:02 +02:00
Yukihiro "Matz" Matsumoto f0be02fcf2 Merge pull request #2188 from takeru/dont_reset_ridx_eidx
Don't reset ridx,eidx. And fix for #1949
2014-05-04 22:58:53 +09:00
sasaki takeru b59ac841af Don't reset ridx,eidx. And fix for #1949 2014-05-04 22:39:51 +09:00
Yukihiro "Matz" Matsumoto 14fe510494 Merge pull request #2187 from take-cheeze/header_searcher_doc
Add document of header searcher of compiler.
2014-05-04 22:18:12 +09:00
take_cheeze 4d31c036d3 Add document of header searcher of compiler. 2014-05-04 22:13:27 +09:00
Yukihiro "Matz" Matsumoto 571f0d4aca Merge pull request #2186 from suzukaze/add-hash.flatten
Add Hash#flatten
2014-05-04 21:55:27 +09:00
Jun Hiroe 28a858c17e Add Hash#flatten 2014-05-04 21:14:13 +09:00
Yukihiro "Matz" Matsumoto e9e4c13390 Merge pull request #2161 from nobu/embedded_document
Embedded document
2014-05-04 20:29:48 +09:00
Yukihiro "Matz" Matsumoto 07b9f2dea7 Merge pull request #2185 from suzukaze/hash-comments
Add Hash comments
2014-05-04 20:29:19 +09:00
Yukihiro "Matz" Matsumoto 8027c20d41 Merge pull request #2184 from yui-knk/fix-typo
Fix typo.
2014-05-04 20:28:50 +09:00
Jun Hiroe 08f2bb0bc5 Add Hash comments 2014-05-04 19:49:16 +09:00
yui-knk 73c370ae52 Fix typo. 2014-05-04 16:43:13 +09:00
Yukihiro "Matz" Matsumoto 0fe62ddcd3 Merge pull request #2183 from yui-knk/fix-error-comment
Fix comment of exc_inspect (and adjust spaces)
2014-05-04 12:29:19 +09:00
Yukihiro "Matz" Matsumoto b87bfe7356 Merge pull request #2182 from cremno/use-isfinite
simply use `isfinite`
2014-05-04 12:28:15 +09:00
Yukihiro "Matz" Matsumoto 4be6f1c79b Merge pull request #2181 from suzukaze/add-hash_delete_if
Add Hash#delete_if
2014-05-04 12:27:22 +09:00
yui-knk cf80e7fe21 Fix comment of exc_inspect (and adjust spaces) 2014-05-04 10:22:27 +09:00
cremno 86cfcd20d6 simply use isfinite 2014-05-04 01:50:17 +02:00
Jun Hiroe 3e7db4ad27 Add Hash#delete_if 2014-05-04 00:46:36 +09:00
Yukihiro "Matz" Matsumoto 8e4d3bb94e Merge pull request #2180 from yui-knk/fix-doc
Fix docs path.
2014-05-03 23:54:34 +09:00
Yukihiro "Matz" Matsumoto 0fd32be182 Merge pull request #2179 from take-cheeze/readline_warning
Suppress warning when using readline in mirb.
2014-05-03 23:54:07 +09:00
Yukihiro "Matz" Matsumoto b9ba036de8 Merge branch 'take-cheeze-values_at' 2014-05-03 23:50:33 +09:00
Yukihiro "Matz" Matsumoto 59fa859d59 refactoring mruby-struct 2014-05-03 23:50:04 +09:00
Yukihiro "Matz" Matsumoto f977772359 new macro mrb_int(mrb,x) to retrieve mrb_int from mrb_value with conversion if needed 2014-05-03 23:45:40 +09:00
Yukihiro "Matz" Matsumoto 1519e441a0 use proper length for mrb_get_values_at()
separate mrb_range_beg_len() into two: the one truncates range into the
sequence size, and the one does not.  #values_at uses the latter.
2014-05-03 23:35:24 +09:00
yui-knk 8773ad1a93 Fix docs path. 2014-05-03 21:57:14 +09:00
take_cheeze cf5155f8f7 Suppress warning when using readline in mirb. 2014-05-03 21:24:03 +09:00
Yukihiro "Matz" Matsumoto 206c96e4a7 reindent else 2014-05-03 21:20:14 +09:00
Yukihiro "Matz" Matsumoto 0c294af091 convert range edges to integers 2014-05-03 21:19:06 +09:00
Yukihiro "Matz" Matsumoto bd681269f4 do not raise error in mrb_range_beg_len() 2014-05-03 21:18:25 +09:00
Yukihiro "Matz" Matsumoto 342f124702 raise TypeError instead of ArgumentError when argument of wrong type given to the values_at 2014-05-03 21:17:22 +09:00
Yukihiro "Matz" Matsumoto c3aa436e2c Merge branch 'values_at' of https://github.com/take-cheeze/mruby into take-cheeze-values_at 2014-05-03 21:13:03 +09:00
Yukihiro "Matz" Matsumoto c2bd0d33ea remove each from range.c 2014-05-03 12:11:17 +09:00
Yukihiro "Matz" Matsumoto 44838f5698 Merge pull request #2178 from cremno/rename-dump_irep
add namespace prefix to `dump_irep`
2014-05-03 09:05:43 +09:00
Yukihiro "Matz" Matsumoto c8b00d011c Merge pull request #2177 from cremno/math-domain-error
mruby-math: define and use `Math::DomainError`
2014-05-03 09:05:10 +09:00
Yukihiro "Matz" Matsumoto 67bf3f1485 Merge pull request #2176 from cremno/msvc-treat-implicit-function-declaration-as-error
MSVC: treat implicit function decl. as error
2014-05-03 09:03:36 +09:00
Yukihiro "Matz" Matsumoto 4d521ed745 Merge pull request #2174 from suzukaze/fix-indent
Fix indent
2014-05-03 09:02:52 +09:00
Yukihiro "Matz" Matsumoto 98729dd69a Merge pull request #2173 from suzukaze/delete-unuse-variable
Delete unused variable in Array#delete_if
2014-05-03 09:02:29 +09:00
Nobuyoshi Nakada 8b13efc26d count skipped line numbers 2014-05-03 08:42:32 +09:00
Nobuyoshi Nakada cf3b880df6 skip to the next line and reset column after =end 2014-05-03 08:42:31 +09:00
Nobuyoshi Nakada 82fce52211 fix char after =end
skips() advance after the string skipped.
2014-05-03 08:42:31 +09:00
Nobuyoshi Nakada 854ae564a3 fix embedded documents
tabs are allowed after `=begin` and `=end`.
raise `SyntaxError` if no =end is found.
2014-05-03 08:42:31 +09:00
Nobuyoshi Nakada 69c6ff7aa0 fix condition for the rest of input
the input must rest the length of a string to be peeked at least.
fixes parse error at embedded documents by string eval, and `-e`
command line options.
2014-05-03 08:42:31 +09:00
cremno 405e8fbcd5 mruby-math: define and use Math::DomainError
Domain errors are detected as per ISO C99 and may differ from CRuby.
2014-05-02 23:48:25 +02:00
cremno 36eef0c222 add namespace prefix to dump_irep 2014-05-02 22:29:12 +02:00
cremno 6ff1b63b0d MSVC: treat implicit function decl. as error
As equivalent to GCC's `-Werror-implicit-function-declaration`.
2014-05-02 21:05:56 +02:00
Jun Hiroe 3988597afc Fix indent 2014-05-03 02:20:23 +09:00
Jun Hiroe 1aa885fae0 Delete unused variable in Array#delete_if 2014-05-03 01:41:41 +09:00
Yukihiro "Matz" Matsumoto 72fe54c403 Merge pull request #2172 from suzukaze/refactor-numeric.c
Refactor rshift
2014-05-03 01:28:21 +09:00
Jun Hiroe 129e5a6c21 Refactor rshift 2014-05-03 01:13:43 +09:00
Yukihiro "Matz" Matsumoto 85d286b4b8 Merge pull request #2170 from windwiny/patch-1
Update time.c
2014-05-03 00:10:34 +09:00
windwiny 642477ef6a Update time.c
miss __MINGW32__ macro check
2014-05-02 22:28:09 +08:00
take_cheeze 44dc05f12a Implement Struct#values_at and Array#values_at .
Add API `mrb_get_values_at()` to mruby/range.h .
2014-05-02 23:20:48 +09:00
Yukihiro "Matz" Matsumoto d91c9a9ea4 Merge pull request #2169 from takeru/load_crash
goto STOP if ridx==0
2014-05-02 15:03:25 +09:00
sasaki takeru bf214c4913 goto STOP if ridx==0 2014-05-02 11:05:31 +09:00
Yukihiro "Matz" Matsumoto ad7020f32a Merge pull request #2168 from carsonmcdonald/stackclearfix
On overflow, clear new stack space before mrb_raise
2014-05-02 00:29:42 +09:00
Yukihiro "Matz" Matsumoto f38928dfcf Merge pull request #2166 from take-cheeze/fix_for_1_8
Remove use of define_singleton_method.
2014-05-02 00:17:52 +09:00
Carson McDonald 03796274da On overflow, clear new stack space before mrb_raise 2014-05-01 10:50:50 -04:00
take_cheeze 2063bee7cc Remove use of define_singleton_method. 2014-05-01 22:51:35 +09:00
Yukihiro "Matz" Matsumoto 41dbcf7a3f Merge pull request #2165 from take-cheeze/header_searcher
Implement header searcher to use readline in mirb if possible.
2014-05-01 22:00:27 +09:00
Yukihiro "Matz" Matsumoto c17761d5dd Merge pull request #2164 from scalone/public_dump_irep
Added dump_irep in header.
2014-05-01 21:58:15 +09:00
take_cheeze 052fe51279 Use header searcher to find readline and linenoise. 2014-05-01 16:49:55 +09:00
take_cheeze b4a702f27d Implement header search for gcc and clang. 2014-05-01 16:49:54 +09:00
Yukihiro "Matz" Matsumoto cb2548141b Merge pull request #2163 from take-cheeze/struct_to_h
Implement Struct#to_h .
2014-05-01 08:49:53 +09:00
Yukihiro "Matz" Matsumoto 652a533965 Merge pull request #2162 from ksss/__send__
use Kernel#__send__ insteard of Kernel#send
2014-05-01 08:35:04 +09:00
Thiago Scalone 05df94f148 Added dump_irep in header. 2014-04-30 18:32:55 -03:00
take_cheeze 90d30f306e Implement Struct#to_h . 2014-04-30 23:00:33 +09:00
ksss d6b4cdb6ac use Kernel#__send__ insteard of Kernel#send 2014-04-30 22:25:21 +09:00
Yukihiro "Matz" Matsumoto 2cb54e4b9d Merge pull request #2160 from nobu/space
Space
2014-04-30 09:58:23 +09:00
Nobuyoshi Nakada ab67c57f65 remove trailing spaces 2014-04-30 09:50:14 +09:00
Nobuyoshi Nakada 345f172bba adjust indent 2014-04-30 09:50:02 +09:00
take_cheeze 5073d14e28 Remove lv_len and use nlocals - 1 instead.
Check that `lv`'s length is always `nlocals - 1`.
2014-04-29 22:06:59 +09:00
take_cheeze 7ea82fedd5 Implement Kernel.local_variables for testing dumped local variables information. 2014-04-29 20:47:50 +09:00
take_cheeze 4c7f9897c2 Support local variables information dumping. 2014-04-29 20:47:50 +09:00
Yukihiro "Matz" Matsumoto 0bdc87d239 indent codedump when file/line info is not available; ref #2147 2014-04-29 19:08:47 +09:00
Yukihiro "Matz" Matsumoto 70a4cc6b08 codedump for binary mrb files as well 2014-04-29 19:05:49 +09:00
Yukihiro "Matz" Matsumoto 077ccaf4a5 Merge pull request #2158 from kyab/support_doubling_stack
Add doubling stack extend, as fix for #2016
2014-04-29 18:57:18 +09:00
Yukihiro "Matz" Matsumoto 7bbda66824 Merge pull request #2147 from take-cheeze/dump_line_file
Print file name and line number in codedump if available.
2014-04-29 18:55:19 +09:00
kyab a13775eb22 Add doubling stack extend, as fix for #2016 2014-04-29 18:42:52 +09:00
Yukihiro "Matz" Matsumoto d3417838d2 turn on MRB_GC_STRESS for debug build on travis 2014-04-29 17:30:39 +09:00
Yukihiro "Matz" Matsumoto aab52be133 Merge pull request #2156 from cremno/fix-disabled-stdio-2
fix disabled stdio
2014-04-29 17:11:11 +09:00
Yukihiro "Matz" Matsumoto 5fb5c2a4c2 Merge pull request #2155 from cremno/define-resize_capa-as-a-function
define `resize_capa` as a function
2014-04-29 17:10:27 +09:00
Yukihiro "Matz" Matsumoto 8639703bec Merge pull request #2157 from cremno/remove-mrb_str_offset
remove `mrb_str_offset`
2014-04-29 17:08:04 +09:00
Yukihiro "Matz" Matsumoto 5398a55462 Merge pull request #2154 from cremno/dbl_dig
remove `DBL_DIG` fallback definition
2014-04-29 17:06:33 +09:00
cremno 739b155535 remove mrb_str_offset 2014-04-29 07:13:44 +02:00
cremno 01b76630b8 fix disabled stdio (and remove trailing spaces) 2014-04-29 07:05:30 +02:00
Yukihiro "Matz" Matsumoto 3464116fc1 Merge pull request #2153 from kyab/fix_msvc_warning_symbol.c
Fix MSVC warning for symbol.c
2014-04-29 13:51:05 +09:00
cremno 0406343f2b remove DBL_DIG fallback definition 2014-04-29 06:21:49 +02:00
cremno 5b3a442d31 include the missing header for DBL_DIG 2014-04-29 06:21:29 +02:00
cremno 92632c61dd define resize_capa as a function
This increases readability and maintainability,
and it also doesn't use reserved identifiers.
2014-04-29 06:09:45 +02:00
kyab 1405f3a514 Fix MSVC warning for symbol.c 2014-04-29 13:00:11 +09:00
Yukihiro "Matz" Matsumoto a2dc6f7db9 Merge pull request #2151 from carsonmcdonald/multilinecommentfix
Fix multiline comments
2014-04-29 12:29:29 +09:00
Yukihiro "Matz" Matsumoto 0bd99d7959 Merge pull request #2146 from utkarshkukreti/speed-up-select-bang
Speed up Array#select! from O(n^2) to O(n).
2014-04-29 12:27:48 +09:00
Yukihiro "Matz" Matsumoto 2ca5bed901 make cioff in struct REnv from int to ptrdiff_t; close #2149 2014-04-29 12:25:15 +09:00
Yukihiro "Matz" Matsumoto 48e82d7c77 cast intptr_t to mrb_int to pacify compiler warning; close #2148 2014-04-29 12:21:49 +09:00
Yukihiro "Matz" Matsumoto 88c0d0cf9a clear all stack everytime to prevent GC crash; ref #2109 2014-04-29 10:38:38 +09:00
Yukihiro "Matz" Matsumoto 29f6cdcd4d stack may be uncleared 2014-04-29 10:36:30 +09:00
Yukihiro "Matz" Matsumoto 57e6a783bc fiber context may be NULL 2014-04-29 10:32:49 +09:00
Yukihiro "Matz" Matsumoto f8c465dd44 clear ci->proc to prevent GC crash 2014-04-29 10:32:05 +09:00
Carson McDonald 9ac817ae78 Add tests for multiline comment parsing 2014-04-28 14:22:55 -04:00
Carson McDonald b2f3919bc2 Accept =begin and =end with spaces after 2014-04-28 14:15:03 -04:00
Carson McDonald af95acec17 make peek_n append p->pb to list 2014-04-28 14:11:18 -04:00
Tomoyuki Sahara 077f39bd38 Merge pull request #19 from schmurfy/solaris_flock
raise an error for flock on solaris
2014-04-29 00:45:08 +09:00
Julien Ammous 9a1b25bdd8 raise an error for flock on solaris 2014-04-28 15:40:04 +02:00
take_cheeze 46d8c08a14 Use int32_t as line variable type. 2014-04-28 22:17:40 +09:00
take_cheeze 197f3cb901 Print file name and line number in codedump if available. 2014-04-28 22:12:45 +09:00
Utkarsh Kukreti 6e9a088efb Speed up Array#select! from O(n^2) to O(n). 2014-04-28 12:14:15 +05:30
Yukihiro "Matz" Matsumoto 220f3124b9 should care about the case that given arguments are less then mandatory formal arguments and optional arguments exist; close #2144 2014-04-28 13:34:14 +09:00
Yukihiro "Matz" Matsumoto b1ec92f7cd fix OP_BLKPUSH dump format 2014-04-28 11:59:46 +09:00
Yukihiro "Matz" Matsumoto 1a44b8817b Merge pull request #2143 from mirichi/test
add post mandatory argument test
2014-04-28 10:44:31 +09:00
mirichi d97ab343bd add post mandatory argument test 2014-04-28 09:37:45 +09:00
Yukihiro "Matz" Matsumoto 2e59cd43de prevent printf warning 2014-04-28 08:30:57 +09:00
Yukihiro "Matz" Matsumoto 67fed3d7fb enable bintest on TravisCI to see how it works 2014-04-28 08:26:25 +09:00
Yukihiro "Matz" Matsumoto b53e69f18d better codedump formatting 2014-04-28 08:02:47 +09:00
Yukihiro "Matz" Matsumoto 3244ddf0c3 presreve local variables names in irep->lv 2014-04-28 07:29:37 +09:00
Yukihiro "Matz" Matsumoto c235d8f08d Merge pull request #2142 from cremno/rename-mrb_str_buf_append
rename `mrb_str_buf_append` to `mrb_str_cat_str`
2014-04-28 05:57:01 +09:00
Yukihiro "Matz" Matsumoto e0fe91bee5 Merge pull request #2141 from kyab/fix_msvc_warning_numeric.c
Fix MSVC warnings for numeric.c
2014-04-28 05:54:43 +09:00
Yukihiro "Matz" Matsumoto b0fd5229fc Merge pull request #2139 from suzukaze/add-array.select_bang
Add Array#select_bang
2014-04-28 05:53:52 +09:00
Yukihiro "Matz" Matsumoto e1f4e021de Merge pull request #2138 from take-cheeze/struct_to_a
Implement Struct#to_a and Struct#values .
2014-04-28 05:52:37 +09:00
cremno 91c22f32f4 rename mrb_str_buf_append to mrb_str_cat_str
The new name is better and less confusing, because:
  - `mrb_str_append` calls `mrb_str_to_str` and this function doesn't
  - `mrb_str_buf_append` _is_ `mrb_str_cat` for `mrb_value` strings
2014-04-27 22:33:22 +02:00
kyab 10cc4be32d Fix MSVC warnings for numeric.c 2014-04-28 03:07:28 +09:00
Jun Hiroe cdef46e3d9 Add Array#select_bang 2014-04-27 23:34:24 +09:00
take_cheeze e2f6a905bc Implement Struct#to_a and Struct#values . 2014-04-27 23:16:32 +09:00
Yukihiro "Matz" Matsumoto bbc237044d NODE_SUPER should preserve stack region for block; ref #2136 2014-04-27 09:22:35 +09:00
Yukihiro "Matz" Matsumoto 26758d89bd NODE_DEF should preserve stack region for lambda; ref #2136 2014-04-27 09:05:23 +09:00
Yukihiro "Matz" Matsumoto 354e6fdce5 Merge pull request #2136 from mirichi/bug-fix2
area of implicit nil is not enough to nregs
2014-04-27 08:24:23 +09:00
Yukihiro "Matz" Matsumoto 7e175d8130 add Hash#fetch; close #2134 2014-04-27 03:03:27 +09:00
Yukihiro "Matz" Matsumoto 855a3f5991 re-apply 3644f1b since we have fixed GC bug 2014-04-27 02:52:04 +09:00
Yukihiro "Matz" Matsumoto 4e790fc1b6 forgot to remove abort() 2014-04-27 02:50:41 +09:00
Yukihiro "Matz" Matsumoto 4bfd25d405 mark may be missed when eval() is called 2014-04-27 02:48:11 +09:00
Yukihiro "Matz" Matsumoto 3d87596a71 Merge pull request #2137 from take-cheeze/module_function_eval
Define eval as module function.
2014-04-27 00:14:32 +09:00
Yukihiro "Matz" Matsumoto 33320e282a Merge pull request #2135 from mirichi/bug-fix
correct to compare MRB_STACK_GROWTH.
2014-04-27 00:06:09 +09:00
Yukihiro "Matz" Matsumoto a5161e76ed Class.constants to take optional argument; close #2133 2014-04-26 23:47:55 +09:00
take_cheeze 649ef30347 Define eval as module function. 2014-04-26 22:44:31 +09:00
mirichi 71395aba52 area of implicit nil is not enough to nregs 2014-04-26 20:20:23 +09:00
mirichi ad60f81032 The correct is to compare the MRB_STACK_GROWTH. 2014-04-26 19:37:53 +09:00
Yukihiro "Matz" Matsumoto 5bf327497f bit more peephole optimization for NODE_LVAR 2014-04-26 17:19:52 +09:00
Yukihiro "Matz" Matsumoto 773097d3a8 Merge branch 'master' of github.com:mruby/mruby 2014-04-26 12:08:11 +09:00
Yukihiro "Matz" Matsumoto e76be4e2ab check length before calling stack_copy(); based on a patch from @mirich; close #2129 2014-04-26 12:07:51 +09:00
Yukihiro "Matz" Matsumoto 55251cb14f Merge pull request #2130 from suzukaze/refactor-numeric.c
Refactor numeric.c
2014-04-26 12:03:38 +09:00
Jun Hiroe 68ce209f7e Refactor fix_xor() 2014-04-26 11:52:45 +09:00
Jun Hiroe 8916381dba Refactor fix_or() 2014-04-26 11:52:45 +09:00
Jun Hiroe c2d46a43b2 Refactor fix_and() 2014-04-26 11:52:45 +09:00
Jun Hiroe 1bf4633ced Refactor flo_finite_p() 2014-04-26 11:52:45 +09:00
Yukihiro "Matz" Matsumoto b1b3ee4547 revert 3644f1b temporary since it caused SEGV only on Travis-CI 2014-04-26 11:06:53 +09:00
Yukihiro "Matz" Matsumoto 0584551eb9 mruby-string-utf8: use mrb_int instead of size_t 2014-04-26 10:43:32 +09:00
Yukihiro "Matz" Matsumoto 5bbbfd8ead Merge pull request #2128 from mirichi/refactoring-comparable
Refactoring Comparable
2014-04-26 09:53:33 +09:00
mirichi 3644f1ba36 Refactoring Comparable 2014-04-26 09:37:37 +09:00
Yukihiro "Matz" Matsumoto 2202e412ea Merge branch 'master' of github.com:mruby/mruby 2014-04-26 01:53:15 +09:00
Yukihiro "Matz" Matsumoto 44ec41a772 should use plain int for index, since i may be printed using %d; close #2127 2014-04-26 01:52:30 +09:00
Yukihiro "Matz" Matsumoto b8e5cb71fe Merge pull request #2125 from suzukaze/add-array-keep_if
Add Array#keep_if
2014-04-26 01:33:04 +09:00
Yukihiro "Matz" Matsumoto f683778389 Merge pull request #2123 from take-cheeze/mrb_int_arg
Use mrb_int in mrbgem rest arguments getting.
2014-04-26 01:32:31 +09:00
Yukihiro "Matz" Matsumoto c236d779cf Merge pull request #2126 from kyab/fix_msvc_warning_error.c
Fix MSVC warnings for error.c
2014-04-26 01:31:51 +09:00
Yukihiro "Matz" Matsumoto 4f1bda2da1 Merge pull request #2124 from take-cheeze/eval_file_line
Support file name and line number argument in eval.
2014-04-26 01:30:41 +09:00
Yukihiro "Matz" Matsumoto c15da653b2 Merge pull request #2118 from ksss/range-bool
RRange excl flag use mrb_bool insteard of int
2014-04-26 01:30:04 +09:00
Yukihiro "Matz" Matsumoto 2a89a66090 Merge pull request #2122 from mirichi/enhance2
Refactoring OP_CALL
2014-04-26 00:52:46 +09:00
Yukihiro "Matz" Matsumoto 5e3cc418f0 Merge pull request #2121 from mirichi/enhance
Refactoring Array#__svalue
2014-04-26 00:50:11 +09:00
kyab 1fdc072032 Fix MSVC warnings for error.c 2014-04-26 00:00:40 +09:00
take_cheeze b5028421b9 Use mrb_int in mrbgem rest argument getting. 2014-04-25 22:02:10 +09:00
take_cheeze d2011ce01a Support file name and line argument in Kernel.eval .
Only a nil binding will be supported.
2014-04-25 21:59:52 +09:00
take_cheeze 215f8fdd64 Fix lineno overwrite in parser_init_cxt.
By reordering parsing string with mrb_parser_parse won't always start with line 1.
2014-04-25 21:56:02 +09:00
mirichi fa1a1e6db8 Refactoring OP_CALL 2014-04-25 21:49:29 +09:00
mirichi d2e4937cea Refactoring Array#__svalue 2014-04-25 21:36:52 +09:00
Jun Hiroe d6414fe112 Add Array#keep_if 2014-04-25 18:57:20 +09:00
Yukihiro "Matz" Matsumoto 49abcd4c02 resolve conflict 2014-04-25 04:43:10 +09:00
Yukihiro "Matz" Matsumoto 48f36d3f0e better integer size assertion suggested by usak 2014-04-25 04:33:08 +09:00
Yukihiro "Matz" Matsumoto 83c1399af0 eliminate plain int except for a few cases like arena_index 2014-04-25 04:01:57 +09:00
Yukihiro "Matz" Matsumoto 8a04dd8493 Merge pull request #2117 from kyab/fix_msvc_warning_backtrace.c
Fix MSVC warning for backtrace.c
2014-04-25 02:33:50 +09:00
Yukihiro "Matz" Matsumoto 320f0711f0 remove -Wsign-compare warnings 2014-04-25 02:33:33 +09:00
Yukihiro "Matz" Matsumoto d95c42eefd Merge pull request #2119 from ksss/range-each
Range#each fixnums are special
2014-04-25 00:05:12 +09:00
Yukihiro "Matz" Matsumoto f882bc8480 Merge pull request #2120 from suzukaze/add-array.delete_if
Add Array#delete_if
2014-04-25 00:02:48 +09:00
Jun Hiroe d4bec4d657 Add Array#delete_if 2014-04-24 23:04:46 +09:00
ksss 209bf256aa Range#each fixnums are special 2014-04-24 13:53:54 +00:00
Yukihiro "Matz" Matsumoto 39c036ab03 Merge pull request #2115 from ksss/ary-fill
Fix Array#fill bug and behavior
2014-04-24 22:28:27 +09:00
ksss aca3a1f3fb range_init argument for exclude_end use mrb_bool 2014-04-24 13:25:59 +00:00
ksss f1d85c2f97 mrb_range_new excl flag use mrb_bool insteard of int 2014-04-24 13:18:57 +00:00
Yukihiro "Matz" Matsumoto fdcea862ee Merge pull request #2116 from take-cheeze/remove_attention
Remove attention about mrbgem dependecy.
2014-04-24 22:17:52 +09:00
kyab 4c8092fe00 Fix MSVC warning for backtrace.c 2014-04-24 22:10:19 +09:00
take_cheeze 1abed6d81c Remove attention about mrbgem dependecy. 2014-04-24 22:07:53 +09:00
ksss 4652c7caa0 Array#fill use kind_of? instead of respond_to? 2014-04-24 21:08:49 +09:00
ksss f961d7abeb Array#fill fix bug when argument use range object 2014-04-24 21:08:49 +09:00
Jun Hiroe c81b9838bb Add Array#bsearch 2014-04-24 21:04:13 +09:00
Yukihiro "Matz" Matsumoto 18c4741883 Merge pull request #2113 from take-cheeze/add_dependency_doc
Update documentation of `MRuby::Gem::Specification#add_dependency`.
2014-04-24 20:45:01 +09:00
take_cheeze e1052e74ff Update documentation of MRuby::Gem::Specification#add_dependency. 2014-04-24 12:32:32 +09:00
Yukihiro "Matz" Matsumoto 0d9c872b9b Merge pull request #2111 from kyab/fix_msvc_warning_gc.c
Fix MSVC warning for gc.c
2014-04-24 02:37:34 +09:00
kyab e248097a17 Fix MSVC warning for gc.c 2014-04-24 01:18:41 +09:00
Yukihiro "Matz" Matsumoto 75128295d9 Merge pull request #2108 from take-cheeze/default_gem_info
Implement default gem info to use when there is no depending gem loaded.
2014-04-23 23:50:23 +09:00
Yukihiro "Matz" Matsumoto d67693d2f1 Merge pull request #2109 from mirichi/enhance
reduce the init area of stack
2014-04-23 21:44:52 +09:00
mirichi 4ab801c045 fixed. 2014-04-23 19:39:14 +09:00
mirichi b27d665d2d Merge remote-tracking branch 'remotes/mruby/master' into enhance 2014-04-23 19:03:35 +09:00
take_cheeze 63bf375b0e Implement default gem info to use when there is no depending gem is defined. 2014-04-23 15:09:01 +09:00
Yukihiro "Matz" Matsumoto f2204ee524 Merge pull request #2105 from take-cheeze/issue_2103_test
Add test of $0 value in bin/mruby related to #2103 .
2014-04-23 07:05:48 +09:00
Yukihiro "Matz" Matsumoto 68027317b0 Array#insert: simpler (and faster) implementation; ref #2107 2014-04-23 00:25:50 +09:00
Jun Hiroe a48e0018fd Add Array#insert 2014-04-23 00:22:24 +09:00
mirichi e6c757b5c1 bug fixed 2014-04-22 23:10:40 +09:00
Yukihiro "Matz" Matsumoto 951f027b12 Merge pull request #2106 from mirichi/enhance
OP_SEND refactoring
2014-04-22 22:33:42 +09:00
mirichi 8195224072 reduce the init size of stack 2014-04-22 22:02:03 +09:00
mirichi b523018803 OP_SEND refactoring 2014-04-22 20:04:10 +09:00
take_cheeze 18718e065a Add test of $0 value in bin/mruby related to #2103 . 2014-04-22 19:19:08 +09:00
Yukihiro "Matz" Matsumoto 9a10900a35 Merge pull request #2104 from cremno/remove-mrb_str_buf_cat
remove `mrb_str_buf_cat`
2014-04-22 07:03:56 +09:00
Yukihiro "Matz" Matsumoto e35e2fff3f Merge pull request #2103 from titouanc/global-zero-bytecode
Also set $0 for binary files
2014-04-22 07:03:16 +09:00
cremno bc23a5e9e5 remove mrb_str_buf_cat
It does the same as `mrb_str_cat`.
2014-04-21 21:28:06 +02:00
iTitou 6676bd61a7 Also set $0 for binary files 2014-04-21 16:37:52 +02:00
Yukihiro "Matz" Matsumoto db6e868265 Merge pull request #2101 from take-cheeze/struct_test
Remove `Struct` defined check in test.
2014-04-21 22:45:05 +09:00
Yukihiro "Matz" Matsumoto 56e520616e Merge pull request #2102 from take-cheeze/fiber_doc
Improve mruby-fiber document.
2014-04-21 22:43:52 +09:00
take_cheeze a457fef213 Remove unnecessary require 'fiber' note in Fiber.current document. 2014-04-21 22:14:23 +09:00
take_cheeze 1d6b8ba524 Add document to Fiber#transfer . 2014-04-21 22:13:39 +09:00
take_cheeze 30c672f890 Remove Struct defined check in test. 2014-04-21 21:35:58 +09:00
Yukihiro "Matz" Matsumoto db440b82b0 Merge pull request #2100 from cremno/fix-tests
tests should not depend on `mruby-proc-ext`
2014-04-21 16:40:31 +09:00
cremno 9dd28c96bb tests should not depend on mruby-proc-ext 2014-04-21 08:09:52 +02:00
Yukihiro "Matz" Matsumoto 8694654fd4 Merge pull request #2099 from nobu/optional_arguments_in_rhs
Optional arguments in rhs
2014-04-21 14:58:26 +09:00
Nobuyoshi Nakada ac6747a9c5 fix optional block arguments in rhs
define optional block arguments as argument variables in the rhs
default expressions, as same as mere assignment expressions.

Import ruby/ruby@01740f0c27
2014-04-21 14:55:06 +09:00
Nobuyoshi Nakada 28f6cfe424 adjust indent 2014-04-21 14:53:37 +09:00
Yukihiro "Matz" Matsumoto 6ec04a4e78 Merge pull request #2098 from suzukaze/add-array.reject_bang
Add Array#reject!
2014-04-21 14:49:03 +09:00
Jun Hiroe fcfab84560 Add Array#reject_bang 2014-04-21 13:52:50 +09:00
Tomoyuki Sahara 5aeb99ad49 fix mrb_raisef usage. 2014-04-21 11:14:40 +09:00
Yukihiro "Matz" Matsumoto e7f5cd7d4e Merge pull request #2097 from nobu/optional_arguments_in_rhs
fix optional arguments in rhs
2014-04-21 10:53:10 +09:00
Nobuyoshi Nakada 367118b1b6 fix optional arguments in rhs
define optional arguments as argument variables in the rhs default
expressions, as same as mere assignment expressions.

Import ruby/ruby@01740f0c27
2014-04-21 10:48:00 +09:00
Tomoyuki Sahara 9c00de59ce IO.for_fd can be written in Ruby. 2014-04-21 10:24:59 +09:00
Tomoyuki Sahara c46cb1b5eb more tests. 2014-04-21 10:02:25 +09:00
Tomoyuki Sahara e5f30f83ce IO#flush should raise an exception if it is closed. 2014-04-21 10:01:49 +09:00
Tomoyuki Sahara 99c67749ff remove return statements after mrb_raise(). 2014-04-21 09:06:46 +09:00
Yukihiro "Matz" Matsumoto 4654db4fdc Merge pull request #2096 from nobu/def_in_cmdarg
Def in cmdarg
2014-04-21 08:56:31 +09:00
Yukihiro "Matz" Matsumoto 5f84692367 Merge pull request #2095 from suzukaze/refactor-dump.c
Use boolean macro in is_valid_c_symbol_name()
2014-04-21 08:53:29 +09:00
Yukihiro "Matz" Matsumoto 73c86f59f6 Merge pull request #2094 from suzukaze/add-array.delete_if
Add Array#delete_if
2014-04-21 08:52:53 +09:00
Nobuyoshi Nakada 9eaddfab44 allow method definition in cmdarg
save cmdarg_stack and isolate command argument state from outer scope
to allow method definition in cmdarg

import from ruby/ruby@04bb9d6b75
2014-04-21 07:00:57 +09:00
Nobuyoshi Nakada a3d6290d7b use stack_type instead of raw unsigned int 2014-04-21 06:53:35 +09:00
Jun Hiroe 81308c0bf4 Use boolean macro in is_valid_c_symbol_name() 2014-04-21 01:49:27 +09:00
Jun Hiroe 931414305a Add Array#delete_if 2014-04-21 01:40:39 +09:00
Yukihiro "Matz" Matsumoto 791631ad4e Merge pull request #2093 from mirichi/bug_fix
do not reuse deleted entry.
2014-04-21 00:45:05 +09:00
Yukihiro "Matz" Matsumoto 8c177032da Merge pull request #2092 from take-cheeze/test_syntax
Suppress test script syntax warning.
2014-04-21 00:43:43 +09:00
Yukihiro "Matz" Matsumoto 3bce663568 Merge pull request #2091 from take-cheeze/struct_len
Implement Struct#size and Struct#length .
2014-04-21 00:43:17 +09:00
mirichi d3efe18143 do not reuse deleted entry. fixed 2014-04-20 23:10:24 +09:00
take_cheeze 0d2c307ef6 Suppress test script syntax warning. 2014-04-20 22:11:08 +09:00
take_cheeze 3675832b0e Implement Struct#size and Struct#length . 2014-04-20 22:02:48 +09:00
Yukihiro "Matz" Matsumoto a694110193 Merge pull request #2089 from ksss/sym-casecmp
Implement Symbol#casecmp
2014-04-20 21:30:46 +09:00
Yukihiro "Matz" Matsumoto a6d8df6761 Merge pull request #2088 from ksss/string-casecmp
String#casecmp should be call `to_str`
2014-04-20 21:30:16 +09:00
Yukihiro "Matz" Matsumoto bd75406a3e Merge pull request #2087 from ksss/sym-comparable
Symbol class include Comparable module.
2014-04-20 21:29:15 +09:00
Yukihiro "Matz" Matsumoto 1abac345cf Merge pull request #2086 from bovi/checksum_hash
Implement :checksum_hash mrbgem option
2014-04-20 21:26:36 +09:00
Yukihiro "Matz" Matsumoto 21ae09c0a0 Merge pull request #2085 from bovi/deep_clean
Add Rake command 'deep_clean' which cleans everything including the mrbg...
2014-04-20 21:25:20 +09:00
Yukihiro "Matz" Matsumoto 86bd3f080f Merge pull request #2090 from ksss/authors
Can I add me to AUTHORS?
2014-04-20 21:24:36 +09:00
Yukihiro "Matz" Matsumoto 45de5bc401 Merge pull request #2084 from suzukaze/fix-typo
Fix typos in tests for mruby-string-utf8
2014-04-20 21:24:06 +09:00
ksss 8cdd2bac6e Add AUTHORS "Yuki Kurihara" 2014-04-20 15:32:44 +09:00
ksss bb52324bd9 Implement Symbol#casecmp 2014-04-20 13:43:59 +09:00
ksss 617fa70211 String#casecmp should be call to_str
when non String object sent
And should be raise TypeError
when can not responsed to `to_str`
2014-04-20 13:25:07 +09:00
ksss 900999b290 Symbol class include Comparable module. 2014-04-20 09:48:33 +09:00
Daniel Bovensiepen 874bec2af5 Implement :checksum_hash mrbgem option.
This allows to use a mgem with a specific checksum hash.
The following modification were necessary to implement this
function:
  - add run_checkout build command to use 'git checkout'
  - skip shallow copy in case checksum_hash is used
  - make 'master' the default branch if branch isn't defined
2014-04-20 05:39:40 +08:00
Daniel Bovensiepen d3195277ff Add Rake command 'deep_clean' which cleans everything including the mrbgems clone directories. 2014-04-20 05:35:47 +08:00
Jun Hiroe cd948b0501 Fix typos in tests for mruby-string-utf8 2014-04-20 02:14:42 +09:00
Yukihiro "Matz" Matsumoto 44cc51fef7 Merge pull request #2083 from take-cheeze/use_bool_macro
Use boolean macro instead of integer literal in `is_debug_info_defined`.
2014-04-20 00:42:42 +09:00
take_cheeze 1ed9394078 Use boolean macro instead of integer literal in is_debug_info_defined. 2014-04-19 23:25:48 +09:00
Yukihiro "Matz" Matsumoto e5368c006a Merge pull request #2081 from nobu/parenthesed_do-block_in_cmdarg
Allow parenthesed do-block in cmdarg
2014-04-19 21:33:29 +09:00
Nobuyoshi Nakada b16697982e Allow parenthesed do-block in cmdarg
Flush cmdarg flags inside left-paren in a command argument, to allow
parenthesed `do-block` as an argument without arguments parentheses.
`CMDARG_PUSH(0)` for tLPAREN_ARG is before `CMDARG_PUSH(1)` in
`command_args` due to look-ahead.
2014-04-19 18:46:07 +09:00
Yukihiro "Matz" Matsumoto 426f80b191 Merge pull request #2080 from crimsonwoods/replace_disordered_callinfo_variables
Sort out the variables which belongs to 'mrb_callinfo'
2014-04-19 14:38:14 +09:00
crimsonwoods 29e90d0287 Sort out the variables which belongs to 'mrb_callinfo' to improve 'cipush' performance. 2014-04-18 22:04:21 -07:00
Yukihiro "Matz" Matsumoto e462475752 Merge pull request #2079 from suzukaze/add-test-of-utf8-string.rindex
Add tests for String#rindex of mruby-string-utf8.
2014-04-19 12:02:52 +09:00
Yukihiro "Matz" Matsumoto edb8cca478 Merge pull request #2077 from take-cheeze/rstruct_macro
Use RARRAY_* macro instead of accessing RArray field.
2014-04-19 12:01:18 +09:00
Jun Hiroe 29bbeb1512 Add tests for utf8-string#rindex 2014-04-19 01:12:58 +09:00
Yukihiro "Matz" Matsumoto 751e74a8fb Merge pull request #2078 from suzukaze/add-block-with-array.uniq_bang
Add block argument with Array#uniq! and Array#uniq
2014-04-19 00:01:08 +09:00
Yukihiro "Matz" Matsumoto 73c0ea5ffa mruby-string-utf8: update UTF-8 tests; ref #2076 2014-04-18 23:46:18 +09:00
Yukihiro "Matz" Matsumoto b2422cf021 mruby-string-utf8: str_subseq takes UTF-8 index, not byte index; ref #2076 2014-04-18 23:45:26 +09:00
take_cheeze bac70ad81d Use RARRAY_* macro instead of accessing RArray field. 2014-04-18 23:19:25 +09:00
Jun Hiroe cb5e6edb7f Add a block argument with Array#uniq 2014-04-18 23:13:10 +09:00
Jun Hiroe 80646a7890 Add a block argument with Array#uniq_bang 2014-04-18 23:13:02 +09:00
mattn 280f9dfc19 Add one more test 2014-04-18 21:05:03 +09:00
mattn 1d5e100e07 Add test for String#ord, String#split for mruby-string-utf8 2014-04-18 21:00:59 +09:00
Tomoyuki Sahara 7d7a549a4f remove io_open(). 2014-04-18 11:32:38 +09:00
Yukihiro "Matz" Matsumoto 4918e5ec65 Merge pull request #2075 from mattn/utf8-string-ord
Implement String#ord, String#split for mruby-string-utf8
2014-04-18 11:21:17 +09:00
Tomoyuki Sahara 36045ea96f IO#syswrite should raise an error if it's not opened for writing. 2014-04-18 11:20:55 +09:00
mattn d72b8c201d Implement String#ord, String#split for mruby-string-utf8 2014-04-18 02:26:17 +09:00
Yukihiro "Matz" Matsumoto 7c1b3f8a86 mruby-string-utf8: String#reverse! may leak memory when mrb_str_modify() raises exception 2014-04-18 00:56:50 +09:00
Yukihiro "Matz" Matsumoto 270659da5f Merge pull request #2074 from mattn/fix_string_utf8_index
Implement String#index, fixes #2073
2014-04-18 00:50:45 +09:00
mattn db88af83df Cosmetic change 2014-04-17 19:51:45 +09:00
mattn ba5a995c23 Handle utf-8 code in index/rindex 2014-04-17 19:47:01 +09:00
mattn 9d520ae739 Implement String#index, fixes #2073 2014-04-17 18:22:07 +09:00
Yukihiro "Matz" Matsumoto d000c72bc6 Merge pull request #2072 from take-cheeze/mrb_regexp_p
Add mrb_regexp_p.
2014-04-17 17:17:37 +09:00
Tomoyuki Sahara 1c4f46f324 remove standard header files from io.h. 2014-04-17 16:29:27 +09:00
Tomoyuki Sahara a11780f4f1 file.c depends on mruby/ext/io.h now. 2014-04-17 16:18:26 +09:00
Tomoyuki Sahara a3e1e535dc function declarations should be in a header file. 2014-04-17 16:13:18 +09:00
Tomoyuki Sahara 9f5ff9ddec remove unused constants. 2014-04-17 16:12:51 +09:00
Tomoyuki Sahara ba9cb1f757 "struct mrb_io_type" is not used at all. 2014-04-17 16:07:12 +09:00
Tomoyuki Sahara 10be4cbb2c file.c does not depend on mruby/ext/io.h. 2014-04-17 15:56:11 +09:00
Tomoyuki Sahara 87ce12dfe3 io.write("") -> 0 2014-04-17 15:53:51 +09:00
Tomoyuki Sahara 810e37b1c3 return value of syswrite may be less than length of given string. 2014-04-17 15:45:31 +09:00
take_cheeze 699964a86e Use mrb_regexp_p to check regexp. 2014-04-17 14:32:45 +09:00
take_cheeze d4a510f751 Add mrb_regexp_p to check whether mrb_value is Regexp. 2014-04-17 14:32:45 +09:00
Yukihiro "Matz" Matsumoto 1d51d1a0b5 Symbol#to_proc to support block call.
based on a patch from @ksss; close #2071
2014-04-17 13:28:54 +09:00
Yukihiro "Matz" Matsumoto dbe85f81dd raises an ArgumentError when calling #call
based on a patch from @ksss; close #2070
2014-04-17 09:37:40 +09:00
Yukihiro "Matz" Matsumoto af5a32f4e5 Merge pull request #2069 from cremno/static
various functions should have internal linkage
2014-04-17 07:58:05 +09:00
Yukihiro "Matz" Matsumoto f756a8a72f Merge pull request #2068 from cremno/exc_inspect-convert-mesg-to-string
convert exception message to string
2014-04-17 07:54:34 +09:00
Yukihiro "Matz" Matsumoto 26c0f8a772 Merge pull request #2067 from take-cheeze/move_re_h
Move src/re.h to include/mruby/re.h .
2014-04-17 07:53:02 +09:00
cremno 8271b4ba27 various functions should have internal linkage 2014-04-16 21:26:12 +02:00
cremno 36d3909e63 get classname and concatenate ": " only once 2014-04-16 20:48:39 +02:00
cremno b4bb2a700a convert exception message to string
fixes: mruby -e "p ArgumentError.new(1)"
2014-04-16 20:44:07 +02:00
take_cheeze b5824f3649 Use mruby/re.h instead of duplicate definition. 2014-04-16 22:41:22 +09:00
take_cheeze c0eaaf3559 Move src/re.h to include/mruby/re.h . 2014-04-16 22:39:57 +09:00
Yukihiro "Matz" Matsumoto 93c82514dc Merge branch 'master' of github.com:mruby/mruby 2014-04-16 15:22:50 +09:00
Yukihiro "Matz" Matsumoto 3e00684faa resolve conflict 2014-04-16 15:18:52 +09:00
Yukihiro "Matz" Matsumoto cb1659c191 Merge pull request #2066 from suzukaze/refactor-numeric2
Refactor numeric.c
2014-04-16 15:02:42 +09:00
Jun Hiroe cdb49ab608 Refactor fix_to_f in numeric.c 2014-04-16 13:42:40 +09:00
Jun Hiroe 212b3409ae Refactor lshift in numeric.c 2014-04-16 13:42:40 +09:00
Jun Hiroe 0823b23623 Refactor fix_shift_get_width in numeric.c 2014-04-16 13:42:40 +09:00
Yukihiro "Matz" Matsumoto c136d871b9 Merge pull request #2065 from take-cheeze/utf8_string_size_test
Add test for UTF-8 string String#size .
2014-04-15 23:50:34 +09:00
take_cheeze 96f40c9ec4 Add test for UTF-8 string String#size . 2014-04-15 22:39:52 +09:00
Yukihiro "Matz" Matsumoto 1c9ad8a580 fixed typo in opcode.h 2014-04-15 22:24:02 +09:00
Yukihiro "Matz" Matsumoto f301f36ec5 Merge pull request #2064 from mirichi/opt_jmp
OP_EQ系が速くなった
2014-04-15 20:08:15 +09:00
Yukihiro "Matz" Matsumoto 216b051756 Merge pull request #2063 from bovi/update_language_doc
Improve Language Documentation
2014-04-15 19:54:09 +09:00
mirichi b796c503fa OP_EQ系が速くなった 2014-04-15 19:30:42 +09:00
Daniel Bovensiepen c53846a22a merge @mattn's win-compatibility 2014-04-15 18:28:16 +08:00
Daniel Bovensiepen a182a0d38c Improve generator to output status 2014-04-15 13:17:23 +08:00
Daniel Bovensiepen 88951ddb7e Update language documentation without line number to reduce update interval in the future 2014-04-15 13:07:00 +08:00
Daniel Bovensiepen 1017868e78 Implement switch for line numbers 2014-04-15 13:05:40 +08:00
Daniel Bovensiepen d83c66c854 Update Language Documentation 2014-04-15 12:48:12 +08:00
Yukihiro "Matz" Matsumoto 5138f62d6b resolve conflict 2014-04-15 10:55:46 +09:00
Takeshi Watanabe 6e0c48d758 Fix and add test to Proc#inspect . 2014-04-14 22:01:52 +09:00
Yukihiro "Matz" Matsumoto 4685a43dd6 should always initialize header flags for pooled strings 2014-04-14 16:55:28 +09:00
Yukihiro "Matz" Matsumoto 10db9e62b6 fixed wrong use of pointer reference found by @tsahara; ref #2059 2014-04-14 16:48:23 +09:00
Yukihiro "Matz" Matsumoto 2a76532fe8 Merge pull request #2060 from cremno/exc_inspect-dup-file
exc_inspect: dup file and check mesg only once
2014-04-14 12:22:18 +09:00
Yukihiro "Matz" Matsumoto 636addd645 Merge pull request #2059 from cremno/reduce-rstring_ptr-usage
reduce RSTRING_PTR usage
2014-04-14 12:20:18 +09:00
cremno 7a8ed0fa3a exc_inspect: dup file and check mesg only once 2014-04-14 03:52:17 +02:00
cremno 649081661a reduce RSTRING_PTR usage 2014-04-14 00:58:34 +02:00
Yukihiro "Matz" Matsumoto 65678f11b4 Merge pull request #2058 from cremno/mruby-time-more-portable
mruby-time: two small changes for portability
2014-04-14 07:10:39 +09:00
cremno 06a946abb2 mruby-time: fix check of mktime's return value
>If the calendar time cannot be represented, the function returns the
value (time_t)(-1).
http://www.iso-9899.info/n1256.html#7.23.2.3p3
2014-04-13 16:43:13 +02:00
cremno 8b5cbe2f33 mruby-time: remove unnecessary tzset call
The gem doesn't use the global variables and:
>Local timezone information is used as though localtime() calls tzset().
http://pubs.opengroup.org/onlinepubs/9699919799/functions/localtime.html
2014-04-13 16:39:16 +02:00
Yukihiro "Matz" Matsumoto 382aed8a12 disable fragile bintest on travis-ci 2014-04-13 18:46:45 +09:00
Yukihiro "Matz" Matsumoto ac5091e211 use quadratic probing in khash.h 2014-04-13 18:30:22 +09:00
Yukihiro "Matz" Matsumoto 8d95e5a0de use kh_put2 in mrb_hash_set for performance improvement 2014-04-13 18:26:13 +09:00
Yukihiro "Matz" Matsumoto 6d6ae570cb add kh_push2() to check if entry is added 2014-04-13 18:20:37 +09:00
Yukihiro "Matz" Matsumoto 6c02935eb1 Merge branch 'master' of github.com:mruby/mruby 2014-04-13 17:34:27 +09:00
Yukihiro "Matz" Matsumoto b631e0f8d5 avoid function style parens after "return"; ref #2055 2014-04-13 17:34:06 +09:00
Yukihiro "Matz" Matsumoto 14514ab40d Merge branch 'Refactor-numeric.c' of https://github.com/suzukaze/mruby into suzukaze-Refactor-numeric.c 2014-04-13 17:31:42 +09:00
Yukihiro "Matz" Matsumoto 6708e4dd8b Merge pull request #2056 from suzukaze/fix-indent
Fix indent in bit_coerce
2014-04-13 17:24:28 +09:00
Jun Hiroe 70e93da724 Fix indent in bit_coerce 2014-04-13 03:11:58 +09:00
Jun Hiroe 996343caa2 Refactor fix_rshift 2014-04-13 00:41:22 +09:00
Jun Hiroe f8e1633c0d Refactor fix_lshift 2014-04-13 00:37:55 +09:00
Yukihiro "Matz" Matsumoto 12ce2054b0 disable bintest for now 2014-04-13 00:35:33 +09:00
Yukihiro "Matz" Matsumoto 45eccd1333 khash.h: use first found k_del 2014-04-13 00:32:23 +09:00
Yukihiro "Matz" Matsumoto a18f22e1b4 Merge pull request #2053 from suzukaze/refactor-fix_rev
Refactor fix_rev
2014-04-12 23:57:41 +09:00
Jun Hiroe 8496f84b9b Refactor fix_rev 2014-04-12 23:45:22 +09:00
Yukihiro "Matz" Matsumoto b046ded67d remove mirb regression test that fails on travis-ci only 2014-04-12 23:10:58 +09:00
Yukihiro "Matz" Matsumoto 17f4835141 Restore arena index since large struct may create many Proc objects; a patch from @take-cheeze; ref #2052 2014-04-12 21:45:01 +09:00
Yukihiro "Matz" Matsumoto 9e3fe6c53d Add test cases to 'large struct' test; a patch from @take-cheeze; ref #2052 2014-04-12 21:42:26 +09:00
Yukihiro "Matz" Matsumoto bff93ba93f simplify Fixnum#== 2014-04-12 16:38:28 +09:00
Yukihiro "Matz" Matsumoto 1ef77ab3ff simplify Numeric#eql? 2014-04-12 16:30:45 +09:00
Yukihiro "Matz" Matsumoto 8321ad3f56 remove num_equal() that potentially cause infinite loop 2014-04-12 16:08:47 +09:00
Yukihiro "Matz" Matsumoto f5e14afacc Merge pull request #2051 from suzukaze/add-array_bang_test
Add Array#uniq! test
2014-04-12 16:03:50 +09:00
Jun Hiroe c471cea4d7 Add Array#uniq_bang test 2014-04-12 15:57:14 +09:00
Yukihiro "Matz" Matsumoto 141593ee09 Merge pull request #2050 from suzukaze/refactor-array-test
Refactor array test to use assert_xxx method
2014-04-12 15:27:53 +09:00
Jun Hiroe 957a0d0439 Refactor array test to use assert_xxx method 2014-04-12 15:18:07 +09:00
Yukihiro "Matz" Matsumoto 63eddaa696 Merge branch 'master' of github.com:mruby/mruby 2014-04-12 14:28:52 +09:00
Yukihiro "Matz" Matsumoto 18ee842bea replace memcpy() with a magic number by two assignments as suggested by @cremno; close #2048 2014-04-12 14:28:43 +09:00
Yukihiro "Matz" Matsumoto fcd6e4a7a4 Merge pull request #2049 from ksss/str-dup
mrb_str_dup return shared string instead of new string
2014-04-12 14:09:35 +09:00
ksss d305a9dad7 mrb_str_dup use sheard string instead of new string 2014-04-12 04:44:56 +00:00
ksss e08998be8f Delegate irep string free to mrb_gc_free_str 2014-04-12 04:44:56 +00:00
Yukihiro "Matz" Matsumoto 3308177c4d retrieve values in Hash#each to handle modified keys 2014-04-12 10:42:02 +09:00
Yukihiro "Matz" Matsumoto 077c87bad6 Merge pull request #2047 from suzukaze/add-array-rotate_bang
Add Array#rotate!
2014-04-12 02:24:37 +09:00
Jun Hiroe 0898f40ccc Add Array#rotate_bang 2014-04-12 01:19:44 +09:00
Yukihiro "Matz" Matsumoto fe55b9dd1c Merge pull request #2045 from suzukaze/add-array.rotate
Array#rotate
2014-04-11 23:45:52 +09:00
Yukihiro "Matz" Matsumoto 92156b4619 Merge pull request #2044 from take-cheeze/const_argv
Qualify argv argument of API `const`.
2014-04-11 23:45:15 +09:00
Yukihiro "Matz" Matsumoto f53b2601a0 Merge pull request #2043 from ksss/khash-fix
Fix bug kh_put after kh_del report by @mirichi
2014-04-11 23:44:44 +09:00
Jun Hiroe 7ed47c1223 Array#rotate 2014-04-11 23:42:40 +09:00
ksss 91f68f77a8 kh_put return value should be found index 2014-04-11 21:13:43 +09:00
Takeshi Watanabe 824d3450c5 Qualify argv argument of API const. 2014-04-11 20:38:23 +09:00
ksss b6cfe0e001 Fix bug kh_put after kh_del report by @mirichi 2014-04-11 19:32:32 +09:00
Yukihiro "Matz" Matsumoto b20d711c4d Numeric#round takes optinal argument; close #2042 2014-04-11 14:22:48 +09:00
Tomoyuki Sahara d5cf1de1ae Merge pull request #16 from schmurfy/solaris
solaris does not have flock
2014-04-11 06:53:34 +09:00
Tomoyuki Sahara 1d987d2fcd Merge pull request #9 from schmurfy/solaris
OpenSolaris/Illumos defines a "sun" constant...
2014-04-11 05:50:18 +09:00
Julien Ammous 9850e6a9d0 OpenSolaris/Illumos defines a "sun" constant... 2014-04-10 19:32:05 +02:00
Julien Ammous cd168c6f32 solaris does not have flock 2014-04-10 19:26:55 +02:00
Yukihiro "Matz" Matsumoto 0887fd1586 Merge pull request #2040 from take-cheeze/yield_const_argv
Qualify mrb_yield_*'s argv `const`.
2014-04-11 01:24:11 +09:00
take_cheeze 9f24cd6d79 Qualify mrb_yield_*'s argv const. 2014-04-10 17:34:38 +09:00
Yukihiro "Matz" Matsumoto 847b7c5e19 Merge pull request #2038 from ksss/khash-refactoring
Refactoring for kh_put
2014-04-10 16:57:20 +09:00
ksss 93904fee21 Refactoring for kh_put 2014-04-10 08:48:34 +09:00
Yukihiro "Matz" Matsumoto 93491caec9 revert b45e99 since a bug in khash.h was fixed 2014-04-10 00:57:21 +09:00
Yukihiro "Matz" Matsumoto aecdafb9ce kh_put in khash.h should work when direct bucket is deleted one 2014-04-10 00:53:32 +09:00
Yukihiro "Matz" Matsumoto 8389066272 Merge pull request #2036 from ksss/assert-kh_del
add assert before write khash del flags
2014-04-10 00:16:32 +09:00
Yukihiro "Matz" Matsumoto 020116fa6b revert 40eaf705 for performance reason; ref #2022 2014-04-10 00:14:57 +09:00
ksss cf5aabeba1 add assert before write khash del flags 2014-04-09 23:11:37 +09:00
Yukihiro "Matz" Matsumoto 90e1a4fb56 Merge pull request #2034 from mattn/fix_hash_usage
Fix invalid hash type
2014-04-09 21:52:24 +09:00
mattn 948ddace20 Fix invalid hash type 2014-04-09 21:48:13 +09:00
Yukihiro "Matz" Matsumoto b45e99b0d5 call kh_get before kh_put to avoid potential key lost; reported by @mirichi 2014-04-09 21:38:29 +09:00
Yukihiro "Matz" Matsumoto ef9daf7ef3 fixed typos in operand descriptions 2014-04-09 21:37:28 +09:00
Yukihiro "Matz" Matsumoto b531ae93bf Merge pull request #2033 from take-cheeze/mrb_tt_has_basic_p
Add MRB_TT_HAS_BASIC_P macro.
2014-04-09 14:35:04 +09:00
take_cheeze 90d74b99ff Add MRB_TT_HAS_BASIC_P macro to check whether a typetag has MRB_OBJECT_HEADER. 2014-04-09 14:26:26 +09:00
Yukihiro "Matz" Matsumoto c2bc09be3d Merge pull request #2032 from take-cheeze/enable_bintest
Make bintest enabling like other `enable_xxx` methods.
2014-04-09 14:07:56 +09:00
take_cheeze 604134e57d Make bintest enabling like other enable_xxx methods. 2014-04-09 13:59:39 +09:00
Yukihiro "Matz" Matsumoto 63cf7073de improve hash function based on #2027; close #2027 2014-04-09 11:49:26 +09:00
Yukihiro "Matz" Matsumoto d95d55089d Merge branch 'master' of github.com:mruby/mruby 2014-04-09 11:35:27 +09:00
Yukihiro "Matz" Matsumoto 6abb9de7e0 mention 1.9 compatibility in README.md; close #2031 2014-04-09 11:35:12 +09:00
Yukihiro "Matz" Matsumoto 7f3b8ddb53 Merge pull request #2029 from take-cheeze/mrb_bug_fix
Fix wrong `mrb_bug` use found with mruby-clang-plugin.
2014-04-09 10:32:18 +09:00
Yukihiro "Matz" Matsumoto ec0f97ddfd Merge pull request #2030 from kyab/fix-build_config-arduinodue
Fix build_config.rb for ArduinoDue
2014-04-09 10:31:50 +09:00
kyab c4214d3ace Fix build_config.rb for ArduinoDue 2014-04-08 23:50:25 +09:00
take_cheeze 70f6aa0496 Fix wrong mrb_bug use found with mruby-clang-plugin. 2014-04-08 23:46:18 +09:00
Yukihiro "Matz" Matsumoto c11157eb40 Merge pull request #2026 from take-cheeze/disable_cxx_exception
Add MRuby::Build#disable_cxx_exception to force C++ ABI disable.
2014-04-08 22:56:16 +09:00
take_cheeze 702cadae4c Add documentation of MRuby::Build#disable_cxx_exception . 2014-04-08 20:30:19 +09:00
take_cheeze 758cdd5b33 Add MRuby::Build#disable_cxx_exception to force C++ ABI disable. 2014-04-08 20:16:18 +09:00
Yukihiro "Matz" Matsumoto b26ca1b55b Merge pull request #2025 from take-cheeze/cxx_abi_fix
Fix C++ files detection for automatic C++ ABI enabling.
2014-04-07 17:53:40 +09:00
take_cheeze 66e0df34e0 Fix C++ files detection for automatic C++ ABI enabling. 2014-04-07 17:38:30 +09:00
Tomoyuki Sahara 28e00d82fb suppress compiler warnings. 2014-04-07 13:15:54 +09:00
Yukihiro "Matz" Matsumoto c5c87424a8 Merge branch 'master' of github.com:mruby/mruby 2014-04-07 02:03:43 +09:00
Yukihiro "Matz" Matsumoto 4e2ae3e376 Hash#replace should copy default from original even when the default value of the original is not set 2014-04-07 02:02:53 +09:00
Yukihiro "Matz" Matsumoto 0d9cc9ccc6 Merge pull request #2023 from ksss/khash-readable
Use kh_end instead to n_buckets
2014-04-06 23:19:40 +09:00
Yukihiro "Matz" Matsumoto e54d775ccc Merge pull request #2022 from ksss/khash-delete-khash_mask
Delete khash_mask macro
2014-04-06 22:55:57 +09:00
ksss f946465fe4 Use kh_end instead to n_buckets 2014-04-06 13:45:32 +00:00
ksss 40eaf7058c Delete khash_mask macro.
And fix expression to more simple and readable.
2014-04-06 13:26:10 +00:00
Yukihiro "Matz" Matsumoto 950fe963ac should have passed args to to_enum 2014-04-06 20:31:37 +09:00
Yukihiro "Matz" Matsumoto 8808c9a31a wrap args by parens 2014-04-06 20:29:54 +09:00
Yukihiro "Matz" Matsumoto d016059b07 Merge pull request #2017 from suzukaze/fix_enumerator.inspect
Add args in Enumerator#inspect
2014-04-06 20:27:07 +09:00
Yukihiro "Matz" Matsumoto eab754d859 Merge pull request #2021 from take-cheeze/count_objects_total
Always increment `total` field of `os_count_struct` in callback.
2014-04-06 20:16:15 +09:00
Yukihiro "Matz" Matsumoto 9002fb7946 Merge pull request #2018 from akuroda/pr_false_test
add tests for FalseClass
2014-04-06 20:15:15 +09:00
Yukihiro "Matz" Matsumoto 4875f9b461 Merge pull request #2019 from monaka/pr-add-macro-for-mrbgem-version
Pass gem's version information to compilers.
2014-04-06 20:13:25 +09:00
Yukihiro "Matz" Matsumoto ce1544783d Merge pull request #2020 from iij/pr-remove-unicode-escape-tests
remove tests for unicode chars in regular expression literals.
2014-04-06 20:12:35 +09:00
take_cheeze c4f14755a7 Always increment total field of os_count_struct in callback.
Check sum of `ObjectSpace.count_objects` values is twice of total objects count.
(Which is CRuby's behavior.)
2014-04-06 18:13:29 +09:00
Tomoyuki Sahara 8df73d250b remove tests for unicode chars in regular expression literals.
mruby does not parse escape characters in a regular expression
literal (ref #2007).  It is parsed by the external mrbgem that
provides Regexp class, if any.  These tests should not be in
mruby core but in the mrbgem.
2014-04-06 17:13:29 +09:00
Masaki Muranaka a54176d4a7 Pass gem's version information to compilers. 2014-04-06 11:58:57 +09:00
Akira Kuroda 0eee513a47 add tests for FalseClass
reorder and add tests for 15.2.6.1
2014-04-06 11:48:38 +09:00
Jun Hiroe 1368ae647b Add args in Enumerator#inspect 2014-04-06 02:45:04 +09:00
Yukihiro "Matz" Matsumoto 63dc51c2f9 Merge pull request #2015 from kyab/detect_vc2010_build_config
Add detection of VC++2010 in build_config.rb
2014-04-06 00:19:43 +09:00
kyab a2bd5fdbf4 Add detection of VC++2010 in build_config.rb 2014-04-05 19:41:36 +09:00
Yukihiro "Matz" Matsumoto 237feb7d39 Merge pull request #2014 from kyab/fix_msvc_build_test
Fix 'make test' fail to build on Windows(MSVC)
2014-04-05 19:32:45 +09:00
kyab 0ad9b900a5 Fix 'make test' fail to build on Windows(MSVC) 2014-04-05 19:28:48 +09:00
Yukihiro "Matz" Matsumoto 4f3f22ec62 Merge pull request #2013 from take-cheeze/objectspace
Fix ObjectSpace.count_objects document.
2014-04-05 19:05:17 +09:00
take_cheeze 0d27f18fe7 Fix ObjectSpace.count_objects document. 2014-04-05 14:48:44 +09:00
Tomoyuki Sahara a6ab2c54f3 Merge pull request #15 from monami-ya-mrb/pr-add-error-check-in-test
Don't ignore the return value of symlink().
2014-04-05 11:55:51 +09:00
Masaki Muranaka 706ef1337a Don't ignore the return value of symlink(). 2014-04-05 10:44:47 +09:00
Yukihiro "Matz" Matsumoto f39a5c1d2a Merge pull request #2008 from rkh/patch-1
Update mruby-head installed on Travis CI
2014-04-04 23:43:31 +09:00
Konstantin Haase 642e4cc985 Update mruby-head installed on Travis CI
This way other projects can test against it.
2014-04-04 23:41:16 +09:00
Yukihiro "Matz" Matsumoto 9f6d7d0a42 Merge pull request #2006 from take-cheeze/tsort_dep
Refactor MRuby::Gem::List#check.
2014-04-04 13:52:12 +09:00
take_cheeze 69cc80abbc Refactor MRuby::Gem::List#check.
* Create mrbgem table before dependencies check.
* Topoligical sort gem list.
* Check circular mrbgem dependency.
2014-04-04 13:17:27 +09:00
Yukihiro "Matz" Matsumoto 5f2817b36c backslash escapes in regexp should be addressed by Regexp processor; close #2005 2014-04-04 13:12:58 +09:00
Yukihiro "Matz" Matsumoto 59cd24d41f Hash#replace should copy default as well; close #2004 2014-04-04 12:14:23 +09:00
Yukihiro "Matz" Matsumoto 9f6d69ee56 simplify string equality check 2014-04-04 12:06:13 +09:00
Akira Yumiyama 572b404935 Update .travis.yml 2014-04-04 11:32:42 +09:00
Akira Yumiyama 2bf49c9232 Update .travis.yml 2014-04-04 11:31:45 +09:00
Akira Yumiyama 083cd9ca8c Update .travis.yml 2014-04-04 11:31:33 +09:00
Akira Yumiyama 355723ebca Create .travis.yml 2014-04-04 11:27:56 +09:00
Akira Yumiyama 80e01e3659 Create .travis.yml 2014-04-04 11:27:14 +09:00
Akira Yumiyama 1094bbfff8 Create .travis.yml 2014-04-04 11:25:04 +09:00
Yukihiro "Matz" Matsumoto 8cfd5f17da merge test code from #2003 2014-04-04 11:06:11 +09:00
Yukihiro "Matz" Matsumoto b9a4d64064 implement Hash#initialize in C 2014-04-04 11:03:26 +09:00
Yukihiro "Matz" Matsumoto 786ed10d59 call to_hash before replacing hash 2014-04-04 10:55:48 +09:00
Yukihiro "Matz" Matsumoto b8ab6af39d protect NoMethodError from calling to_hash in ==/eql?; close #2002 2014-04-04 10:54:46 +09:00
Yukihiro "Matz" Matsumoto 28ab106292 Hash#replace to preserve order; close #2001 2014-04-04 10:50:42 +09:00
Yukihiro "Matz" Matsumoto 7a9630a5bb add mruby-enum-lazy mrbgem for Enumerable::Lazy 2014-04-04 10:33:17 +09:00
Yukihiro "Matz" Matsumoto 4e5ec1993a Merge pull request #2000 from kyab/add-help-for-mruby-config
add --help option to mruby-config
2014-04-04 01:49:29 +09:00
Yukihiro "Matz" Matsumoto 2d61698799 should not access proc->body.irep if proc is PROC_CFUNC; close #1999 2014-04-04 01:47:47 +09:00
kyab 97ecf30fb8 add --help option to mruby-config 2014-04-04 01:01:15 +09:00
Yukihiro "Matz" Matsumoto fc2b37f0ee space adjustment in khash.h 2014-04-03 20:35:27 +09:00
Yukihiro "Matz" Matsumoto fdf87b7a3f Merge branch 'master' of github.com:mruby/mruby 2014-04-03 20:33:21 +09:00
Yukihiro "Matz" Matsumoto 6b6f893773 Merge pull request #1998 from ksss/khash-delete-upper_bound
delete khash member upper_bound
2014-04-03 20:33:07 +09:00
ksss 169cf75b1e delete khash member upper_bound 2014-04-03 11:26:37 +00:00
Yukihiro "Matz" Matsumoto 19c3c957fc add assertion before casting 2014-04-03 20:23:39 +09:00
Yukihiro "Matz" Matsumoto 653ddd6d3e downto, upto, step to return Enumerator 2014-04-03 20:19:54 +09:00
Yukihiro "Matz" Matsumoto 697684654c Merge pull request #1997 from kyab/fix-make_test-fail-without-gems
Fix build fail for 'make test' with no mrbgems
2014-04-03 19:43:01 +09:00
kyab ad6fa200e2 Fix build fail for 'make test' with no mrbgems 2014-04-03 19:39:25 +09:00
Yukihiro "Matz" Matsumoto f67038a11b Merge pull request #1996 from take-cheeze/objectspace
Support :T_FIBER in ObjectSpace.count_objects .
2014-04-03 17:47:22 +09:00
take_cheeze 6d75f89ee5 Support :T_FIBER in ObjectSpace.count_objects . 2014-04-03 17:18:46 +09:00
Yukihiro "Matz" Matsumoto 09d1c42308 Merge pull request #1993 from iij/pr-array-should-not-depend-on-enumerator
test fails when we don't have Enumerator.
2014-04-03 12:29:24 +09:00
Tomoyuki Sahara 23f522c877 test fails when we don't have Enumerator. 2014-04-03 11:47:26 +09:00
Yukihiro "Matz" Matsumoto 83a1e7122b Merge branch 'master' of github.com:mruby/mruby 2014-04-03 10:14:55 +09:00
Yukihiro "Matz" Matsumoto 5be2bfb523 too much peephole optimization; close #1992 2014-04-03 10:14:38 +09:00
Yukihiro "Matz" Matsumoto 91805fb0a5 Merge pull request #1991 from ksss/khash-delete-member
Delete member mask and inc
2014-04-03 00:43:52 +09:00
ksss 84ccc82ef9 Delete khash member mask and inc
because there can be substituted by n_buckets
2014-04-02 15:42:31 +00:00
Yukihiro "Matz" Matsumoto ba4746749f Merge pull request #1990 from ksss/khash-bool-macro
Use bool macro KHASH_DEFINE and KHASH_DECLARE
2014-04-02 22:44:33 +09:00
ksss 8d15ef2e89 Use bool macro KHASH_DEFINE and KHASH_DECLARE 2014-04-02 13:38:43 +00:00
Yukihiro "Matz" Matsumoto de818e9859 Merge pull request #1989 from ksss/khash-size_t
use size_t instead of int
2014-04-02 22:28:21 +09:00
ksss 0f1a984a4f use size_t instead of int 2014-04-02 13:24:50 +00:00
Yukihiro "Matz" Matsumoto 8eaee91892 Merge pull request #1988 from ksss/khash-mask
delete unused indexes __m_* masks
2014-04-02 22:07:43 +09:00
ksss c816558b01 delete unused indexes __m_* masks 2014-04-02 12:44:11 +00:00
Yukihiro "Matz" Matsumoto b4043256d0 implement part of Array#<=> in C 2014-04-02 18:04:09 +09:00
Yukihiro "Matz" Matsumoto 94effc6a37 implement Array comparisons by Ruby 2014-04-02 17:33:25 +09:00
Yukihiro "Matz" Matsumoto 9b45189626 remove some empty lines 2014-04-02 10:42:56 +09:00
Yukihiro "Matz" Matsumoto 911764e8e2 handle CR before LF; close #1781 2014-04-02 03:22:06 +09:00
Yukihiro "Matz" Matsumoto 3b339ed47f simpler escape handling in ?c strings 2014-04-02 02:21:57 +09:00
Yukihiro "Matz" Matsumoto 5bcaa749fc fix else indentation style 2014-04-02 02:16:09 +09:00
Yukihiro "Matz" Matsumoto 164dcd8b33 Hash#keys to update memory region directly 2014-04-01 15:19:53 +09:00
Yukihiro "Matz" Matsumoto 312e11da39 should adjust hash value order at deletion 2014-04-01 15:19:11 +09:00
Yukihiro "Matz" Matsumoto 1690fc4c99 implement Hash#== and eql? in Ruby 2014-04-01 14:56:23 +09:00
Yukihiro "Matz" Matsumoto 8b141b07b6 function expansion in hash.c 2014-04-01 14:37:10 +09:00
Yukihiro "Matz" Matsumoto d9feed6703 move Array#inspect implementation to mrblib/array.rb 2014-04-01 14:31:39 +09:00
Yukihiro "Matz" Matsumoto cf58d0d3e9 move Hash#inspect implementation to mrblib/hash.rb 2014-04-01 14:21:40 +09:00
Yukihiro "Matz" Matsumoto f05069fd1a Hash to preserve order as Ruby1.9 does 2014-04-01 14:18:21 +09:00
Yukihiro "Matz" Matsumoto 00f3484ff7 Merge pull request #1986 from take-cheeze/proc_macro
REnv macros.
2014-04-01 11:24:32 +09:00
take_cheeze 755ded2ef0 Use MRB_ENV_STACK_SHARED_P to check cioff field of REnv. 2014-04-01 01:53:28 +09:00
take_cheeze b38eb72d82 Add macro MRB_ENV_UNSHARE_STACK instead of assigning -1 directly. 2014-04-01 01:35:40 +09:00
take_cheeze 80534b6d14 Use MRB_ENV_STACK_LEN instead of accessing flags directly to get REnv's stack length. 2014-04-01 01:13:39 +09:00
Yukihiro "Matz" Matsumoto d7c29322b8 singleton class needs to set __outer__; fixed #1983 2014-03-31 14:12:47 +09:00
Yukihiro "Matz" Matsumoto 4c2969910f Hash function to avoid funcalls if possible 2014-03-31 13:44:35 +09:00
Yukihiro "Matz" Matsumoto 2c3530ff10 Merge pull request #1985 from take-cheeze/cfunc_with_env
Add API to define cfunc Proc with userdata.
2014-03-31 11:45:45 +09:00
Yukihiro "Matz" Matsumoto d1e755df0f Merge pull request #1984 from mattn/test_hex_oct_underscore
More tests for String#hex, String#oct as against 9434506035
2014-03-31 10:57:16 +09:00
take_cheeze bf6b1dfe21 Add API to define cfunc Proc with userdata.
The APIs are defined in mruby-proc-ext so include it before using this API.
See mruby-proc-ext's test code for usage.
This should resolve #1794.
2014-03-31 10:01:17 +09:00
mattn ea68fe2f15 More tests for String#hex, String#oct as against 9434506035 2014-03-31 09:47:21 +09:00
Yukihiro "Matz" Matsumoto 3eb3c99a6a Merge pull request #1982 from ksss/err-msg
Show error class name when raise Error
2014-03-31 09:32:07 +09:00
ksss 15eabcdbc4 Show error class name when raise Error 2014-03-31 08:14:14 +09:00
Yukihiro "Matz" Matsumoto a85fdbdba4 according to JIS/ISO, Array is not Comparable 2014-03-31 00:50:16 +09:00
Yukihiro "Matz" Matsumoto 2a1273d3bb Merge pull request #1981 from k-tsj/fix-method-name
Fix method name in Array#reverse_each
2014-03-30 18:44:38 +09:00
Kazuki Tsujimoto 01a798362f Fix method name 2014-03-30 18:32:19 +09:00
Yukihiro "Matz" Matsumoto b1eef40630 Merge pull request #1980 from take-cheeze/minirake_directory
Add -C (--directory) option to minirake.
2014-03-30 18:31:49 +09:00
take_cheeze d54c250839 Add -C (--directory) option to minirake. 2014-03-30 09:23:14 +09:00
Yukihiro "Matz" Matsumoto ebb29f0450 Merge branch 'master' of github.com:mruby/mruby 2014-03-30 08:29:20 +09:00
Yukihiro "Matz" Matsumoto 2277c374db revert #1974; ref #1979 2014-03-30 08:29:09 +09:00
Yukihiro "Matz" Matsumoto 8cdac8221d Merge pull request #1978 from suzukaze/add-array.fill
Add Array#fill
2014-03-29 20:59:08 +09:00
Jun Hiroe aa4a18e81e Add Array#fill 2014-03-29 20:22:07 +09:00
Yukihiro "Matz" Matsumoto a88403cc85 Merge pull request #1975 from take-cheeze/driver_mrb_intern_lit
Use mrb_intern_lit instead of mrb_intern in test driver.
2014-03-29 13:18:13 +09:00
Yukihiro "Matz" Matsumoto ea5088215f Merge pull request #1974 from ksss/enumerator-duck
Enumerator#initialize support duck-type
2014-03-29 13:17:37 +09:00
take_cheeze 98e49ebd7c Use mrb_intern_lit instead of mrb_intern in test driver. 2014-03-29 11:08:40 +09:00
ksss 5a2014b8f8 Enumerator#initialize support duck-type 2014-03-29 09:24:00 +09:00
Yukihiro "Matz" Matsumoto 938281c17a Merge pull request #1971 from suzukaze/fix-typo
Fix a typo
2014-03-29 00:22:32 +09:00
Yukihiro "Matz" Matsumoto 49d18ca848 Kernel#send should preserve nregs in callinfo; close #1970 2014-03-29 00:21:52 +09:00
Jun Hiroe 110486debe Fix a typo 2014-03-29 00:16:12 +09:00
Yukihiro "Matz" Matsumoto 7d413b7043 Merge branch 'master' of github.com:mruby/mruby 2014-03-28 23:21:42 +09:00
Yukihiro "Matz" Matsumoto e8cb971bbb Merge pull request #1969 from suzukaze/add-array.fetch
Add Array#fetch
2014-03-28 23:21:22 +09:00
Yukihiro "Matz" Matsumoto 97f22c9516 Array#reverse_each should return Enumerator; ref #1968 2014-03-28 23:18:55 +09:00
Yukihiro "Matz" Matsumoto 5625104291 Merge pull request #1968 from suzukaze/add-to_enum-unless-block
Add to_enum unless block
2014-03-28 23:16:19 +09:00
Yukihiro "Matz" Matsumoto 2b77fbe1e0 Merge pull request #1967 from ksss/define_singleton_method
Implement Kernel#define_singleton_method
2014-03-28 22:59:41 +09:00
Jun Hiroe de573e57a0 Add Array#fetch 2014-03-28 20:28:14 +09:00
Jun Hiroe ca1bc5290e Add to_enum unless block 2014-03-28 18:54:25 +09:00
ksss f0dd4cb673 Implement Kernel#define_singleton_method 2014-03-28 18:16:28 +09:00
Yukihiro "Matz" Matsumoto 03fa45760e Merge pull request #1966 from take-cheeze/backquote
Add test for backquote.
2014-03-28 13:14:17 +09:00
take_cheeze 2239350348 Add test for backquote.
* Implement code generation of NODE_DXSTR.
* Fix NOVAL NODE_XSTR.
2014-03-28 13:02:52 +09:00
Yukihiro "Matz" Matsumoto be58f1c9ab add Numeric#/ tests; ref #1965 2014-03-28 11:05:53 +09:00
Yukihiro "Matz" Matsumoto 514cafe6c3 do not use "to_f" to retrieve floats in mrb_get_args(); close #1965 2014-03-28 11:04:15 +09:00
Yukihiro "Matz" Matsumoto b8e434a5e6 initialize ci->target_class in mrb_toplevel_run; ref #1942 close mattn/mruby-require#20 2014-03-27 23:51:08 +09:00
Yukihiro "Matz" Matsumoto f2c086d7d5 Merge pull request #1963 from ksss/implement-__method__
Implement Kernel#__method__
2014-03-27 22:47:31 +09:00
Yukihiro "Matz" Matsumoto 211710d782 Merge pull request #1964 from ksss/object-tap
Implement Object#tap
2014-03-27 22:46:01 +09:00
ksss d3ea800cba Implement Object#tap 2014-03-27 19:36:07 +09:00
ksss 65ace4e027 Implement Kernel#__method__ 2014-03-27 18:25:47 +09:00
Yukihiro "Matz" Matsumoto 458c18cd4e Merge pull request #1962 from cubicdaiya/feature/string_oct
add String#oct
2014-03-27 14:36:42 +09:00
Yukihiro "Matz" Matsumoto b5cb8284ba Enumerable#zip to use enumerator if mruby-enumerator gem is available 2014-03-27 14:35:07 +09:00
Yukihiro "Matz" Matsumoto fc51781402 Enumerable#cycle to return enumerator 2014-03-27 14:34:21 +09:00
Yukihiro "Matz" Matsumoto 8250016136 use __svalue instead of ary2sv 2014-03-27 14:28:49 +09:00
Yukihiro "Matz" Matsumoto 69b4842a03 call to_a at the top of Enumerabl#zip; ref #1961 2014-03-27 14:25:33 +09:00
cubicdaiya 9c06f297ee add String#oct 2014-03-27 14:10:08 +09:00
Jun Hiroe c2ad8098a5 Support multiple values in Enumerable#zip 2014-03-27 14:09:29 +09:00
Jun Hiroe 68695d174c Add Enumerable#zip 2014-03-27 14:09:29 +09:00
Yukihiro "Matz" Matsumoto 70718d5935 an int literal may have multiple underscores inside 2014-03-27 13:33:14 +09:00
Yukihiro "Matz" Matsumoto 9434506035 allow underscores in integer literals; close #1960 2014-03-27 12:33:32 +09:00
Yukihiro "Matz" Matsumoto 5067e7b064 Merge pull request #1959 from mattn/string_hex
Implement String#hex
2014-03-27 12:15:19 +09:00
Yukihiro "Matz" Matsumoto 292abdb609 Merge pull request #1956 from cubicdaiya/issues/suitable_type5
Use size_t instead of int
2014-03-27 11:29:59 +09:00
mattn 0df65751c6 Implement String#hex 2014-03-27 11:28:29 +09:00
Yukihiro "Matz" Matsumoto a4f4db975a Merge pull request #1954 from take-cheeze/objectspace_count_key
Use CRuby compatible key in ObjectSpace.count_objects .
2014-03-27 08:01:42 +09:00
Yukihiro "Matz" Matsumoto ea88ee91a3 Merge pull request #1953 from bovi/conversion-str-int
Adapt TypeError Message for String to (Integer|Float) Conversion
2014-03-27 08:00:00 +09:00
take_cheeze 889a2e0932 Use CRuby compatible key in ObjectSpace.count_objects . 2014-03-27 07:06:44 +09:00
cubicdaiya e157c63c18 use suitable type 2014-03-27 03:18:20 +09:00
Daniel Bovensiepen 7ae495cc9c Adapt for Float and Integer 2014-03-27 01:48:07 +08:00
Daniel Bovensiepen c96339769d Adapt TypeError Message for String to Integer Conversion.
MRI:
"str" * "3"
=> TypeError: no implicit conversion of String into Integer

mruby:
"str" * "3"
=> TypeError: String can't be coerced into int
2014-03-27 01:41:31 +08:00
Akira Yumiyama eda9d1a8fc nonexistent test fixes (for travis-ci) 2014-03-26 22:09:10 +09:00
Yukihiro "Matz" Matsumoto 6e1e728c51 Merge pull request #1952 from kyab/catchup_arduinodue
Catch up to latest Arduino IDE
2014-03-26 22:02:22 +09:00
kyab e87b2d3626 Catch up to latest Arduino IDE 2014-03-26 18:21:25 +09:00
Yukihiro "Matz" Matsumoto 1b422befb1 revert 813ba5 since #1949 fixed 2014-03-26 17:53:22 +09:00
Yukihiro "Matz" Matsumoto 67f1cfaffc Merge branch 'eval_test' of https://github.com/take-cheeze/mruby into take-cheeze-eval_test 2014-03-26 17:50:33 +09:00
Yukihiro "Matz" Matsumoto 28871b9d1f should not over process ensure clauses; close #1949 2014-03-26 17:49:27 +09:00
Tomoyuki Sahara ab9dcc766e IO.close should be IO._sysclose. closes #13. 2014-03-26 17:22:57 +09:00
Yukihiro "Matz" Matsumoto 306b1d3c51 Merge pull request #1948 from monaka/pr-remove-unused-null-check
Remove redundant NULL checks.
2014-03-26 13:32:18 +09:00
take_cheeze 813ba50bfb Don't use ensure to fix crash of mruby-eval test. 2014-03-26 12:59:56 +09:00
take_cheeze f700346b44 Add tests for mruby-eval. 2014-03-26 12:59:17 +09:00
Masaki Muranaka dcff9012e3 Remove redundant NULL checks.
mrb_malloc causes an exception when memory was empty.
2014-03-26 11:21:20 +09:00
Yukihiro "Matz" Matsumoto 79ba1ed137 Merge branch 'master' of github.com:mruby/mruby 2014-03-26 01:09:17 +09:00
Yukihiro "Matz" Matsumoto bfd2a539ed add new function mrb_toplevel_run to prevent running through C function boudaries on exceptions; close #1942 2014-03-26 01:09:09 +09:00
Yukihiro "Matz" Matsumoto 2220fb2a91 Merge pull request #1946 from ksss/str-macro
Fix unnecessary string macro
2014-03-25 23:55:05 +09:00
Yukihiro "Matz" Matsumoto 76098d5e43 Merge pull request #1945 from cubicdaiya/issues/suitable_type3
Use mrb_int instead of int
2014-03-25 23:54:16 +09:00
ksss c82517862a Fix unnecessary string macro 2014-03-25 23:03:47 +09:00
cubicdaiya bf3f45fc70 Use mrb_int instead of int 2014-03-25 22:33:53 +09:00
Yukihiro "Matz" Matsumoto b042b951ce Enumerable#find_index to support multiple values 2014-03-25 19:07:32 +09:00
Yukihiro "Matz" Matsumoto 648059575d Merge pull request #1939 from suzukaze/add-enum.find_index
Enumerable#find_index
2014-03-25 16:27:10 +09:00
Yukihiro "Matz" Matsumoto 86e69334ba Merge pull request #1938 from cubicdaiya/issues/suitable_type2
Use mrb_int instead of int
2014-03-25 16:22:29 +09:00
Jun Hiroe 767ca3f76e Enumerable#find_index 2014-03-25 16:14:19 +09:00
cubicdaiya b7c3a7d181 Use mrb_int instead of int 2014-03-25 15:02:32 +09:00
Yukihiro "Matz" Matsumoto 896dc002ca use to_int to integer duck-type check 2014-03-25 12:29:29 +09:00
Yukihiro "Matz" Matsumoto 1e73181da9 Merge pull request #1937 from cubicdaiya/issues/mrb_int
Use mrb_int instead of int
2014-03-25 11:51:23 +09:00
Yukihiro "Matz" Matsumoto a043eb63ca Merge branch 'master' of github.com:mruby/mruby 2014-03-25 11:50:42 +09:00
Yukihiro "Matz" Matsumoto b4dd3564ef REnv uses obj->c as env link; no super 2014-03-25 11:50:11 +09:00
cubicdaiya 6e648d6382 Use mrb_int instead of int 2014-03-25 11:36:47 +09:00
Yukihiro "Matz" Matsumoto 650651e909 Merge pull request #1936 from ksss/pool-capa
mrb_str_pool add string capa
2014-03-25 11:27:07 +09:00
take_cheeze 8ae3c80fc3 Use mrb_int. 2014-03-25 11:08:54 +09:00
ksss ebf6da7e30 mrb_str_pool add string capa 2014-03-25 08:44:59 +09:00
take_cheeze e5922aa896 Implement ObjectSpace.each_object . 2014-03-25 08:32:50 +09:00
Yukihiro "Matz" Matsumoto 13f0f597c8 Merge pull request #1934 from ksss/safe-name
src/string.c RESIZE_CAPA use safe name variables
2014-03-25 00:01:57 +09:00
Yukihiro "Matz" Matsumoto d7d54b6e69 Fix Enumerable#cycle; ref #1933
* add multi value support
* `each` method may not rewind the sequence so that `cycle` should save elements
2014-03-24 23:58:21 +09:00
Yukihiro "Matz" Matsumoto 915b158e89 Merge pull request #1933 from suzukaze/add-enum.cycle
Add Enumerable#cycle
2014-03-24 23:49:01 +09:00
Yukihiro "Matz" Matsumoto aa5920aaae Enumerable#reverse_each should not rely on mruby-array-ext gem 2014-03-24 23:44:23 +09:00
ksss e6e462c07d src/string.c RESIZE_CAPA use safe name variables
This has a possibility of naming conflicts
2014-03-24 23:05:44 +09:00
Jun Hiroe 381f126f1b Add Enumerable#cycle 2014-03-24 20:24:23 +09:00
Yukihiro "Matz" Matsumoto c326ab877e improve Enumerable#reverse_each to be efficient 2014-03-24 18:39:06 +09:00
Yukihiro "Matz" Matsumoto 23610d5489 Merge pull request #1932 from suzukaze/add-enum.reverse_each
Add Enumerable#reverse_each
2014-03-24 18:31:20 +09:00
Jun Hiroe 70bbe9a894 Add Enumerable#reverse_each 2014-03-24 18:03:37 +09:00
Yukihiro "Matz" Matsumoto 2ce232144b Merge pull request #1930 from chasonr/unicode-escape
Implement \u notation for strings and regexes.
2014-03-24 17:35:32 +09:00
Yukihiro "Matz" Matsumoto 53d6df3fdb fix multiple value handling; ref #1931 2014-03-24 17:31:43 +09:00
Jun Hiroe 7e41e2ed0e Enumerable#each_with_object 2014-03-24 16:26:23 +09:00
chasonr 8162295ba2 Small correction to the test identification. 2014-03-23 22:31:49 -04:00
chasonr 509cbc51eb Implement \u notation for strings and regexes.
This change adds the \u notation for double quoted strings and regular
expressions.  It does not implement the \u notation for character literals.
Both the \uNNNN and \u{NNNN} notations are supported.

\uNNNN is implemented by emitting equivalent UTF-8; that is, "\u4000" is
equivalent to "\xE4\x80\x80".

Unlike CRuby, the \u{NNNN} notation allows only one character per pair of
braces; I see no way to lift this restriction without remodeling the parser.
2014-03-23 21:46:00 -04:00
Yukihiro "Matz" Matsumoto b8d7f1ce7a Merge pull request #1928 from ksss/fix-typo
Hash#__update fix typo
2014-03-24 09:17:42 +09:00
Yukihiro "Matz" Matsumoto 4592862b0d remove unnecessary operator method call; ref #1927 2014-03-24 09:17:09 +09:00
Yukihiro "Matz" Matsumoto e2da53c60d Merge pull request #1927 from take-cheeze/count_crash
Count crashed tests in total tests count.
2014-03-24 09:15:33 +09:00
ksss 2981b4e3d9 Hash#__update fix typo
It's called by create Hash of over 126 keys
2014-03-24 08:43:44 +09:00
take_cheeze db5d78e229 Count crashed tests in total tests count. 2014-03-24 03:22:17 +09:00
Yukihiro "Matz" Matsumoto 75eed54bba move conditional out of loop 2014-03-24 00:24:02 +09:00
Yukihiro "Matz" Matsumoto d05635e252 Enumerable#one? to prune iteration when count > 1; ref #1926 2014-03-24 00:13:37 +09:00
Yukihiro "Matz" Matsumoto 2a771760be Merge pull request #1926 from suzukaze/add-enum.one
Add Enumerable#one?
2014-03-24 00:08:01 +09:00
Jun Hiroe 919ca8f42b Add Enumerable#one? 2014-03-23 23:47:03 +09:00
Yukihiro "Matz" Matsumoto e2bab8c71b Merge pull request #1925 from ksss/hash-reject
Hash#{reject,reject!} support return Enumerator
2014-03-23 22:54:18 +09:00
ksss d9068f0583 Hash#{reject,reject!} fix yield value 2014-03-23 20:13:49 +09:00
ksss d8fc05fcb9 Hash#{reject,reject!} support return Enumerator 2014-03-23 20:11:20 +09:00
ksss b0f10b5c3d mrb_str_pool use embed-string 2014-03-23 08:04:54 +00:00
Yukihiro "Matz" Matsumoto 81e0c30cc5 Merge pull request #1921 from cubicdaiya/issues/not_use_old_macro
Use MRB_ARGS_REST() instead of ARGS_REST()
2014-03-23 16:36:47 +09:00
Yukihiro "Matz" Matsumoto 9beef5fdb0 Merge pull request #1923 from ksss/hash-enumerator-select
Hash#{select,select!} support return Enumerator
2014-03-23 16:36:19 +09:00
Yukihiro "Matz" Matsumoto 85d20127a1 Merge pull request #1922 from suzukaze/add-enum.none
Add Enumerable.none?
2014-03-23 16:35:55 +09:00
ksss d09e4475bf Hash#{select,select!} fix yield value 2014-03-23 13:31:26 +09:00
ksss 5e4626c9ba Hash#{select,select!} support return Enumerator
if non block given
2014-03-23 13:31:26 +09:00
Jun Hiroe d8d47b80c3 Support multiple values in Enumerable#none? 2014-03-23 13:06:18 +09:00
Jun Hiroe 1f709c1ef0 Add Enumerable#none? 2014-03-23 12:58:12 +09:00
cubicdaiya 8f8c174fc2 Use MRB_ARGS_REST() instead of ARGS_REST()
According to include/mruby.h,

 /* compatibility macros; will be removed */
 #define ARGS_REST()         MRB_ARGS_REST()
2014-03-23 12:48:34 +09:00
Yukihiro "Matz" Matsumoto ff6666632f Merge pull request #1920 from suzukaze/add-enum.minmax_by
Add Enumerable#minmax_by
2014-03-23 12:12:32 +09:00
Jun Hiroe 5b31ee9a2a Suppoert multiple values in Enumerable#minmax_by 2014-03-23 11:48:46 +09:00
Jun Hiroe 776a680e89 Enumerable#minmax_by 2014-03-23 11:41:23 +09:00
Yukihiro "Matz" Matsumoto bbee56f284 Merge pull request #1915 from suzukaze/add-enum.minmax
Add Enumerable#minmax
2014-03-23 02:13:06 +09:00
Yukihiro "Matz" Matsumoto 76b2ba886a Merge pull request #1916 from ksss/hash-enumerator
Hash#each_{key,value} support return Enumerator if non block given
2014-03-23 02:11:54 +09:00
ksss 5386cd9b9b Hash#each_{key,value} support return Enumerator
if non block given
2014-03-23 00:22:22 +09:00
Yukihiro "Matz" Matsumoto 539d9cb855 need not to add assertion in STR_SET_LEN() where n is mrb_int 2014-03-22 22:33:09 +09:00
Jun Hiroe 77291f3531 Support multiple values in Enumerable#minmax 2014-03-22 22:06:39 +09:00
Jun Hiroe 5027aaaf4e Add Enumerable#minmax 2014-03-22 21:52:08 +09:00
Yukihiro "Matz" Matsumoto 7182ef6358 Merge pull request #1914 from stomar/struct-emsg
use the same error message
2014-03-22 18:46:10 +09:00
Yukihiro "Matz" Matsumoto 6b43f71b21 Merge pull request #1913 from take-cheeze/fiber_unnecessary_get_args
Remove unnecessary mrb_get_args in fiber_switch.
2014-03-22 18:45:02 +09:00
Marcus Stollsteimer 4f0a163842 use the same error message 2014-03-22 09:51:46 +01:00
take_cheeze cad9648bde remove unnecessary mrb_get_args in fiber_switch 2014-03-22 17:51:43 +09:00
Yukihiro "Matz" Matsumoto 5488da6c44 Merge pull request #1907 from ksss/float-round
Float#round fix bug for infinity and nan cases
2014-03-22 16:58:56 +09:00
Yukihiro "Matz" Matsumoto 064030732a Merge branch 'master' of github.com:mruby/mruby 2014-03-22 16:56:43 +09:00
Yukihiro "Matz" Matsumoto 22d57105eb add Enumerable#min_by as well; ref #1912 2014-03-22 16:55:47 +09:00
Yukihiro "Matz" Matsumoto 04b5e705e0 wrap expr with paren 2014-03-22 16:54:54 +09:00
Yukihiro "Matz" Matsumoto ebb337b132 fix multiple value support of max_by; ref #1912 2014-03-22 16:47:56 +09:00
Yukihiro "Matz" Matsumoto 927bf68769 Merge pull request #1911 from cubicdaiya/issues/use_bool_macro
Use bool-macro instead of magic-number
2014-03-22 16:40:08 +09:00
Yukihiro "Matz" Matsumoto 2a1488756d Merge pull request #1910 from take-cheeze/fiber_error
Use FiberError in vm.c.
2014-03-22 16:39:46 +09:00
Jun Hiroe 5ef1021d88 Support mulitple values in Enumerable#max_by 2014-03-22 14:51:47 +09:00
Jun Hiroe af7db89aa3 Add Enumerable#max_by 2014-03-22 14:51:45 +09:00
cubicdaiya 51947f132b Use bool-macro instead of magic-number 2014-03-22 09:55:48 +09:00
take_cheeze f536492521 use FiberError in vm.c 2014-03-22 03:19:58 +09:00
Yukihiro "Matz" Matsumoto 7c82b9e1bf use mrb_get_args("i") 2014-03-21 23:36:03 +09:00
Yukihiro "Matz" Matsumoto c978fd7b35 should test Enumerable#first; close #1905 2014-03-21 23:33:59 +09:00
Yukihiro "Matz" Matsumoto da34749db0 add const qualifier to pacify warning; ref #1900 2014-03-21 23:19:07 +09:00
Yukihiro "Matz" Matsumoto 73eac77b70 Merge branch 'master' of github.com:mruby/mruby 2014-03-21 23:15:07 +09:00
Yukihiro "Matz" Matsumoto 6a458ab5a5 Merge pull request #1900 from take-cheeze/fiber_transfer
Implement Fiber#transfer.
2014-03-21 23:14:54 +09:00
Yukihiro "Matz" Matsumoto 9bf983ae02 Merge branch 'master' of github.com:mruby/mruby 2014-03-21 23:02:56 +09:00
Yukihiro "Matz" Matsumoto 01162ce812 Merge pull request #1904 from ktaobo/get-arg-int
Prevent accepting String value for mrb_get_args("i")
2014-03-21 23:02:46 +09:00
ksss 8891cea41c Float#round fix bug for infinity and nan cases 2014-03-21 22:24:33 +09:00
take_cheeze e854a0e850 make Fiber#transfer compatible with CRuby 2014-03-21 22:10:47 +09:00
take_cheeze d4d4f1b0d5 implement Fiber#transfer 2014-03-21 22:10:47 +09:00
Yukihiro "Matz" Matsumoto 041b5a9f67 reduce object allocation in __update 2014-03-21 21:53:50 +09:00
Keita Obo 3faa76851d Prevent accepting String value for mrb_get_args("i")
Accepting String value for mrb_get_args("i")
causes unintentional expression.

  * `"str" * "3"` => `"strstrstr"`

This change prevents String->Integer conversion for mrb_get_args("i")
and fixes above problem.

See also:
https://github.com/mruby/mruby/issues/1903
2014-03-21 21:41:04 +09:00
Yukihiro "Matz" Matsumoto 07bd65ae65 flat_map to support multiple values; ref #1902 2014-03-21 13:35:39 +09:00
Yukihiro "Matz" Matsumoto 34a7c9f567 Merge pull request #1902 from suzukaze/add-enum-flat_map
Add Enumerable#{flat_map, collect_concat}
2014-03-21 13:32:54 +09:00
Yukihiro "Matz" Matsumoto 607cf951fc Merge pull request #1901 from ksss/compar-other
Fix behavior of Comparable methods when <=> return nil
2014-03-21 13:32:01 +09:00
Jun Hiroe 44763ebc74 Add Enumerable#{flat_map,collect_concat} 2014-03-21 12:34:21 +09:00
ksss 72fe192259 Fix behavior of Comparable methods
when <=> return nil
2014-03-21 11:58:47 +09:00
Yukihiro "Matz" Matsumoto 2c44f96e78 reduce hash creation by using update method 2014-03-21 09:31:44 +09:00
Yukihiro "Matz" Matsumoto 287f317f05 Merge branch 'master' of github.com:mruby/mruby 2014-03-21 09:24:40 +09:00
Yukihiro "Matz" Matsumoto 5bcb119ed7 use File#directory? instead of File#exist?; ref c2d8b0 2014-03-21 09:24:28 +09:00
Yukihiro "Matz" Matsumoto b331db1c47 Merge pull request #1899 from stomar/about
Reword mention of mrbtest in README
2014-03-21 09:21:09 +09:00
Yukihiro "Matz" Matsumoto bb5e4cfd6d Merge branch 'master' of github.com:mruby/mruby 2014-03-21 09:20:11 +09:00
Yukihiro "Matz" Matsumoto 298c07d6ca add Hash#each_pair 2014-03-21 09:19:53 +09:00
Yukihiro "Matz" Matsumoto 45b0e1f788 should be able to create hash with 127+ entries; close #1894 2014-03-21 09:18:10 +09:00
Marcus Stollsteimer 69ec2547ce Reword mention of mrbtest in README 2014-03-20 20:10:23 +01:00
Yukihiro "Matz" Matsumoto e96a1bc4e6 Merge pull request #1898 from akuroda/pr_true_test
add tests for TrueClass
2014-03-21 03:27:17 +09:00
Yukihiro "Matz" Matsumoto d3ae793ef7 Merge pull request #1897 from suzukaze/add-enum-count-comment
Add Enumerable#count comment
2014-03-21 03:26:49 +09:00
Yukihiro "Matz" Matsumoto 34002374fc Merge pull request #1895 from stomar/typos
Fix typos in README.md and doc/compile/README.md
2014-03-21 03:26:15 +09:00
Yukihiro "Matz" Matsumoto c2d8b0303d avoid Dir.exist? that is not available in Ruby1.8 2014-03-21 03:23:26 +09:00
Akira Kuroda 02406bc2e3 add tests for TrueClass
reorder and add tests for 15.2.5.1
2014-03-21 01:10:05 +09:00
Jun Hiroe 6cfc5795af Add Enumerable#count comment 2014-03-21 00:44:00 +09:00
Marcus Stollsteimer 77bf470cc5 Fix typos in README 2014-03-20 12:49:19 +01:00
Marcus Stollsteimer a8068b44cb Fix literal asterisks in markdown 2014-03-20 12:47:37 +01:00
Yukihiro "Matz" Matsumoto 36836c8eb9 should restore proc after rescue; close #1891 2014-03-20 16:10:12 +09:00
take_cheeze de65d4e2a7 make behavior of Fiber without block compatible with CRuby 2014-03-20 04:49:14 +09:00
take_cheeze daaedf320c refactor and use assert_raise in fiber test checking exception raise 2014-03-20 04:40:50 +09:00
take_cheeze 272fe3d864 use FiberError in fiber exception raise 2014-03-20 04:38:34 +09:00
Yukihiro "Matz" Matsumoto 07d81a113d enum methods to support multiple values; all?, any?, grep, include?, drop, drop_while, take, take_while, each_cons, each_slice, group_by, first, count 2014-03-19 15:36:55 +09:00
Yukihiro "Matz" Matsumoto 57c7f92dbf Merge branch 'master' of github.com:mruby/mruby 2014-03-19 14:03:19 +09:00
Yukihiro "Matz" Matsumoto 2bf718faf8 Merge pull request #1882 from ksss/enum-find_all
Enumerable#find_all return Enumerator if non block given
2014-03-19 10:43:54 +09:00
Yukihiro "Matz" Matsumoto d7eb455cf3 Merge branch 'master' of github.com:mruby/mruby 2014-03-19 09:08:11 +09:00
Yukihiro "Matz" Matsumoto 72c274473b remove size_t cast in mrb_assert() since ((size_t)n <= SIZE_MAX) is always true 2014-03-19 09:07:59 +09:00
Yukihiro "Matz" Matsumoto d9107fd157 Merge pull request #1890 from take-cheeze/fiber_resuming
Revert MRB_FIBER_RESUMED as MRB_FIBER_RESUMING.
2014-03-19 08:59:45 +09:00
Yukihiro "Matz" Matsumoto 9084e03556 rename mrb_yield_internal to mrb_yield_with_class since it's no longer internal 2014-03-19 08:57:54 +09:00
Yukihiro "Matz" Matsumoto 2f4eed2501 Merge pull request #1889 from iij/pr-struct-new-block-def
Set the newly created Struct object to self in its initialization block.
2014-03-19 07:54:22 +09:00
Tomoyuki Sahara 40c18fca77 self must be the newly created object in initialization block; close #1858 2014-03-19 01:08:46 +09:00
Tomoyuki Sahara 93694fe521 export mrb_yield_internal. 2014-03-19 01:08:01 +09:00
take_cheeze 4be7a8b7e8 add root fiber resume test to know double resume checking is working 2014-03-19 01:05:21 +09:00
take_cheeze 19c4bf6fcb revert MRB_FIBER_RESUMED as MRB_FIBER_RESUMING to fix recurive resume 2014-03-19 01:05:21 +09:00
Yukihiro "Matz" Matsumoto 792c1add0c string functions arguments changed from mrb_int to size_t that would take strlen() 2014-03-19 00:46:27 +09:00
Yukihiro "Matz" Matsumoto 180b3d5678 change mrb_int to size_t that would take strlen() 2014-03-19 00:17:03 +09:00
Yukihiro "Matz" Matsumoto 3e24e06b29 add a space after C reserved words 2014-03-18 23:57:29 +09:00
Yukihiro "Matz" Matsumoto 575d919122 should not use nil as default value for Enumerable#count since it prevent counting nil in enums; ref #1887 2014-03-18 23:50:31 +09:00
Yukihiro "Matz" Matsumoto 290faf88df Merge pull request #1887 from suzukaze/add-enumerable.count
Add Enumerable#count
2014-03-18 23:48:15 +09:00
Yukihiro "Matz" Matsumoto 53a282ac0e stricter check for double resume; close #1885 2014-03-18 23:47:01 +09:00
Jun Hiroe 17fdd81573 Add Enumerable#count test 2014-03-18 23:08:24 +09:00
Jun Hiroe 02ac5dd9f1 Add Enumerable#count 2014-03-18 23:06:01 +09:00
Yukihiro "Matz" Matsumoto 31b2980acb Merge pull request #1880 from ksss/enum-each_with_index
Enumrable#each_with_index return Enumerator if non block given
2014-03-18 22:22:23 +09:00
Yukihiro "Matz" Matsumoto 555c187687 Merge pull request #1883 from suzukaze/add-test-enumerable
Add enumerable test
2014-03-18 22:21:37 +09:00
Yukihiro "Matz" Matsumoto 598385e2d6 Merge pull request #1886 from iij/pr-kernel-loop-rescue-error
Kernel.loop should not catch StandardError.
2014-03-18 22:21:01 +09:00
Yukihiro "Matz" Matsumoto 4893a1f431 Merge pull request #1884 from monaka/pr-reduce-implicit-type-cast
Reduce implicit type casts.
2014-03-18 22:18:57 +09:00
Tomoyuki Sahara 4b4784f96f rescue StopIteration only. 2014-03-18 19:02:38 +09:00
Masaki Muranaka 1df355e300 Reduce implicit type casts. 2014-03-18 17:36:47 +09:00
Yukihiro "Matz" Matsumoto b844b96858 add Fiber#== from #1865 patch 2014-03-18 12:42:35 +09:00
Yukihiro "Matz" Matsumoto 4c690b23a6 add fiber assertion from #1865 patch 2014-03-18 12:41:51 +09:00
Yukihiro "Matz" Matsumoto 9201af7d36 mark root fiber object; close #1865 2014-03-18 12:39:11 +09:00
Jun Hiroe 0349283fab Add Enumerable#first test 2014-03-18 00:30:31 +09:00
Jun Hiroe 7380acf1b6 Add Enumerable#sort_by test 2014-03-18 00:29:14 +09:00
ksss fd80d4ecdd Enumerable#find_all return Enumerator if non block given 2014-03-17 23:32:31 +09:00
ksss 9abe413530 Enumrable#each_with_index return Enumerator if non block given 2014-03-17 22:31:40 +09:00
Yukihiro "Matz" Matsumoto 2f8dbd8e5d recover description in default.gembox 2014-03-17 08:57:02 +09:00
Yukihiro "Matz" Matsumoto 2abfeeafdb Merge branch 'mrbgem_summary' of https://github.com/take-cheeze/mruby into take-cheeze-mrbgem_summary 2014-03-17 08:53:16 +09:00
Yukihiro "Matz" Matsumoto 26930ddc19 Merge branch 'refactor-enumerable.rb' of https://github.com/suzukaze/mruby into suzukaze-refactor-enumerable.rb 2014-03-17 08:45:05 +09:00
Yukihiro "Matz" Matsumoto cea951dc7a Merge branch 'master' of github.com:mruby/mruby 2014-03-17 08:44:46 +09:00
Yukihiro "Matz" Matsumoto 446d721715 Merge pull request #1875 from akuroda/pr_nil_test
add unit tests for NilClass
2014-03-17 08:41:41 +09:00
Jun Hiroe bdeef827ac Refactor Enumerable#include? 2014-03-17 01:18:45 +09:00
Jun Hiroe a21088b2d7 Refactor Enumerable#any? 2014-03-17 01:18:44 +09:00
Jun Hiroe b9632bce46 Refactor Enumerable#all? 2014-03-17 01:18:44 +09:00
Yukihiro "Matz" Matsumoto 5ac737cf88 add Enumerable#sort_by 2014-03-17 01:09:07 +09:00
Yukihiro "Matz" Matsumoto 027d6407cc make Enumerable methods to support multiple values; collect, detect, each_with_index, find_all, inject, max, min, partition, reject, sort 2014-03-17 00:53:08 +09:00
Yukihiro "Matz" Matsumoto ed2fe64076 Enumerable#entries to support multiple values; close #1868 2014-03-17 00:34:47 +09:00
take_cheeze 624e34a6fe don't show version '0.0.0' in build summary since it's default version 2014-03-17 00:34:25 +09:00
take_cheeze c35b0c5245 add summary to mrbgems without it 2014-03-17 00:34:25 +09:00
take_cheeze 4bd623ba75 print gem summary in print_build_summary method 2014-03-17 00:34:24 +09:00
take_cheeze c73f8d4def move summary of mrbgems in default gembox to its spec 2014-03-17 00:34:24 +09:00
Yukihiro "Matz" Matsumoto 75a4f1ac96 refactor Enumerable#{all?,any?} tests 2014-03-17 00:17:52 +09:00
Yukihiro "Matz" Matsumoto 3687e1f97b Merge branch 'master' of github.com:mruby/mruby 2014-03-17 00:16:01 +09:00
Yukihiro "Matz" Matsumoto 0d82ada922 Merge pull request #1869 from suzukaze/add-test-enumerable.rb
Add test enumerable.rb
2014-03-17 00:15:51 +09:00
Yukihiro "Matz" Matsumoto d53423fb7d Merge pull request #1870 from ksss/convert_type
fix bool number to macro
2014-03-17 00:15:01 +09:00
Yukihiro "Matz" Matsumoto e4ae3bf661 Merge pull request #1871 from ksss/numeric-plus
fix bug when `0 + other object`
2014-03-17 00:14:42 +09:00
Yukihiro "Matz" Matsumoto 5140e27b5a Merge pull request #1872 from ksss/numeric-mul
fix bug when `0 * other object`
2014-03-17 00:14:16 +09:00
Yukihiro "Matz" Matsumoto 777d460fb8 Merge pull request #1873 from suzukaze/refactor-assert.rb
Refactor assert_true
2014-03-17 00:13:45 +09:00
Akira Kuroda 395c0087d4 add unit tests for NilClass 2014-03-17 00:13:34 +09:00
Yukihiro "Matz" Matsumoto ffdef362ec Merge pull request #1874 from ksss/float-plus
float + nil should be raise TypeError
2014-03-17 00:13:24 +09:00
Yukihiro "Matz" Matsumoto 55c1942b43 add Enumerable#first to mruby-enum-ext 2014-03-17 00:04:34 +09:00
ksss 0fab9d557e float + nil should be raise TypeError 2014-03-16 23:39:58 +09:00
Jun Hiroe d27dcbe9d2 Refactor assert_true 2014-03-16 23:26:29 +09:00
ksss 9dcce29749 fix bug when 0 * other object 2014-03-16 23:08:31 +09:00
ksss e9f3dca0f4 fix bug when 0 + other object 2014-03-16 22:52:25 +09:00
ksss a481976056 fix bool number to macro 2014-03-16 21:06:08 +09:00
Jun Hiroe 8ba04a09a9 Add Enumerable#any?(&block) tests 2014-03-16 18:58:39 +09:00
Jun Hiroe cf556f0ad9 Add Enumerable#all?(&block) tests 2014-03-16 18:49:05 +09:00
Yukihiro "Matz" Matsumoto 18bebd3acd Merge pull request #1867 from cubicdaiya/issues/indent_style
Unify indent style
2014-03-16 14:41:01 +09:00
cubicdaiya cee152670a unify indent style 2014-03-16 07:44:44 +09:00
Yukihiro "Matz" Matsumoto ef884caca5 Merge branch 'master' of github.com:mruby/mruby 2014-03-15 16:03:21 +09:00
Yukihiro "Matz" Matsumoto b09b774dda Merge pull request #1863 from take-cheeze/fiber_double_resume
Add Fiber's double resume test and fix it.
2014-03-15 15:59:54 +09:00
Yukihiro "Matz" Matsumoto 62505d51cc calc hash value directly for strings, symbols and numbers 2014-03-15 15:53:12 +09:00
Yukihiro "Matz" Matsumoto 048bca43c9 string length type to be mrb_int 2014-03-15 15:47:21 +09:00
Yukihiro "Matz" Matsumoto c476c1b528 symbol length type to be mrb_int 2014-03-15 15:43:40 +09:00
take_cheeze 62f05614ee Add Fiber's double resume test and fix it. 2014-03-15 15:18:06 +09:00
Yukihiro "Matz" Matsumoto b868ce8a77 Hash#shift may return any entries 2014-03-15 15:01:17 +09:00
Yukihiro "Matz" Matsumoto ddd1bfda02 type of mrb_type() should be enum mrb_vtype when MRB_NAN_BOXING is on 2014-03-15 14:30:17 +09:00
Yukihiro "Matz" Matsumoto fc75cff14e Merge pull request #1859 from ksss/enumerator
Fix Enumerator
2014-03-15 11:35:02 +09:00
ksss 447764763c add test for Array#each_index if non block given 2014-03-15 08:21:39 +09:00
ksss 4f8e11ae57 optimize from each to enumerator_block_call 2014-03-15 08:21:39 +09:00
ksss 0bb7f5e950 fix variable name typo 2014-03-15 08:21:39 +09:00
ksss 9447c637a5 test split and to detail 2014-03-15 08:21:34 +09:00
ksss 6b3cc0052d fix self modifying bug 2014-03-15 08:15:16 +09:00
ksss 47fc784b56 fix return value for with_index 2014-03-15 08:15:16 +09:00
ksss bc63518fa7 modify core method that return Enumerator object if not block given 2014-03-15 08:15:04 +09:00
ksss 29964cfdac make private method enumerator_block_call 2014-03-14 23:42:04 +09:00
Yukihiro "Matz" Matsumoto e893349e95 Merge pull request #1857 from mitchellh/f-fix-mingw-time
Don't redefine timeval in MinGW environments
2014-03-14 16:30:48 +09:00
Mitchell Hashimoto 3843a286b6 Don't redefine timeval on MingW64 environments 2014-03-13 23:23:28 -07:00
Tomoyuki Sahara 719452b8d2 remove unsed. 2014-03-14 10:47:54 +09:00
Tomoyuki Sahara 14031bdf44 Merge pull request #11 from pbosetti/master
Can build on VisualStudio, revised.
2014-03-14 10:41:56 +09:00
Yukihiro "Matz" Matsumoto 94df66fb08 Merge branch 'master' of github.com:mruby/mruby 2014-03-14 07:40:07 +09:00
Yukihiro "Matz" Matsumoto 1b6f6413db Merge pull request #1855 from take-cheeze/fix_mrbc_compile_error
Fix compile error check of Mrbc command.
2014-03-14 07:39:53 +09:00
take_cheeze deb5f59bec fix compile error check of Mrbc command 2014-03-14 03:44:22 +09:00
Yukihiro "Matz" Matsumoto 2bd099c842 remove new_label(s) where label position can be obtained from genop() 2014-03-14 03:11:11 +09:00
Yukihiro "Matz" Matsumoto 8094a503f0 move dependency check from runtime to mrbgem.rake 2014-03-14 02:59:50 +09:00
Yukihiro "Matz" Matsumoto 58362fc30c remove ambiguity warnings 2014-03-14 02:44:14 +09:00
Yukihiro "Matz" Matsumoto 113ab60784 mruby-enumerator: move definitions in core_mod.rb to mrblib core 2014-03-14 02:41:22 +09:00
ksss 463c5f83c3 add mruby-enumerator 2014-03-13 23:47:12 +09:00
Yukihiro "Matz" Matsumoto 91f2d47d34 too much optimization 2014-03-13 23:44:10 +09:00
Yukihiro "Matz" Matsumoto 8cc487c465 peephole optimization for OP_JMP{IF,NOT} 2014-03-13 19:54:50 +09:00
Yukihiro "Matz" Matsumoto 5b3c76ee48 Merge pull request #1849 from cremno/add-mrb_int_bit-macro
add MRB_INT_BIT
2014-03-13 03:09:58 +09:00
Yukihiro "Matz" Matsumoto ad04b45e5b Merge pull request #1851 from tmash06/add_include_limit_h
add including limits.h.
2014-03-13 03:09:03 +09:00
Yukihiro "Matz" Matsumoto 4e1a10f035 Merge pull request #1850 from cremno/safer-lit-macros
add mrb_strlen_lit
2014-03-13 03:08:31 +09:00
tmash06 cfcd2e2dc9 add including limits.h.
Because Android's libc(bionic) defines SIZE_MAX at limits.h.
2014-03-13 02:37:09 +09:00
cremno e4afd5374f add mrb_strlen_lit which makes _lit macros safer
strlen(3) + string literal is usually optimized but strlen(3) doesn't
check if its argument is really a string literal. This is important for
mruby's _static functions to which some _lit macros are expanded (string
literals have static storage). See comment for some additional info.

remove unnecessary parentheses
2014-03-12 17:56:08 +01:00
Yukihiro "Matz" Matsumoto f85e5a80dc Merge pull request #1826 from unak/mswin
ignore *.pdb
2014-03-12 15:38:08 +09:00
Yukihiro "Matz" Matsumoto 1b845de755 Merge pull request #1848 from joejimbo/master
Added a short description about mruby gems
2014-03-12 15:12:10 +09:00
Joachim Baran 244260b05e Added a short description on how to add mruby gems to the compilation workflow. 2014-03-11 22:27:28 -07:00
Yukihiro "Matz" Matsumoto fa2e87c468 avoid mrb_string_value_cstr() to copy string between mrb_states in tests 2014-03-12 13:32:04 +09:00
Yukihiro "Matz" Matsumoto 7e8652d549 Merge pull request #1843 from take-cheeze/suppress_warnings
Suppress warnings.
2014-03-12 11:45:14 +09:00
Yukihiro "Matz" Matsumoto 9b7198c222 Merge pull request #1846 from take-cheeze/funcall_fix
Fix mrb_funcall calling.
2014-03-12 11:16:58 +09:00
take_cheeze 7c4961234d fix mrb_funcall calling 2014-03-12 10:18:38 +09:00
Tomoyuki Sahara 279587c138 split. 2014-03-12 09:44:34 +09:00
Tomoyuki Sahara a8558512ec mruby-mtest is not required to build (but to test). 2014-03-12 09:41:23 +09:00
cremno 1b6a4fb5a2 add MRB_INT_BIT 2014-03-11 20:14:18 +01:00
Tomoyuki Sahara e345d4c68f Merge pull request #7 from monami-ya-mrb/pr-fix-connect-failed
Call Socket._connect() in Socket.connect() .
2014-03-11 23:25:29 +09:00
take_cheeze 52cf39a67a remove deprecated register keyword 2014-03-11 22:01:00 +09:00
take_cheeze bbb7ba46b2 don't use of anonymous unions 2014-03-11 22:01:00 +09:00
Masaki Muranaka 11b47459e7 Call Socket._connect() in Socket.connect() . 2014-03-11 21:18:05 +09:00
Yukihiro "Matz" Matsumoto fee639775e Merge pull request #1845 from ksss/sym_intern-argument-type
fix sym_intern argument type
2014-03-11 14:05:06 +09:00
ksss 58a5e832d9 fix sym_intern argument type 2014-03-11 09:12:56 +09:00
Yukihiro "Matz" Matsumoto 6dd2f36d20 Merge pull request #1842 from ksss/assert_nothing_raised
add assertion method `assert_nothing_raised'
2014-03-11 00:19:45 +09:00
ksss 23680cb447 add assertion method `assert_nothing_raised' 2014-03-11 00:13:36 +09:00
Yukihiro "Matz" Matsumoto 86a48b7c48 Merge pull request #1840 from ksss/bit-field
set bit field for mrb_bool
2014-03-10 22:24:36 +09:00
Yukihiro "Matz" Matsumoto 04dffc239b Merge pull request #1841 from ksss/symbol-bool
set bool macro
2014-03-10 22:24:18 +09:00
ksss a53dd33eaa set bool macro 2014-03-10 13:18:34 +00:00
ksss 49a048c544 set bit field for mrb_bool 2014-03-10 13:14:07 +00:00
Yukihiro "Matz" Matsumoto f168e12ba7 Merge pull request #1838 from take-cheeze/reduce_mrb_open_in_test
Reduce mrb_open calls in mrbgem test.
2014-03-10 15:57:58 +09:00
Yukihiro "Matz" Matsumoto 93350ca221 Merge pull request #1839 from cubicdaiya/issues/comment_include_guard
Add comments at end of include guard
2014-03-10 15:54:22 +09:00
cubicdaiya 042c9f95a5 add comments at end of include guard 2014-03-10 12:37:47 +09:00
take_cheeze 77fba20480 reduce mrb_open calls in mrbgem test 2014-03-10 04:45:28 +09:00
Yukihiro "Matz" Matsumoto c740a78e5c Merge pull request #1837 from monaka/pr-add-comments
Add comments to notify files are auto generated.
2014-03-09 19:06:02 +09:00
Masaki Muranaka 5cf46db561 Add comments to notify files are auto generated. 2014-03-09 18:10:27 +09:00
Yukihiro "Matz" Matsumoto 5f787b0cdf Merge pull request #1836 from monaka/pr-use-mrb_str_new_cstr
Use mrb_str_new_cstr() instead of mrb_str_new() with strlen().
2014-03-09 17:12:28 +09:00
Masaki Muranaka 40f57f7b42 Use mrb_str_new_cstr() instead of mrb_str_new() with strlen(). 2014-03-09 16:45:29 +09:00
Yukihiro "Matz" Matsumoto 4f27089b4a Merge branch 'master' of github.com:mruby/mruby 2014-03-09 03:16:28 +09:00
Yukihiro "Matz" Matsumoto bc663549ea Merge pull request #1833 from cremno/use-mrb_str_cat_lit
use mrb_str_cat_lit for literals
2014-03-09 03:01:54 +09:00
Yukihiro "Matz" Matsumoto 24839d74b2 Merge pull request #1834 from cremno/use-nan-and-infinity-macros
use NAN and INFINITY macros
2014-03-09 03:01:04 +09:00
cremno bfc522bcd5 use mrb_str_cat_lit for literals 2014-03-08 18:38:31 +01:00
Yukihiro "Matz" Matsumoto 6423011986 remove invocation of strlen() on buffer of strings; with refactoring 2014-03-09 02:35:49 +09:00
Yukihiro "Matz" Matsumoto ee57789c72 Merge pull request #1831 from monaka/pr-make-type-casts-safer
Make type casts safer
2014-03-09 01:28:31 +09:00
Yukihiro "Matz" Matsumoto 452bf73c23 Merge pull request #1832 from ksss/fix-1823
fix #1823
2014-03-09 01:27:34 +09:00
cremno 8a4faae55e MSVC: add NAN and INFINITY for older versions 2014-03-08 17:25:56 +01:00
cremno f57b9d1576 use NAN and INFINITY
The macro str_to_mrb_float (strto[df]) converts a string to a number,
but these two macros can be used to directly get the special value.

The NAN macro requires quiet NaN support, but so does str_to_mrb_float.

This change also circumvents missing C99 support in Microsoft's C library.
Its (or ISO C90's) strtod doesn't parse "nan" or "inf".
2014-03-08 17:25:07 +01:00
Yukihiro "Matz" Matsumoto 6a23be7805 add data_type check to mruby-random 2014-03-09 01:22:53 +09:00
Yukihiro "Matz" Matsumoto 9a89a82048 refactoring mruby-random 2014-03-09 01:21:57 +09:00
Yukihiro "Matz" Matsumoto ae65c7da58 implement Array#sample in mruby-random gem 2014-03-09 01:03:34 +09:00
Yukihiro "Matz" Matsumoto bd4b59cd04 add "?" specifier to check if preceding optional argument is given 2014-03-09 00:25:59 +09:00
ksss d7b179475b fix #1823 2014-03-08 17:51:21 +09:00
Masaki Muranaka 270d25bf2d Make type casts safer. 2014-03-08 15:53:59 +09:00
Yukihiro "Matz" Matsumoto 058bb18f28 Merge pull request #1828 from take-cheeze/string_embed
Use sizeof(void*) instead of mrb_int size and extend embed string size.
2014-03-08 15:01:42 +09:00
Yukihiro "Matz" Matsumoto 286665c437 Merge pull request #1830 from cremno/pool-fixes
two pool fixes
2014-03-08 13:34:19 +09:00
Yukihiro "Matz" Matsumoto 6f5d234292 Merge pull request #1829 from takkaw/mirb_linenoise
support linenoise in mirb
2014-03-08 13:31:38 +09:00
cremno 307c356c8a pool: use mrb_malloc_simple instead of mrb_malloc 2014-03-07 20:55:11 +01:00
cremno 0c96b936dc MSVC: fix C4146
C4146 (unary minus operator applied to unsigned type, result still
unsigned)
2014-03-07 20:48:44 +01:00
takkaw 0d4bd01cf1 support linenoise in mirb 2014-03-08 01:22:31 +09:00
Paolo Bosetti 39bd240116 Fixed bug in File.expand_path() on Windows (forever recursive loop) 2014-03-07 16:47:18 +01:00
Yukihiro "Matz" Matsumoto e5e5aadfa8 convert too much from size_t to uint32_t; mrb_sym2name_len() takes size_t* 2014-03-08 00:38:56 +09:00
take_cheeze c3f3a0484a use sizeof(void*) instead of mrb_int size and extend embed string size 2014-03-08 00:32:59 +09:00
U.Nakamura 7591049e89 ignore *.pdb 2014-03-07 23:27:31 +09:00
Yukihiro "Matz" Matsumoto aa4f3c79ef reduce integer type complexity from int/size_t/uint32_t by unifying them to uint32_t; close #1778 2014-03-07 20:30:42 +09:00
Yukihiro "Matz" Matsumoto ac8d04fb6c Merge pull request #1820 from ksss/string-embed
Embed small string
2014-03-07 18:51:32 +09:00
Yukihiro "Matz" Matsumoto 035898c721 Merge pull request #1824 from unak/patch-1
.PHONY should be placed after `all'
2014-03-07 18:41:01 +09:00
Yukihiro "Matz" Matsumoto fe1b4cea41 Hash#== and eql? should not return fixnum; ref #1823 2014-03-07 18:40:10 +09:00
Yukihiro "Matz" Matsumoto 23853acbb6 Merge pull request #1823 from ksss/hash-eql
Fix behavior Hash#eql?
2014-03-07 18:36:53 +09:00
unak 8ee5b0196b .PHONY should be placed after `all'
Because some make (e.g. nmake) recognize it as a normal rule definition and if it's the first rule, make runs it as a default rule.
Consequently `all', `test' and `clean' are all ran (because they are depended by .PHONY), and builded files are cleaned.
2014-03-07 12:11:10 +09:00
ksss cab1f734ef Fix behavior Hash#eql? 2014-03-07 11:08:24 +09:00
ksss 4bc19d5fad add embed string test 2014-03-06 14:00:08 +00:00
ksss 54132e4364 make embed string when create literals 2014-03-06 13:47:51 +00:00
ksss 4070b5987a embed small string
use flags 4 for *this object is embed*
use flags 8~64 for *embed string length*
2014-03-06 13:12:08 +00:00
Yukihiro "Matz" Matsumoto e40428af7b Merge pull request #1819 from mattn/fix-mruby-time
Fix build on mingw32
2014-03-06 20:57:29 +09:00
mattn a9ac721e38 Fix build on mingw32 2014-03-06 19:57:22 +09:00
Yukihiro "Matz" Matsumoto 50974614ec Merge pull request #1818 from unak/patch-1
fixed broken gettimeofday implementation for Windows
2014-03-06 12:46:11 +09:00
unak 561c2a1581 fixed broken gettimeofday implementation for Windows
small, but critical typo :)
2014-03-06 12:40:48 +09:00
Yukihiro "Matz" Matsumoto bd4f38add6 Merge pull request #1815 from take-cheeze/source_location
Fix and add test for Proc#source_location.
2014-03-06 08:39:51 +09:00
Yukihiro "Matz" Matsumoto 2329b17893 Merge pull request #1817 from cremno/visualcpp-toolchain-change-cflags
visualcpp toolchain: change compiler/linker flags
2014-03-06 08:37:40 +09:00
Yukihiro "Matz" Matsumoto 00af5efd96 Merge pull request #1816 from cremno/error.h-add-extern_c
error.h: add extern "C" for C++
2014-03-06 08:36:44 +09:00
cremno ab025dc511 visualcpp toolchain: change compiler/linker flags
with these flags visualcpp should behave more like the gcc toolchain

c:
- produce debug information
- optimize for speed instead of disabling optimization
- use non-debug version of Microsoft's C library
- remove unused and unnecessary macro definitions
cxx:
- separate C and C++ (#1594)
- specify kind of exception handling (see warning C4530)
linker:
- produce debug information
- disable incremental linking and re-enable optimizations
2014-03-05 20:27:58 +01:00
cremno cbc84ba5b2 error.h: add extern "C" for C++ 2014-03-05 19:50:13 +01:00
take_cheeze f8270ee59b fix and add test for Proc#source_location 2014-03-06 03:40:41 +09:00
Yukihiro "Matz" Matsumoto b8625bbc5e Merge pull request #1814 from cremno/__file__-windows-paths
__FILE__ test: add support for \ as separator
2014-03-06 01:44:25 +09:00
Yukihiro "Matz" Matsumoto 1bba236cb2 Merge pull request #1812 from cremno/time-3
mruby-time: add gettimeofday(2) for Windows
2014-03-06 01:43:06 +09:00
Yukihiro "Matz" Matsumoto 9dfdbe6632 Merge pull request #1813 from cremno/time-1
mruby-time: various smaller changes
2014-03-06 01:41:37 +09:00
cremno 3900fcecd7 __FILE__ test: add support for \ as separator 2014-03-05 17:38:02 +01:00
cremno 890ef11fde mruby-time: add gettimeofday(2) for Windows 2014-03-05 17:13:13 +01:00
cremno 69b231ece5 mruby-time: fix indentation in mrb_time_asctime 2014-03-05 17:08:51 +01:00
cremno 96d3bc2811 mruby-time: store timezone name directly 2014-03-05 17:08:51 +01:00
cremno 9b3033bb53 mruby-time: timezone_names should be const 2014-03-05 17:08:50 +01:00
cremno e34b69f582 mruby-time: store strings directly instead of pointers to them 2014-03-05 17:08:44 +01:00
cremno 333840ba61 mruby-time: mrb_time_type should be const 2014-03-05 16:53:42 +01:00
cremno f9c88e9c68 mruby-time: fix two tiny typos in comments 2014-03-05 16:53:41 +01:00
cremno c088797107 mruby-time: rearrange header order 2014-03-05 16:53:41 +01:00
cremno bf48f5ec87 mruby-time: remove trailing whitespace 2014-03-05 16:53:40 +01:00
Yukihiro "Matz" Matsumoto 2f20463b77 Merge pull request #1811 from takkaw/refactor_mirb
small refactor in mirb
2014-03-06 00:20:41 +09:00
takkaw d7d8b09580 small refactor 2014-03-05 23:35:34 +09:00
Yukihiro "Matz" Matsumoto faf48bb761 Merge branch 'master' of github.com:mruby/mruby 2014-03-05 21:53:07 +09:00
Yukihiro "Matz" Matsumoto adc5b56c15 use mrb_int instead of size_t since string length is represented by mrb_int; close #1810 2014-03-05 21:51:44 +09:00
Yukihiro "Matz" Matsumoto 61d06abf81 Merge pull request #1809 from matsumoto-r/change_mruby_libs_flag
Change the position of -L option from MRUBY_LIBS to MRUBY_LDFLAGS
2014-03-05 21:39:20 +09:00
Yukihiro "Matz" Matsumoto 640efb3015 Merge pull request #1808 from cubicdaiya/issues/unused_variable
remove unused variable
2014-03-05 17:44:12 +09:00
MATSUMOTO Ryosuke a5dd02f94f Change the position of -L option from MRUBY_LIBS to MRUBY_LDFLAGS 2014-03-05 17:37:44 +09:00
Yukihiro "Matz" Matsumoto 1c4d58b882 Merge pull request #1807 from tmash06/fix_exit_status_code
fix mruby command returning EXIT_SUCCESS when program file can't be opened.
2014-03-05 17:26:25 +09:00
cubicdaiya 80d8170959 remove unused variable
GLOBAL_RAND_SEED_KEY is no longer used.
2014-03-05 17:19:26 +09:00
Tatsuya Matsumoto 43944a0d3a fix mruby command returning EXIT_SUCCESS when program file can't be
opened.
2014-03-05 16:51:57 +09:00
Yukihiro "Matz" Matsumoto 3120eb3ecc Merge pull request #1806 from tmash06/fix_exit_method_aspec_setting
fix argument spec setting of Kernel.exit method.
2014-03-05 16:23:42 +09:00
Tatsuya Matsumoto 2d5a7371bc fix argument spec setting of Kernel.exit method.
this method requires 1 optional argument.
2014-03-05 15:54:03 +09:00
Yukihiro "Matz" Matsumoto d03c72ad53 Merge branch 'master' of github.com:mruby/mruby 2014-03-05 15:38:27 +09:00
Yukihiro "Matz" Matsumoto 865b850b76 should check crossing C boudary from resume 2014-03-05 15:38:13 +09:00
Yukihiro "Matz" Matsumoto 415b70fd49 Merge pull request #1805 from take-cheeze/existing_include
Add existing include/ directory only.
2014-03-05 15:24:43 +09:00
Yukihiro "Matz" Matsumoto 071317e81b Merge pull request #1804 from mattn/fix-quote
Fix #1803
2014-03-05 15:24:09 +09:00
take_cheeze 9d81487c8b add existing include/ directory only 2014-03-05 14:29:45 +09:00
mattn 98b5b68298 Fix #1803 2014-03-05 14:11:53 +09:00
mattn 7510d9adee s/\\"/"/g in mruby-config 2014-03-05 13:50:14 +09:00
Yukihiro "Matz" Matsumoto f911b23599 Merge pull request #1801 from mattn/mruby-config
Add mruby-bin-mruby-config
2014-03-05 13:18:39 +09:00
Yukihiro "Matz" Matsumoto 13d9ed455c Merge pull request #1802 from tmash06/fix_syntax_check_no_exec
mruby command should not execute program on "syntax only option(-c)".
2014-03-05 13:11:54 +09:00
Yukihiro "Matz" Matsumoto 1742e74434 Merge pull request #1800 from tmash06/fix_indent
fix indent.
2014-03-05 13:06:56 +09:00
Yukihiro "Matz" Matsumoto e641412547 Merge pull request #1799 from cubicdaiya/issues/off_by_one_error2
fix off-by-one error in attrsym
2014-03-05 13:06:34 +09:00
mattn 67b8f6ec60 Don't echo empty string. (Remove workaround for windows) 2014-03-05 12:56:27 +09:00
mattn 48616a85af chmod 755 2014-03-05 12:51:15 +09:00
Tatsuya Matsumoto 23cb0bb64b mruby command should not execute program on "syntax only option(-c)". 2014-03-05 12:49:58 +09:00
mattn fb621ef411 Add mruby-bin-mruby-config 2014-03-05 12:46:07 +09:00
Tatsuya Matsumoto 7ac4a60cf0 fix indent. 2014-03-05 11:57:10 +09:00
cubicdaiya 016d3b9394 fix off-by-one error in attrsym
The allocation size for null-terminated character is lacking.
In actual, it is no problem in most case
because codegen_palloc allocates more a memory size than required size.
2014-03-05 11:20:39 +09:00
Yukihiro "Matz" Matsumoto ba608fb38a Merge pull request #1797 from take-cheeze/doc_update
Add notes about new features.
2014-03-05 07:27:23 +09:00
Yukihiro "Matz" Matsumoto 2667371e1e Merge pull request #1796 from mattn/fix_1793
Fix #1793
2014-03-05 07:26:16 +09:00
take_cheeze ce9681dce6 fix typo 2014-03-05 03:08:23 +09:00
take_cheeze 1029be3cd8 update compilation notes 2014-03-05 03:08:06 +09:00
mattn d59b738b43 Fix #1793 2014-03-04 22:25:25 +09:00
Yukihiro "Matz" Matsumoto 47d1701fb4 Merge pull request #1795 from cubicdaiya/issues/off_by_one_error
fix off-by-one error in String#rindex(fixnum)
2014-03-04 22:22:45 +09:00
Yukihiro "Matz" Matsumoto a479dafb9b Merge pull request #1792 from cubicdaiya/issues/fix_invalid_comment
fix a comment end of include guard
2014-03-04 22:21:19 +09:00
cubicdaiya ebe4711df8 fix off-by-one error in String#rindex(fixnum)
null-terminated string should not be included in search targets.
2014-03-04 21:58:47 +09:00
cubicdaiya dd4ddcae38 fix a comment end of include guard 2014-03-04 20:35:11 +09:00
Paolo Bosetti 7ff049457f Added File.foreach method.
Improved error management in File.new (Errno can be undefined)
2014-03-04 10:43:46 +01:00
Yukihiro "Matz" Matsumoto 7a607112c6 Merge pull request #1791 from iij/pr-numeric-div
add Integer#div and Float#div to mruby-numeric-ext
2014-03-04 17:31:16 +09:00
Tomoyuki Sahara 4ad0896bda add Integer#div and Float#div. 2014-03-04 12:45:11 +09:00
Yukihiro "Matz" Matsumoto 6b6277e2c6 Merge pull request #1790 from iij/pr-float-divmod
fix Float#divmod returns nil
2014-03-04 11:56:40 +09:00
Tomoyuki Sahara 6e1f4695aa add tests for Integer#divmod. 2014-03-04 10:51:56 +09:00
Tomoyuki Sahara 9686890ab3 Fix Float#divmod. 2014-03-04 10:51:36 +09:00
Yukihiro "Matz" Matsumoto a3411c4c96 Merge pull request #1789 from cubicdaiya/feature/mrb_exc_new_str_lit
Introduce mrb_exc_new_str_lit for C string literals
2014-03-04 08:37:38 +09:00
cubicdaiya 019d15c3ee Use mrb_exc_new_str_lit widely 2014-03-04 02:45:53 +09:00
cubicdaiya a514e31f6b introduce mrb_exc_new_str_lit for C string literals 2014-03-04 02:45:13 +09:00
Yukihiro "Matz" Matsumoto e1b3cfa88e Merge branch 'master' of github.com:mruby/mruby 2014-03-04 01:39:34 +09:00
Yukihiro "Matz" Matsumoto 18f0fcb0c7 add new macros for MRB_STR_SHARED operations, based on 0f7aecf from @ksss; ref #1782 2014-03-04 01:33:58 +09:00
Paolo Bosetti d9f3fd868a Merge branch 'master' of https://github.com/iij/mruby-io into test
Conflicts:
	src/io.c
2014-03-03 13:15:57 +01:00
Yukihiro "Matz" Matsumoto 0cc34d64a2 Merge pull request #1787 from take-cheeze/bintest_improvement
`bintest` improvement.
2014-03-03 21:00:20 +09:00
take_cheeze 24e3e33cb6 use tempfile module 2014-03-03 17:01:47 +09:00
take_cheeze fa5c3d4f51 add test to check striped binary works correctly 2014-03-03 16:58:27 +09:00
take_cheeze cfa7889996 run enabled gem's bintest only 2014-03-03 16:53:26 +09:00
Yukihiro "Matz" Matsumoto 369c6c3649 Kernel#send does not use mrb_funcall anymore for most cases; ref #1680 2014-03-03 13:31:29 +09:00
Yukihiro "Matz" Matsumoto 933f8013e0 Merge branch 'master' of github.com:mruby/mruby 2014-03-03 13:25:25 +09:00
Yukihiro "Matz" Matsumoto 9a92b40aaf rescue clause should understand splats; close #1786 2014-03-03 13:25:13 +09:00
Yukihiro "Matz" Matsumoto 55a43c78ff Merge pull request #1785 from tmash06/fix_include_guard_style
fix include guard style.
2014-03-03 07:42:41 +09:00
Tatsuya Matsumoto 71319ac335 fix include guard style. 2014-03-03 00:46:39 +09:00
Yukihiro "Matz" Matsumoto ae55e9e23e Merge pull request #1784 from tmash06/fix_memory_leak_in_mruby-random
fix a memory leak in mruby-random.
2014-03-02 22:36:17 +09:00
Tatsuya Matsumoto d496ba7e25 fix a memory leak in mruby-random. 2014-03-02 22:18:02 +09:00
Yukihiro "Matz" Matsumoto 611b1e8e9b Merge pull request #1780 from monaka/pr-add-ssh-protocol-support-for-bitbucket
Add ssh protocol support for bitbucket.
2014-03-02 21:24:40 +09:00
Yukihiro "Matz" Matsumoto 6c9bf266b3 Merge pull request #1779 from akuroda/pr_test_string_times
add tests for String#*
2014-03-02 21:21:37 +09:00
Akira Kuroda 8d6ce6bace add tests for String#*
add test cases for 0 and -1
2014-03-02 12:19:57 +09:00
Masaki Muranaka b58e6b9146 Add ssh protocol support for bitbucket. 2014-03-02 12:08:09 +09:00
Yukihiro "Matz" Matsumoto ba7ea50788 Merge pull request #1777 from take-cheeze/command_improvement
Command improvements.
2014-03-02 08:15:01 +09:00
take_cheeze 2543b712a3 remove explicit use of g++ 2014-03-02 05:04:00 +09:00
take_cheeze 600c17ec08 use shallow clone in git gem 2014-03-02 04:33:23 +09:00
take_cheeze 6de1c22d99 use c++ compiler to link when c++ abi is enabled 2014-03-02 04:30:06 +09:00
take_cheeze 9968af4570 allow command like "ccache gcc" 2014-03-02 04:26:33 +09:00
Yukihiro "Matz" Matsumoto 873fae9f45 wrap function prototype by extern "C" 2014-03-02 00:59:49 +09:00
Yukihiro "Matz" Matsumoto 7721463a35 add const to char* to pacify warnings for string litral to char* conversion 2014-03-02 00:59:12 +09:00
take_cheeze b98890a4b7 clear exc_catched before jumping to L_RAISE 2014-03-01 20:53:31 +09:00
take_cheeze 1eeafc27d0 define mrbconfs on all compiler 2014-03-01 20:05:31 +09:00
take_cheeze 54f9ca36fd define __STDC_* macros in y.tab.cxx too 2014-03-01 20:05:31 +09:00
take_cheeze fad4b578e1 wrap scope with do {} while() 2014-03-01 20:05:31 +09:00
take_cheeze 0c8bac5a38 revert wrong build_config.rb 2014-03-01 20:05:31 +09:00
take_cheeze 7e11388dc4 use g++ to link 2014-03-01 20:05:30 +09:00
take_cheeze 556afa0e44 name c++ abi build 2014-03-01 20:05:30 +09:00
take_cheeze 86831d5465 move jmpbuf_id to generated file 2014-03-01 20:05:30 +09:00
take_cheeze 1985f1ace9 fix compile error of min/max macro 2014-03-01 20:05:29 +09:00
take_cheeze 87ec2567f8 add cxx_abi travis test 2014-03-01 20:05:29 +09:00
take_cheeze 23ef20624c fix compile error 2014-03-01 20:05:29 +09:00
take_cheeze 78915f9601 support c++ exception 2014-03-01 20:05:29 +09:00
Yukihiro "Matz" Matsumoto 5ff9c1d286 Merge branch 'master' of github.com:mruby/mruby 2014-03-01 18:13:36 +09:00
Yukihiro "Matz" Matsumoto 675fd3dc80 allow send method not to call mrb_funcall if calling method is implemented in Ruby; fix #1680 ref #1765 2014-03-01 18:13:10 +09:00
Yukihiro "Matz" Matsumoto 32818bd25e should build "all" before "test"; close #1774 2014-03-01 15:20:16 +09:00
Yukihiro "Matz" Matsumoto 8e170ce915 exception in fiber should make resume to raise in parent fiber context; close #1765 2014-03-01 12:58:31 +09:00
Yukihiro "Matz" Matsumoto bed4dcb162 Merge branch 'master' of github.com:mruby/mruby 2014-03-01 10:54:01 +09:00
Yukihiro "Matz" Matsumoto 7074a55913 revert changes to mrbconf.h 2014-03-01 10:53:38 +09:00
Yukihiro "Matz" Matsumoto 5f93759158 Merge branch 'issues/comment_style' of https://github.com/cubicdaiya/mruby into cubicdaiya-issues/comment_style 2014-03-01 10:52:46 +09:00
Yukihiro "Matz" Matsumoto 203b7529b8 Merge pull request #1773 from tmash06/remove_unnecessary_gitkeep
remove unnecessary .gitkeep
2014-03-01 10:49:41 +09:00
Yukihiro "Matz" Matsumoto 78f2902c06 need to initialize flags for pooled strings; close #1768 2014-03-01 10:48:22 +09:00
Yukihiro "Matz" Matsumoto 5fb8fa5a81 add _FLAG to SET_SHARED macros; ref #1750 2014-03-01 10:26:21 +09:00
Yukihiro "Matz" Matsumoto fca90a43c7 Merge branch 'array-shared-macro' of https://github.com/ksss/mruby into ksss-array-shared-macro 2014-03-01 10:19:55 +09:00
Tatsuya Matsumoto 860773db61 remove unnecessary .gitkeep 2014-03-01 03:36:58 +09:00
cubicdaiya 67de10bfcb use C style comments instead of C++ style comments
According to CONTRIBUTING.md,

Don't use C++ style comments

 /* This is the prefered comment style */

Use C++ style comments only for temporary comment e.g. commenting out some code lines.
2014-03-01 03:31:45 +09:00
Yukihiro "Matz" Matsumoto 9b65a0d572 Merge pull request #1771 from take-cheeze/add_author
Please add me to the author.
2014-03-01 02:47:42 +09:00
take_cheeze 7ebac7e247 Please add me to the author. 2014-03-01 02:42:36 +09:00
Yukihiro "Matz" Matsumoto 2c7204fc93 mrb_fiber_yield() is available now; you have to link mruby-fiber mrbgem to use the function; there's no function available to create new fiber from C (countapart of Lua's lua_newthread), but that's because you cannot create a new fiber from C due to mruby C API design limitation. define your method to create fibers in Ruby; close #1269 2014-03-01 00:48:08 +09:00
Yukihiro "Matz" Matsumoto 1f134d723c cancel 313f6b; add fallthrough comment 2014-02-28 18:55:30 +09:00
Yukihiro "Matz" Matsumoto cb7f82ac45 Merge pull request #1756 from chasonr/sprintf-utf8
Implement sprintf("%c") for UTF-8.
2014-02-28 18:45:31 +09:00
Yukihiro "Matz" Matsumoto 6bd3d88edd support break from fiber block; fix #1766 2014-02-28 18:43:35 +09:00
chasonr d60944ef3a Test for UTF-8 as mattn suggests.
The string is "Hello world" in Japanese.  (hat tip:  Google Translate.)
2014-02-27 23:42:07 -05:00
Yukihiro "Matz" Matsumoto 03fde35760 restore proc after restoring from fiber; ref #1766 2014-02-28 12:50:32 +09:00
Yukihiro "Matz" Matsumoto 8b4660dfc7 Merge branch 'master' of github.com:mruby/mruby 2014-02-28 10:02:13 +09:00
Yukihiro "Matz" Matsumoto f5ec2115b5 swap actual and expected; ref #1764 2014-02-28 10:01:39 +09:00
Yukihiro "Matz" Matsumoto dd5ccb6cd5 Merge pull request #1763 from cubicdaiya/issues/mrb_str_new_static_bug
fix SEGV bug for mrb_str_new_static
2014-02-28 09:59:00 +09:00
ksss a14a672915 fix test for Array#[] 2014-02-28 08:50:26 +09:00
cubicdaiya 8336072e86 fix SEGV bug for mrb_str_new_static
mrb_str_new_static causes seg-fault when 3rd argument is negative.
2014-02-28 02:07:09 +09:00
Yukihiro "Matz" Matsumoto 25822f2430 Merge pull request #1762 from cubicdaiya/issues/mrb_str_new_bug
fix SEGV bug for mrb_str_new
2014-02-28 01:44:09 +09:00
cubicdaiya 30fe3f5d4b fix SEGV bug for mrb_str_new
mrb_str_new causes seg-fault when 3rd argument is negative.
2014-02-28 01:30:09 +09:00
Yukihiro "Matz" Matsumoto 90c54d1ead remove break altogether in ci loop 2014-02-28 01:25:50 +09:00
Yukihiro "Matz" Matsumoto c39e2a4e5d Merge pull request #1761 from take-cheeze/mruby-strip
Add mruby-strip tool to strip irep's debug info.
2014-02-28 00:55:11 +09:00
Yukihiro "Matz" Matsumoto 9a9548eb0e Merge pull request #1760 from cubicdaiya/issues/make_mrb_str_dump_a_bit_faster
make mrb_str_dump a bit faster
2014-02-28 00:51:54 +09:00
Yukihiro "Matz" Matsumoto 30ac4e5596 Merge pull request #1758 from ksss/array-out-while
move check condition to outside in while block
2014-02-28 00:51:33 +09:00
Yukihiro "Matz" Matsumoto ed0797418c Merge pull request #1759 from suzukaze/fix-test
Refactor tests in kernel.rb
2014-02-28 00:50:51 +09:00
Yukihiro "Matz" Matsumoto 5bd90b59a9 Merge pull request #1757 from cubicdaiya/issues/use_mrb_str_cat_lit
use mrb_str_cat_lit() intead of mrb_str_cat
2014-02-28 00:50:26 +09:00
take_cheeze 1266ab6500 add mruby-strip tool to strip irep's debug info 2014-02-28 00:36:08 +09:00
cubicdaiya a238c9c1c3 make mrb_str_dump a bit faster 2014-02-28 00:20:36 +09:00
ksss 88f3e5b294 move check condition to outside in while block 2014-02-27 23:54:36 +09:00
Jun Hiroe caa139f91a Refactor tests in kernel.rb 2014-02-27 23:49:58 +09:00
cubicdaiya bd0244d067 use mrb_str_cat_lit() intead of mrb_str_cat 2014-02-27 22:42:25 +09:00
Yukihiro "Matz" Matsumoto d1526b0409 should not continue loop when ci = NULL 2014-02-27 19:00:37 +09:00
Yukihiro "Matz" Matsumoto 56ebac0db2 Merge pull request #1751 from cubicdaiya/issues/test_for_instance_variable_defined_question
Add test for Kernel#instance_variable_defined?
2014-02-27 14:15:27 +09:00
Yukihiro "Matz" Matsumoto 524352ffbb Merge pull request #1755 from cubicdaiya/issues/add_to_me_authors
Could you add me to AUTHORS?
2014-02-27 14:14:51 +09:00
chasonr b752b01a56 Update the Fixnum#chr test for UTF-8. 2014-02-26 20:53:23 -05:00
chasonr 5e5ee841a1 Implement sprintf("%c") for UTF-8.
* sprintf("%c") is changed to accept a string for which String#size returns
  1, even if it is longer than one byte, and to convert a Fixnum via
  Fixnum#chr (possibly returning more than one byte).  Thus, if the UTF-8
  gem is in use, a character will be understood as a single UTF-8 character.

* The change to sprintf depends on the implementation of Fixnum#chr added
  to mrbgems/mruby-string-utf8/src/string.c.

This should work with any other gem that implements a multibyte encoding, as
long as it implements String#size and Fixnum#chr as appropriate.
2014-02-26 20:18:26 -05:00
cubicdaiya 83e9c45de9 Could you add me to AUTHORS? 2014-02-27 09:48:00 +09:00
Yukihiro "Matz" Matsumoto 313f6b5997 forget to break in the switch statement 2014-02-27 08:23:32 +09:00
Yukihiro "Matz" Matsumoto b31a90614d boot_defclass: super may be NULL 2014-02-27 08:21:39 +09:00
Yukihiro "Matz" Matsumoto 62071f7afe Merge pull request #1754 from pje/patch-1
Delete `!!Notice!!` intro paragraph from README
2014-02-27 07:59:44 +09:00
Patrick Ellis a75758d177 Delete !!Notice!! intro paragraph from README
It's become misleading since the release of 1.0.0 and the launch of mruby.org.
2014-02-26 14:49:51 -08:00
Yukihiro "Matz" Matsumoto 5b8229715d revert 38e9ce21 and API changed; mrb_get_backtrace() -> renamed to mrb_exc_backtrace since this is a backtrace method implementation of Exception; mrb_get_backtrace_at() -> removed; mrb_get_backtrace() -> added to get backtrace in array (like caller) 2014-02-27 04:34:30 +09:00
Yukihiro "Matz" Matsumoto 0c1c4416e7 avoid recursion when method_missing happened in inspect; fix #1746 2014-02-27 04:23:57 +09:00
Yukihiro "Matz" Matsumoto d264e1addd fix indent 2014-02-27 03:50:59 +09:00
Yukihiro "Matz" Matsumoto 38e9ce21f8 add new function mrb_get_backtrace_at() to get backtrace at ci and pc 2014-02-27 03:45:52 +09:00
Yukihiro "Matz" Matsumoto 630a152093 Merge pull request #1753 from take-cheeze/assert_rb
Compile assert.rb once.
2014-02-27 02:04:45 +09:00
ksss f1043ab85c add macro ARY_UNSET_SHARED 2014-02-27 00:11:40 +09:00
ksss 2f090879a5 add macro ARY_SET_SHARED 2014-02-27 00:10:42 +09:00
cubicdaiya 677cd22be1 add test for Kernel#instance_variable_defined? 2014-02-26 22:44:22 +09:00
Yukihiro "Matz" Matsumoto 14948710a9 Merge pull request #1752 from cubicdaiya/issues/use_mrb_str_new_lit2
Use mrb_str_new_lit instead of mrb_str_new for C string literal
2014-02-26 22:41:25 +09:00
cubicdaiya 4c283714f6 use mrb_str_new_lit instead of mrb_str_new for C string literal 2014-02-26 22:34:12 +09:00
take_cheeze 7201404ee0 compile assert.rb once 2014-02-26 22:01:31 +09:00
Yukihiro "Matz" Matsumoto cc39213856 Merge pull request #1748 from cubicdaiya/issues/optim_get_valid_iv_sym
fix bug for get_valid_iv_sym
2014-02-26 21:59:01 +09:00
Yukihiro "Matz" Matsumoto 8c949eeef0 Merge pull request #1747 from cubicdaiya/issues/use_mrb_intern_lit
use mrb_intern_lit instead of mrb_intern_cstr for C string literals
2014-02-26 21:56:59 +09:00
Yukihiro "Matz" Matsumoto bac71b482b Merge pull request #1749 from take-cheeze/file_line_test
add test for __LINE__ and __FILE__
2014-02-26 21:55:27 +09:00
Yukihiro "Matz" Matsumoto c93f873ac0 Merge pull request #1744 from cubicdaiya/feature/introduce_mrb_str_cat_lit
Introduce mrb_str_cat_lit
2014-02-26 21:54:05 +09:00
ksss 3e4e90a708 add macro ARY_SHARED_P 2014-02-26 21:40:36 +09:00
Yukihiro "Matz" Matsumoto f3476d1dcb Merge pull request #1743 from cubicdaiya/issues/use_mrb_str_new_lit
Use mrb_str_new_lit instead of mrb_str_new for C string literals
2014-02-26 21:26:47 +09:00
take_cheeze d31f824b5a add test for __LINE__ and __FILE__ 2014-02-26 21:11:33 +09:00
cubicdaiya d316115748 fix bug for get_valid_iv_sym
When sub-string is used in the following way, it does not work well.

o = Object.new
o.instance_variable_set(:@a, 1)
o.instance_variable_defined?("@abc"[0,2]) #=> false (this should be true)
2014-02-26 17:26:40 +09:00
cubicdaiya 6db2e080f0 use mrb_intern_lit instead of mrb_intern_cstr for C string literals 2014-02-26 13:48:11 +09:00
cubicdaiya a860735d0c use mrb_str_cat_lit() more widely 2014-02-26 03:03:47 +09:00
cubicdaiya 6b3801c30d introduce mrb_str_cat_lit() to create strings from C string litrals 2014-02-26 03:03:00 +09:00
cubicdaiya 94c5a5ee73 use mrb_str_new_lit instead of mrb_str_new for C string literals 2014-02-26 02:23:50 +09:00
Yukihiro "Matz" Matsumoto e203383d98 Merge pull request #1739 from take-cheeze/clang_cxx
Specialize C++ compiler in clang toolchain.
2014-02-26 01:55:36 +09:00
Yukihiro "Matz" Matsumoto 8814aedcb8 Merge pull request #1741 from suzukaze/update-readme
Update README.md; The URL of the mruby home-page is accessible.
2014-02-26 01:54:54 +09:00
Yukihiro "Matz" Matsumoto 7952e7af3c Merge pull request #1740 from tmash06/fix_missing_spaces
fix missing spaces.
2014-02-26 01:54:27 +09:00
Jun Hiroe b57d4f2e15 Update README.md; The URL of the mruby home-page is accessible. 2014-02-26 01:13:30 +09:00
Yukihiro "Matz" Matsumoto f3e9a066aa Merge branch 'master' of github.com:mruby/mruby 2014-02-26 00:10:06 +09:00
Yukihiro "Matz" Matsumoto d747ea72c4 resolve conflict 2014-02-26 00:06:58 +09:00
Tatsuya Matsumoto fd903c1f38 fix missing spaces. 2014-02-26 00:06:23 +09:00
take_cheeze 043e7fc6bd specialize C++ compiler in clang toolchain 2014-02-25 22:42:12 +09:00
Yukihiro "Matz" Matsumoto feeaea8dcd Merge pull request #1737 from chasonr/Random-static-data
Implement default Random instance.
2014-02-25 19:16:01 +09:00
Yukihiro "Matz" Matsumoto 501f7ab25d Merge pull request #1738 from cubicdaiya/issues/optim_mrb_time_zone
small-optimization for mrb_time_zone
2014-02-25 19:13:44 +09:00
cubicdaiya 96c24b0a37 small-optimization2 for mrb_time_zone
mrb_str_new_static is more efficient than mrb_str_new in this case.
2014-02-25 15:24:02 +09:00
cubicdaiya 985e4892cf small-optimization for mrb_time_zone
Using mrb_str_new instead of mrb_str_new_cstr
2014-02-25 15:03:35 +09:00
chasonr 7c9ff7c8ff Implement default Random instance.
Previously, the default random number generator was implemented using static
storage.  This storage is common to all instances of mruby in a process, and
use of the default random number generator in one instance will perturb the
default random number generator in other instances.  It is also not thread
safe.

With this change, the default random number generator is defined as
Random::DEFAULT, as it is in CRuby.
2014-02-25 00:06:31 -05:00
Tomoyuki Sahara f7c054bd39 quiet compiler. 2014-02-25 12:28:34 +09:00
Tomoyuki Sahara e8706d4ee7 remove unused. 2014-02-25 12:23:15 +09:00
Tomoyuki Sahara b9dff44582 Merge branch 'master' of github.com:iij/mruby-io 2014-02-25 12:20:52 +09:00
Tomoyuki Sahara 56a8c592dd add IO.read 2014-02-25 12:19:52 +09:00
Yukihiro "Matz" Matsumoto 05d3b9de54 clarify fallthrough in the switch statement 2014-02-25 10:48:10 +09:00
Yukihiro "Matz" Matsumoto ebd976be84 initialize sname before interning 2014-02-25 10:43:16 +09:00
Yukihiro "Matz" Matsumoto b201dbeb3d Merge pull request #1736 from take-cheeze/doc_update
add ruby and C code execution order note
2014-02-25 07:52:00 +09:00
take_cheeze f59636304a add ruby and C code execution order note 2014-02-25 03:32:14 +09:00
Yukihiro "Matz" Matsumoto de0af73c24 Merge pull request #1732 from cho45/depend-build-config
Always include build_config.rb to compile dependency.
2014-02-25 02:20:13 +09:00
Yukihiro "Matz" Matsumoto e86ce92066 Merge pull request #1733 from take-cheeze/mrb_stringize
add MRB_ prefix to STRINGIZE macro
2014-02-25 02:19:16 +09:00
Yukihiro "Matz" Matsumoto 303b955ba8 Merge pull request #1734 from kyab/add_galileo_config
Add target example for Intel Galileo board
2014-02-25 02:18:59 +09:00
Yukihiro "Matz" Matsumoto ad40f32d57 Merge pull request #1735 from h2so5/limit-significand-length
limit preserved significand length
2014-02-25 02:18:34 +09:00
Yukihiro "Matz" Matsumoto c636386953 avoid accessing uninitialized string; ref ac936fc 2014-02-25 00:47:02 +09:00
Yukihiro "Matz" Matsumoto ddf9504558 Merge pull request #1721 from take-cheeze/d_format_spec
add 'd' format specifier in mrb_get_args and mruby-random gem improvement
2014-02-25 00:22:27 +09:00
kyab 70935f9979 Add target example for Intel Galileo board 2014-02-24 23:16:02 +09:00
take_cheeze faad3e2ecd add MRB_ prefix to STRINGIZE macro 2014-02-24 23:13:21 +09:00
Yukihiro "Matz" Matsumoto 2f9cf26ab5 Merge pull request #1731 from jeremyong/master
Issue minor corrections and updates to INSTALL file.
2014-02-24 18:01:46 +09:00
Yukihiro "Matz" Matsumoto a26867f595 Merge pull request #1730 from bggd/patch-3
Add error for C99 style variable declaration on travis-ci
2014-02-24 17:59:58 +09:00
cho45 03b1b62bde Always include build_config.rb to compile dependency.
build_config.rb modifies `cc.defines` (eg. `DISABLE_GEMS`) so files depending on such flags should be rebuilt.

Ref. (Failing scenario): https://gist.github.com/cho45/9181191
2014-02-24 12:01:54 +09:00
Jeremy Ong 6fb75460c1 Issue minor corrections and updates to INSTALL file. 2014-02-23 18:33:26 -08:00
Tomoyuki Sahara a90d8b8a73 add Socket.getaddrinfo. 2014-02-24 11:21:49 +09:00
bggd 7c716de723 add -Werror=declaration-after-statement 2014-02-24 11:13:48 +09:00
bggd 3ff4af91a2 remove -Werror=declaration-after-statement 2014-02-24 11:08:23 +09:00
h2so5 f025e4961d limit preserved significand length 2014-02-24 08:21:10 +09:00
Yukihiro "Matz" Matsumoto 109f675f44 Merge pull request #1727 from bggd/patch-2
Add warning for C89-style variable declarations
2014-02-24 01:41:27 +09:00
Yukihiro "Matz" Matsumoto 8b29f0d9c1 Merge pull request #1729 from take-cheeze/customizable_build_dir
Make mruby build directory customizable.
2014-02-24 01:41:06 +09:00
Yukihiro "Matz" Matsumoto 37348c296e Merge pull request #1728 from kyab/fix_unused_error_mirb
Fix unused function warning when readline enabled (mirb)
2014-02-23 21:00:52 +09:00
take_cheeze 9059b9a354 support custom build_dir in CrossBuild 2014-02-23 20:50:51 +09:00
kyab 1cf619d3b4 Fix unused function warning when readline enabled (mirb) 2014-02-23 20:43:43 +09:00
Yukihiro "Matz" Matsumoto 46ee883574 move declaration to the top of the block; ref #1727 2014-02-23 20:41:15 +09:00
take_cheeze dd68ea9799 make mruby build directory customizable 2014-02-23 20:35:06 +09:00
bggd 15b484df38 Add warning for C89-style variable declarations 2014-02-23 16:08:56 +09:00
Yukihiro "Matz" Matsumoto e202d4cd53 add src/error.h for compatibility reason 2014-02-22 23:38:59 +09:00
Akira Yumiyama d28f042118 compatibility support (mruby/mruby, iij/mruby and 1.0.0)
- refs https://github.com/mruby/mruby/commit/36e234aa377d50d8ee425c7868e0651cf78e85cf
2014-02-22 20:45:07 +09:00
Yukihiro "Matz" Matsumoto e8daace8f1 Merge pull request #1724 from h2so5/f2s-significand
preserve significands in float-string conversion
2014-02-22 18:06:27 +09:00
h2so5 b0e3b873f5 preserve significands in float-string conversion 2014-02-22 16:50:52 +09:00
Yukihiro "Matz" Matsumoto ac936fc211 powered num may be infinite in float-string conversion 2014-02-22 11:06:38 +09:00
Yukihiro "Matz" Matsumoto 6b6c590fe3 Merge pull request #1722 from take-cheeze/hash_ext_arena_fix
Fix possible arena overflow in mruby-hast-ext.
2014-02-22 10:55:04 +09:00
Yukihiro "Matz" Matsumoto 96e806ff05 Merge pull request #1723 from akuroda/string_test_cap_down
add tests for String#capitalize!, String#downcase!, and String#upcase!
2014-02-22 10:51:13 +09:00
Akira Kuroda 61523d0e4f fix the position of capitalize! and downcast!, and add test for upcase! 2014-02-22 00:43:12 +09:00
take_cheeze 658b4f4ea7 add test(requires MRB_GC_FIXED_ARENA enabled) 2014-02-22 00:28:38 +09:00
Akira Kuroda f6516526b5 add tests for String#capitalize! and String#downcase! 2014-02-22 00:19:29 +09:00
take_cheeze a9af8c9c07 fix possible arena overflow 2014-02-22 00:05:05 +09:00
take_cheeze f863025bd6 use 'd' format spec to get Random object 2014-02-21 17:36:58 +09:00
take_cheeze 8060478b3c add 'd' format specifier to get data pointer directly from mrb_get_args 2014-02-21 17:29:49 +09:00
take_cheeze d345134fb8 use mrb_intern_lit in mruby-random 2014-02-21 17:07:48 +09:00
Yukihiro "Matz" Matsumoto 36e234aa37 Merge pull request #1720 from take-cheeze/move_error_h
move src/error.h to include/mruby/error.h
2014-02-21 11:02:36 +09:00
take_cheeze 08ea324593 move src/error.h to include/mruby/error.h 2014-02-20 22:41:29 +09:00
Yukihiro "Matz" Matsumoto 66ecd159d3 Merge pull request #1719 from pbosetti/master
Added spaces in version.h macros for complying with C++11
2014-02-18 21:35:56 +09:00
cremno 61577e8d6b mrb_flo_to_str: internal linkage 2014-02-18 04:37:35 +01:00
Paolo Bosetti 0b603baa53 Added spaces in version.h macros for complying with C++11 2014-02-17 17:54:49 +01:00
Yukihiro "Matz" Matsumoto 800d992987 Merge pull request #1717 from cremno/iv_size-t-null
iv_size (non-seglist): return 0 if t is NULL
2014-02-18 00:30:07 +09:00
cremno 69bc004e08 iv_size (non-seglist): return 0 if t is NULL 2014-02-17 12:39:56 +01:00
cremno 1838099e00 more mrb_flo_to_str fixes
- remove float check (take mrb_float instead of mrb_value)
- support -0.0
- fix range error if log10 is called when n == 0.0
- MSVC older than 2013: add signbit macro (for double)
2014-02-17 12:37:39 +01:00
Yukihiro "Matz" Matsumoto 57b7f6b619 use double instead of mrb_float (that may be single precision float) to reduce errors 2014-02-17 10:20:58 +09:00
Yukihiro "Matz" Matsumoto eacdcc13d8 remove trailing zeros from float string representation 2014-02-17 10:11:51 +09:00
Yukihiro "Matz" Matsumoto a740b28b52 define FLO_EPSILON depends on float/double 2014-02-17 09:47:39 +09:00
Yukihiro "Matz" Matsumoto 4b981adc58 remove max_digit from mrb_flo_to_str() 2014-02-17 09:40:30 +09:00
Yukihiro "Matz" Matsumoto ffe541b503 small refactoring; direct return 2014-02-17 09:35:20 +09:00
Yukihiro "Matz" Matsumoto 25ea4d751b use powf() instead of pow() on MRB_USE_FLOAT 2014-02-17 09:34:56 +09:00
Yukihiro "Matz" Matsumoto b4bc395680 fdigit may be negative due to error if mrb_float is 32bit (e.g. 10**36 on 32bit arch); ref #1713 #1714 2014-02-17 09:27:53 +09:00
Yukihiro "Matz" Matsumoto 09080fd2ee Merge pull request #1714 from h2so5/f2s
fix mrb_flo_to_str() exponent problem
2014-02-17 07:57:12 +09:00
h2so5 db80a9a2ce fix mrb_flo_to_str() exponent problem 2014-02-17 07:53:02 +09:00
Yukihiro "Matz" Matsumoto 41a77111ea Merge pull request #1710 from takkaw/flo_to_str
modify mrb_to_str() in order to display big float number
2014-02-16 01:33:43 +09:00
Yukihiro "Matz" Matsumoto e29efb02bd normalize NaN after division that may generate NaN; fix #1712 2014-02-15 19:59:26 +09:00
takkaw 0a48fb0407 modify mrb_to_str() in order to display big float number 2014-02-15 15:40:51 +09:00
Yukihiro "Matz" Matsumoto 8b93f8591d Merge pull request #1709 from cubicdaiya/issues/nonvoid
Give the type 'void' to functions have no argument.
2014-02-15 13:25:41 +09:00
cubicdaiya 3d716f2376 Give the type 'void' to functions have no argument.
According to the C standard,
it is desirable to give the type 'void'
to functions have no argument.
2014-02-14 19:47:15 +09:00
Yukihiro "Matz" Matsumoto 7586d474b5 Merge pull request #1707 from Fleurer/issue1706
keep stack with nlocals instead of nregs; fix #1706
2014-02-14 17:06:43 +09:00
Yukihiro "Matz" Matsumoto 007ed07e77 Merge pull request #1708 from Fleurer/cleanup-warning-hash-dup
cleanup warnings in hash.c
2014-02-14 17:04:21 +09:00
Li Yazhou 7ab0506795 add test for Hash#dup 2014-02-14 13:26:19 +08:00
Li Yazhou adbf1eba99 clearn up warning in hash.c
/home/fleuria/code/mruby/src/hash.c:159:1: warning: ‘mrb_hash_dp`defined but not used [-Wunused-function]
 mrb_hash_dup(mrb_state *mrb, mrb_value hash)
     ^

this commit defines Hash#dup to take advantage of mrb_hash_dup, however
it seems that Hash#dup is not in ISO standard.
2014-02-14 13:22:30 +08:00
Li Yazhou 876e7de7ec add a regression test for #1706 2014-02-14 11:32:59 +08:00
Li Yazhou 9ebfeac111 keep stack with nlocals instead of nregs; fix #1706 2014-02-14 11:16:56 +08:00
Tomoyuki Sahara 7fd585bae1 support older version. 2014-02-14 10:36:37 +09:00
Yukihiro "Matz" Matsumoto ba8a8e75c7 Merge pull request #1702 from cremno/hash-hash-ext-changes
hash / hash-ext: various small changes
2014-02-14 01:29:19 +09:00
Yukihiro "Matz" Matsumoto 69eaaa146c Merge pull request #1705 from takahashim/version-number
MRUBY_VERSION should be only numbers separated by dot, like JRUBY_VERSION or Rubinius::VERSION
2014-02-14 01:27:05 +09:00
Yukihiro "Matz" Matsumoto 9ad55617c3 Merge pull request #1703 from cremno/parenthesize-mrbdump-errnos
dump.h: parenthesize negative errnos
2014-02-14 01:26:13 +09:00
Yukihiro "Matz" Matsumoto bc8c803990 Merge pull request #1704 from cremno/rm-mrb_str_literal-decl
remove mrb_str_literal declaration
2014-02-14 01:25:54 +09:00
Yukihiro "Matz" Matsumoto 22d5102504 Merge pull request #1701 from cremno/do-not-use-mrb_str_cat2
mrb_str_cat2: deprecated since 0cedf8f
2014-02-14 01:25:17 +09:00
takahashim ac4443879a MRUBY_VERSION should be only numbers separated by dot, like JRUBY_VERSION or Rubinius::VERSION 2014-02-13 22:19:42 +09:00
cremno 8bbc2c107b mrb_str_cat2: deprecated since 0cedf8f 2014-02-13 13:45:28 +01:00
cremno 5a76288f3f remove mrb_str_literal declaration
definition was removed in 677a2ac
2014-02-13 13:39:44 +01:00
cremno e8945b8598 dump.h: parenthesize negative errnos 2014-02-13 13:39:22 +01:00
cremno 4ffea85b62 hash / hash-ext: various small changes
src/hash.c:
 - mrb_hash_(aget|aset|dup|delete): internal linkage
 - remove documentation of methods which are not implemented (in here)
 - remove #assoc; unused, not in ISO spec
 - remove #rassoc: same, implementation is also wrong

hash-ext mrbgem:
 - remove header "mruby/khash.h"
 - remove mrb_hash_values_at (move code into hash_values_at, i: long -> int)
 - less whitespace in gem_init function
2014-02-13 13:39:09 +01:00
Yukihiro "Matz" Matsumoto 7a32c7b183 remove direct inclusion of mruby/version.h from version.c; #1698 2014-02-13 00:45:56 +09:00
Tomoyuki Sahara daa65c15de add dummy IO#flush for better compatibility with CRuby. 2014-02-12 16:33:34 +09:00
Tomoyuki Sahara 40c52f58d0 Merge pull request #9 from matsumoto-r/support_mrb_get_module
Support mrb_module_get
2014-02-12 10:57:58 +09:00
Tomoyuki Sahara 50ef284015 include mruby/version.h in mruby.h 2014-02-12 10:26:19 +09:00
Yukihiro "Matz" Matsumoto 26781692b7 Merge pull request #1697 from cremno/array-changes
array implementation: several small changes
2014-02-12 09:31:28 +09:00
Yukihiro "Matz" Matsumoto 4558b29719 Merge pull request #1694 from cremno/rakefile-mkdir-bin-path
Rakefile: make bin directory
2014-02-12 09:28:50 +09:00
Yukihiro "Matz" Matsumoto 67d63387ee Merge pull request #1695 from cremno/clang-and-icl-define-direct-threaded
Clang and ICC/ICL: define DIRECT_THREADED
2014-02-12 09:28:12 +09:00
Yukihiro "Matz" Matsumoto 8e78db3af3 Merge pull request #1693 from cremno/mruby-math-rm-cygwin-compat
mruby-math: remove Cygwin compatibility macros
2014-02-12 09:27:41 +09:00
cremno 7691b64963 array implementation: several small changes
src/array.c:
 - make various functions without declaration in the mruby headers static
 - removed all uncessary int casts and two useless comments
 mrb_ary_new_from_values: move to similar functions
 mrb_check_array_type: fix indentation

include/mruby/array.h:
 mrb_shared_array: padding (default "mrbconf.h" on an usual 64-bit system)
                   sizeof(mrb_int)==sizeof(int)==4 && sizeof(mrb_value*)==8

both:
 mrb_ary_aget:  remove declaration in header and make static
                nobody uses it which is not surprising since it has 1 req arg!
 mrb_assoc_new: small optimization and move to similar functions
 mrb_ary_len:   re-implement as static inline function (it is used by mrbgems)
                programmers should directly use RARRAY_LEN instead
2014-02-12 00:37:47 +01:00
cremno d1f474c239 Rakefile: make bin directory 2014-02-12 00:04:42 +01:00
cremno b7899aa6ee mruby-math: remove Cygwin compatibility macros
nan:
 The first non-test release of Cygwin 1.5.x was over a decade ago:
 <http://cygwin.com/ml/cygwin-announce/2003-09/msg00001.html>

log/log10:
 This workaround is not needed anymore (1.2.6.1, 1.3 - both over 6 years ago):
 <https://sourceware.org/cgi-bin/cvsweb.cgi/src/newlib/libm/math/w_log.c?cvsroot=src>
2014-02-12 00:03:12 +01:00
cremno 8a3a3a5a49 Clang and ICC/ICL: define DIRECT_THREADED
This is most likely only needed on Windows be-
cause __GNUC__ is not defined by both compilers.

It might fail with some unusual configurations.
If that is the case, feel free to open an issue.
2014-02-11 23:55:52 +01:00
Paolo Bosetti ee2859de6e Updated mrb_include_module call after mruby 1.0.0 2014-02-11 14:54:30 +01:00
Yukihiro "Matz" Matsumoto 27dbcd0f0d add RUBY_ENGINE; ref #576 2014-02-11 15:37:03 +09:00
Tomoyuki Sahara b3c6075dc5 IO._bless has gone.
https://github.com/iij/mruby-io/commit/b74458a486042f4863fa6362057e25f0997694f5
2014-02-10 09:51:24 +09:00
Yukihiro "Matz" Matsumoto d7960bf2a9 resolve conflict in travis_config.rb 2014-02-10 09:50:32 +09:00
Tomoyuki Sahara b74458a486 remove _bless trick. closes #8. 2014-02-10 09:49:37 +09:00
Yukihiro "Matz" Matsumoto 5519bd69bc Merge pull request #1692 from Paxa/Kernel_global_variables
Fix Kernel#global_variables for $1-$9
2014-02-10 09:34:53 +09:00
Pavel 411168deab Fix Kernel#global_variables for $1-$9 2014-02-09 23:54:49 +07:00
Yukihiro "Matz" Matsumoto 00bdaec766 initialize ci->stackent at the top; #1691 2014-02-09 19:20:16 +09:00
Yukihiro "Matz" Matsumoto ee0b7d150b Merge branch 'original2' of https://github.com/miura1729/mruby into miura1729-original2 2014-02-09 18:37:20 +09:00
Yukihiro "Matz" Matsumoto 19a08b8455 Merge pull request #1674 from cremno/mrb_bool-FALSE-TRUE
use mrb_bool, FALSE and TRUE more
2014-02-09 18:35:20 +09:00
Miura Hideki 5df82e357c Store raw stack address in callinfo instead of offset from stbas 2014-02-09 16:42:25 +09:00
MATSUMOTO Ryosuke 526608c8a2 Support mrb_module_ge 2014-02-08 17:38:41 +09:00
Yukihiro "Matz" Matsumoto d8a5f12053 forget to add function prototypes 2014-02-08 13:56:15 +09:00
Yukihiro "Matz" Matsumoto b35893ee13 Merge pull request #1689 from Bovi-Li/remove-notice
Remove *very early version* notice
2014-02-08 13:53:41 +09:00
Yukihiro "Matz" Matsumoto 0947aefa23 Merge pull request #1690 from bovi/patch-2
Add download link for stable version to README
2014-02-08 13:53:20 +09:00
Yukihiro "Matz" Matsumoto 4a2c37df93 made mrb_define_class to return existing class, with heavy refactoring 2014-02-08 13:44:31 +09:00
Yukihiro "Matz" Matsumoto 5da7bd3a91 rename mrb_name_class and make it static 2014-02-08 10:20:23 +09:00
Daniel Bovensiepen cd5677ea72 Add download link for stable version to README
- add download link of stable version 1.0.0
- remove remark for mruby branch due to non-existence
2014-02-08 03:26:22 +08:00
Daniel Bovensiepen 5056a29d93 Remove notice of early version 2014-02-08 03:06:05 +08:00
Yukihiro "Matz" Matsumoto 56b5356f6b add MRUBY_RELEASE info in numbers 2014-02-07 16:57:17 +09:00
Yukihiro "Matz" Matsumoto 95e2be6508 forgot to add new files 2014-02-07 12:24:24 +09:00
Yukihiro "Matz" Matsumoto 3ff9aad22f move version info from gems to core; ref #576 #1684 2014-02-07 12:18:55 +09:00
Yukihiro "Matz" Matsumoto c3f02afa21 Merge pull request #1688 from cubicdaiya/issues/unnecessary_semicolon
Remove unnecessary semicolon
2014-02-06 21:16:24 +09:00
cubicdaiya 360d92dc28 remove unnecessary semicolon 2014-02-06 19:05:45 +09:00
Yukihiro "Matz" Matsumoto 7ba4612956 use mrb_str_new_lit() more widely 2014-02-06 08:54:47 +09:00
Yukihiro "Matz" Matsumoto ed1bf9aa80 introduce mrb_str_new_lit() to create strings from C string litrals 2014-02-06 07:50:34 +09:00
MATSUMOTO Ryosuke 2e564153ac Fix MRUBY_BIRTH_YEAR 2014-02-05 23:58:08 +09:00
MATSUMOTO Ryosuke dadf06f72b Add global constant MRUBY_COPYRIGHT 2014-02-05 23:54:15 +09:00
MATSUMOTO Ryosuke 456a765e53 replace Kernel.show_version with MRUBY_DESCRIPTION 2014-02-05 22:17:44 +09:00
MATSUMOTO Ryosuke 6c91ba001f Fix release date 2014-02-05 21:17:00 +09:00
MATSUMOTO Ryosuke e0c10d03da Add pluggable versioning by mruby-version 2014-02-05 18:45:09 +09:00
Yukihiro "Matz" Matsumoto 6bcc780261 Merge pull request #1683 from take-cheeze/gem_flags_after_libraries
Pass forgotten variable gem_flags_after_libraries to tool's linker.run.
2014-02-04 23:07:39 -08:00
take_cheeze 2e20232daf pass gem_flags_after_libraries 2014-02-05 14:22:19 +09:00
Yukihiro "Matz" Matsumoto 5172f4797f add RUBY_VERSION to notify syntax compatible version 2014-02-05 13:27:30 +09:00
Yukihiro "Matz" Matsumoto 565e1f6ef2 disable LocalJumpError test since the code causes SyntaxError (not LocalJumpError) on CRuby 2014-02-05 12:58:01 +09:00
Yukihiro "Matz" Matsumoto 04eb577b69 Fiber.new{break} caused SEGV 2014-02-05 12:51:17 +09:00
Yukihiro "Matz" Matsumoto be0cc4f90e better codedump format 2014-02-04 23:04:34 +09:00
Yukihiro "Matz" Matsumoto 89e7402526 Merge pull request #1682 from mattn/remove_warning
Remove warning
2014-02-04 05:33:53 -08:00
mattn c850372029 Remove warning 2014-02-04 18:12:35 +09:00
Yukihiro "Matz" Matsumoto 857e384187 fibers cannot cross C function boundary; close #1680 2014-02-04 14:01:22 +09:00
Yukihiro "Matz" Matsumoto 33bb4578a2 Merge pull request #1678 from iij/float-nan-p
add Float#nan?
2014-02-02 23:39:00 -08:00
Tomoyuki Sahara 7bf63c2876 add Float#nan? 2014-02-03 15:18:52 +09:00
Tomoyuki Sahara f10b73efa7 move license terms to the bottom. 2014-02-03 12:35:02 +09:00
Yukihiro "Matz" Matsumoto 857e3cfa7c Merge pull request #1675 from h2so5/node-splat-codegen
fix NODE_SPLAT codegen
2014-01-31 20:30:18 -08:00
h2so5 b53d91e6e2 fix NODE_SPLAT codegen 2014-02-01 12:22:28 +09:00
Yukihiro "Matz" Matsumoto e12250032f Merge pull request #1673 from cremno/rework-objspace-gc
rework mruby-objectspace and gc.[ch]
2014-01-31 09:08:45 -08:00
cremno 4507985c3e use mrb_bool, FALSE and TRUE more
It doesn't matter to me if one is using FALSE/TRUE instead of 1/0
but I prefer a type (alias) which emphasizes boolean vars to int.
I changed 1/0 to FALSE/TRUE anyway.
2014-01-31 18:00:36 +01:00
cremno a2cfc9a9af rework mruby-objectspace and gc.[ch]
- functions should have C linkage (for C++ code)
- add prefix to each_object_callback
- use more appropriate variable types / initialization
- ObjectSpace::count_objects has 1 opt. arg.
- prefer mrb_intern_lit to mrb_intern_cstr for str. lit.
- mruby/value.h is included by mruby.h
- adjust coding style
2014-01-31 17:42:05 +01:00
Yukihiro "Matz" Matsumoto 7c9a1accff remove conflict 2014-01-31 17:09:04 +09:00
Yukihiro "Matz" Matsumoto 6cf42a8200 Merge pull request #1671 from cremno/extern-cleanup
clean up external symbols
2014-01-31 00:03:28 -08:00
Yukihiro "Matz" Matsumoto 4e2a9509dc Merge pull request #1669 from cremno/copyright-2014
update copyright year
2014-01-31 00:01:09 -08:00
Yukihiro "Matz" Matsumoto 210e7b668e Merge pull request #1668 from cremno/etc-c-cleanup
etc.c: small cleanup
2014-01-31 00:00:41 -08:00
Yukihiro "Matz" Matsumoto 4c9c466ba3 Merge pull request #1670 from cremno/remove-mrb_str_format-declaration
remove mrb_str_format declaration
2014-01-30 23:59:37 -08:00
h2so5 650ffb9d84 reindent parse.y 2014-01-31 11:30:58 +09:00
cremno bb25d42d0d add missing declaration of mrb_str_format 2014-01-31 01:34:20 +01:00
cremno f2a62a74ed clean up external symbols
remove unused and unneeded:
- sysexit_status
- type (a global variable)

add mrb_ prefix to:
- codedump_all
- class_instance_method_list
- parser_dump

make various functions static, incl.:
- yyparse
- make_exception
2014-01-31 01:30:18 +01:00
cremno eaf445ea5c mruby.h: remove mrb_str_format declaration
The function mrb_str_format is only defined when the mrbgem mruby-sprintf was
activated. That might not always be the case (by default it currently is).
mrb_str_format still has external linkage, so from now on mrbgem authors
have to declare it in their source code if they want or need to call it.
2014-01-30 23:50:18 +01:00
cremno 3ee946dab4 Happy new year! (update copyright year)
Let's not wait until May this time
(f0a9b95af3)!
2014-01-30 23:17:24 +01:00
cremno d90f52f552 etc.c: small cleanup (delete unused functions)
mrb_data_object_alloc: unnecessary cast
mrb_lastline_get: mruby doesn't support $_, weird and unused code
mrb_exec_recursive: see 4e46abb869
mrb_block_proc: unused, doesn't really do anything (or needs to be
rewritten)
mrb_obj_to_sym: actually use id (and MSVC detected unreachable code)
2014-01-30 23:16:46 +01:00
Yukihiro "Matz" Matsumoto a68a517028 refactor parser lineno adjustment; ref #1667 2014-01-31 00:49:46 +09:00
Yukihiro "Matz" Matsumoto dd70ae0b6e add semicolon after the statements 2014-01-30 22:08:31 +09:00
Yukihiro "Matz" Matsumoto 5815ac4fed Merge pull request #1667 from h2so5/backtrace-lineno
more accurate backtrace lineno
2014-01-30 03:53:03 -08:00
Yukihiro "Matz" Matsumoto aa08158f67 Array#[]= is now range aware 2014-01-30 10:50:56 +09:00
Yukihiro "Matz" Matsumoto 0006278088 move Array#[] tests from mrbgems to test/t/array.rb 2014-01-30 10:33:47 +09:00
h2so5 36e0925053 more accurate backtrace lineno 2014-01-30 10:08:04 +09:00
Yukihiro "Matz" Matsumoto 5346bdd76b move range aware aget to array.c from mruby-array-ext gem 2014-01-29 14:53:38 +09:00
Yukihiro "Matz" Matsumoto b69bb896fc Merge pull request #1664 from h2so5/clone-class-module
clone Class/Module rightly
2014-01-25 04:55:07 -08:00
h2so5 25045345c9 clone Class/Module rightly 2014-01-25 07:47:15 +09:00
Yukihiro "Matz" Matsumoto e0e5aebc66 add callback invocation from OP_DEBUG 2014-01-23 15:08:38 +09:00
Yukihiro "Matz" Matsumoto 92570a96b0 add enable_debug to build_config.rb 2014-01-23 14:25:54 +09:00
Yukihiro "Matz" Matsumoto 68f33d220b Merge pull request #1663 from h2so5/fix-utf8-codepage
fix utf8 codepage
2014-01-22 19:22:36 -08:00
h2so5 1717666662 fix utf-8 codepage 2014-01-23 03:38:54 +09:00
Yukihiro "Matz" Matsumoto 33dc9615d4 Merge pull request #1662 from h2so5/fix-string-inspect
escape non-ascii characters correctly in String#inspect
2014-01-22 05:53:19 -08:00
h2so5 a030cab7d1 escape non-ascii characters correctly in String#inspect 2014-01-21 21:36:59 +09:00
Yukihiro "Matz" Matsumoto b3f8f8a5b0 describe call stack overwritten problem of mrb_get_backtrace; close #1661 2014-01-21 17:12:14 +09:00
Yukihiro "Matz" Matsumoto 4a12d351bb Merge pull request #1659 from carsonmcdonald/threestructtests
Increase test coverage of mruby-struct
2014-01-16 16:46:55 -08:00
Carson McDonald d3a057caed Increase test coverage of mruby-struct 2014-01-16 17:54:56 -05:00
Yukihiro "Matz" Matsumoto 38973f1566 Merge branch 'master' of github.com:mruby/mruby 2014-01-16 21:34:04 +09:00
Yukihiro "Matz" Matsumoto c7cff199dc hash value of enumerable should be obtained from its elements; close #1658 2014-01-16 21:33:48 +09:00
Yukihiro "Matz" Matsumoto 4de72f1870 hash value of enumerable should be obtained from its elements; close #1658 2014-01-16 21:32:08 +09:00
Paolo Bosetti a2af349959 Now the drive letter is returned as leading path element by File#dirname on Windows 2014-01-13 17:29:57 +01:00
Tomoyuki Sahara b744097511 Merge pull request #6 from schmurfy/testless
removed mtest dependency
2014-01-09 16:09:50 -08:00
Paolo Bosetti a613bce3f2 Merge branch 'master' of https://github.com/iij/mruby-io 2014-01-07 13:51:38 +01:00
Tomoyuki Sahara 8cee36b1b5 Catch Errno::ENFILE too.
When system file descriptor table is full, errno is set to
ENFILE instead of EMFILE.  They are similar but different.
2013-12-13 15:49:32 +09:00
Paolo Bosetti 23afaf02dc Made compatible with VisualStudio 2013-12-10 14:34:26 +01:00
Julien Ammous a26ce35c64 removed mtest dependency 2013-12-04 20:51:27 +01:00
Tomoyuki Sahara d12f436bdb mrb_intern API change. 2013-12-03 10:07:29 +09:00
Paolo Bosetti 5a59fd3a5c Fix for compilation under Win/MinGW 2013-12-02 12:14:04 +01:00
Tomoyuki Sahara e641e9a380 suppress a compiler warning. 2013-11-20 12:14:54 +09:00
Tomoyuki Sahara 2245818f91 make it more portable. 2013-11-20 12:13:34 +09:00
Tomoyuki Sahara 78d2d909cf style 2013-11-20 10:26:13 +09:00
fleuria 05fb139d28 add a comment for enable_bintest in build_config.rb 2013-11-16 15:13:58 +08:00
fleuria 50c029f09d enable bintest for travis CI 2013-11-16 15:05:21 +08:00
fleuria 14429ef268 add regression for #1563 2013-11-16 15:05:21 +08:00
fleuria 995e0f89cf add regression for #1572 2013-11-16 15:05:15 +08:00
Tomoyuki Sahara 87d878292d Try GC when Too many open files (revert a part of 1e8097a). 2013-11-16 16:04:31 +09:00
fleuria 2d646a13f7 add regression for #1564 2013-11-16 14:32:43 +08:00
fleuria 06914f607c add conf.enable_bintest and run_bintest 2013-11-16 14:26:38 +08:00
fleuria 1404d491d2 add test/bintest.rb 2013-11-16 14:25:57 +08:00
fleuria 0a4010728a make test/assert.rb cruby compatible 2013-11-16 14:22:15 +08:00
Tomoyuki Sahara e44da8a6cc test for #6. 2013-11-16 05:44:04 +09:00
Tomoyuki Sahara 1e8097a4b8 IO.sysopen raises an exception when open(2) fails. closes #6. 2013-11-16 05:14:07 +09:00
Tomoyuki Sahara e96cdeb2af Merge pull request #3 from h2so5/patch-1
avoid declaration error on VC++
2013-11-05 18:31:15 -08:00
h2so5 db14b8e7d4 avoid declaration error on VC++ 2013-11-06 11:25:33 +09:00
Tomoyuki Sahara d8e5e7df3f Merge pull request #3 from murasesyuka/feature/add_dependencies_gem
add mruby-socket dependency gems
2013-11-03 00:41:21 -07:00
murase_syuka 78ebe1b427 add mruby-socket dependency gems 2013-11-02 14:30:42 +09:00
Tomoyuki Sahara 823df14ff4 remove unused code and irrelevant comment. 2013-10-15 10:43:48 +09:00
Tomoyuki Sahara ec443d45db more IPPROTO_* related to IPv6. 2013-10-10 10:24:02 +09:00
Tomoyuki Sahara 93edd26b3e fix typo... 2013-10-09 00:35:22 +09:00
Tomoyuki Sahara 005f01f2fc fix RSTRING_PTR usage. 2013-10-03 12:18:39 +09:00
Tomoyuki Sahara bf4c226232 Merge pull request #4 from pbosetti/master
Truncate the file to zero length on opening when "w" mode is set
2013-10-02 17:08:24 -07:00
Paolo Bosetti c608c26ab4 Merge branch 'master' of https://github.com/iij/mruby-io 2013-10-02 13:05:12 +02:00
Paolo Bosetti 49494a7367 Truncate file on File.open(file, "w") 2013-10-02 13:01:56 +02:00
Tomoyuki Sahara 8b48e2b4a4 syswrite must write to fd2 if it is properly set.
closes #3.
2013-09-30 11:56:15 +09:00
Tomoyuki Sahara 97899a6922 style 2013-09-30 11:18:22 +09:00
Tomoyuki Sahara adb3bd6698 don't retry when we cannot fork(2).
EAGAIN indicates the system is under heavy load.
Retrying make things worse.
2013-09-30 10:55:09 +09:00
Tomoyuki Sahara d75d23294d fix descriptor leakage. 2013-09-30 10:36:29 +09:00
Tomoyuki Sahara b4f0a68fba add File#flock. 2013-09-30 10:17:21 +09:00
Tomoyuki Sahara 140da1c6ca remove duplicated white spaces. 2013-09-26 18:31:02 +09:00
Tomoyuki Sahara e27fb544df suppress a warning and fix a possible segv. 2013-09-26 10:59:40 +09:00
Tomoyuki Sahara e2b0606752 Merge pull request #2 from pbosetti/master
Catch up with API changes on mrb_intern() -> mrb_intern_cstr()
2013-09-25 18:21:27 -07:00
Paolo Bosetti c4e3c46e86 Catch up with API changes on mrb_intern() -> mrb_intern_cstr() 2013-09-25 13:26:49 +02:00
Tomoyuki Sahara 47a610e688 use array parameter on IO.open. 2013-08-30 19:09:36 +09:00
Tomoyuki Sahara 713aa48cf9 STDERR's file descriptor is 2.
closes #1
2013-08-30 17:04:40 +09:00
Tomoyuki Sahara 9dc875f246 add cmd (command output expression). 2013-08-23 16:00:08 +09:00
Tomoyuki Sahara 40adffc676 ARGS_XXX -> MRB_ARGS_XXX 2013-08-21 09:29:38 +09:00
Tomoyuki Sahara 0345215465 fix a possible address family mismatch. 2013-08-14 11:51:53 +09:00
Tomoyuki Sahara a9593e1f57 v4/v6 fallback for TCP. 2013-08-14 09:34:22 +09:00
Tomoyuki Sahara 5e8021bedb tests for File.socket? and File.symlink? 2013-08-08 14:00:02 +09:00
Tomoyuki Sahara c49541058c use lstat(2) to check if it's a symlink 2013-08-08 13:58:47 +09:00
Daniel Bovensiepen f3f99fa2cd Update Language Documentation 2013-08-01 15:19:25 +08:00
Daniel Bovensiepen 16a162ec45 Merge remote-tracking branch 'upstream/master' into lang-doc 2013-08-01 15:17:34 +08:00
Tomoyuki Sahara 76e1017f48 hints.ai_socktype must be set if servname is not NULL on NetBSD3.
Closes #1
2013-07-25 15:04:59 +09:00
Tomoyuki Sahara a341b8e0ff more socket options (for multicast). 2013-07-25 11:58:05 +09:00
Tomoyuki Sahara cf827ab0e7 fix Addrinfo.getaddrinfo("127.0.0.1", nil).
Closes #2
2013-07-25 11:54:53 +09:00
Takashi Sogabe 4f3a749da1 Fix incorrect condition for pendig-IO 2013-06-26 15:24:23 +09:00
Tomoyuki Sahara 216e32751e Socket.gethostname always fails. 2013-06-21 09:14:53 +09:00
Daniel Bovensiepen 6f95cd36bb Update Documentation 2013-06-15 03:56:41 +08:00
Daniel Bovensiepen 373122a299 Merge upstream 2013-06-15 03:53:50 +08:00
Daniel Bovensiepen ad07d41bd1 Improve generator 2013-06-23 18:51:58 +08:00
Daniel Bovensiepen dd6b265b2d Add ISO comments 2013-06-23 18:51:32 +08:00
Daniel Bovensiepen 51e494267a Remove old result file 2013-06-23 18:51:20 +08:00
Daniel Bovensiepen 0cec377c6b Remove swap file 2013-06-23 18:50:24 +08:00
Daniel Bovensiepen 52336e5408 Add mrbdoc - first draft 2013-06-23 17:37:39 +08:00
Daniel Bovensiepen 0a8381b7a0 Fix Tables 2013-06-17 05:06:51 +08:00
Daniel Bovensiepen 256f248548 Add First draft of Language documentation 2013-06-17 04:51:42 +08:00
Daniel Bovensiepen ac4844757d Redirect documentation to Core.md 2013-06-17 04:51:20 +08:00
Daniel Bovensiepen fd6e624ba7 Add ISO Number to Symbol 2013-06-17 04:50:54 +08:00
Daniel Bovensiepen ca937898a7 Add ISO Number to String 2013-06-17 04:50:45 +08:00
Daniel Bovensiepen 80c26d2235 Add ISO Number to Range 2013-06-17 04:50:37 +08:00
Daniel Bovensiepen 3c34eb61cb Add ISO Number to Proc 2013-06-17 04:50:31 +08:00
Daniel Bovensiepen 007faa17a4 Add ISO Number to Numeric, Integer and Float 2013-06-17 04:50:12 +08:00
Daniel Bovensiepen 2c1299d35e Add ISO Number to Kernel 2013-06-17 04:50:03 +08:00
Daniel Bovensiepen 029ed96510 Add ISO Number to Hash 2013-06-17 04:49:56 +08:00
Daniel Bovensiepen b9604819ee Add ISO Number to Enumerable 2013-06-17 04:49:46 +08:00
Daniel Bovensiepen aece7c6c4d Add ISO Number to Comparable 2013-06-17 04:49:27 +08:00
Daniel Bovensiepen 609d063b26 Add ISO Number to Array 2013-06-17 04:48:56 +08:00
Daniel Bovensiepen f64e104da6 Add init language documentation 2013-06-15 02:41:43 +08:00
Akira Yumiyama 5625e44371 add method: IO#select 2013-06-02 15:25:14 +09:00
Akira Yumiyama 1272df7cb6 fix IO#eof? method (consider the read buffer) 2013-06-02 13:24:34 +09:00
Akito Mochizuki 35defaf1c9 fix mrb_voidp_value function call 2013-05-28 10:15:25 +09:00
Tomoyuki Sahara f4aa3e7ae7 getaddrinfo("localhost") returns "fe80::1%lo0" on MacOS! 2013-05-21 14:48:42 +09:00
Tomoyuki Sahara 1411d5b974 using mruby-mtest on test/socket.rb. 2013-05-21 14:23:35 +09:00
Tomoyuki Sahara 12144b9ad2 getaddrinfo("localhost") may return 2 or more. 2013-05-21 14:23:07 +09:00
Tomoyuki Sahara 0f2d7e8a99 fix reading wrong variable. 2013-05-21 14:15:15 +09:00
Tomoyuki Sahara b8912c3508 Linux does not have getpeereid(2). 2013-05-21 14:13:15 +09:00
Tomoyuki Sahara 4bebd4d70f mrb_sys_fail() is declared in src/error.h 2013-05-21 14:03:10 +09:00
Tomoyuki Sahara cfe18142cb test runner. 2013-05-21 13:53:27 +09:00
Tomoyuki Sahara 89147066f8 mruby-socket depends on mruby-io. 2013-05-21 13:48:33 +09:00
Tomoyuki Sahara bc5feb39a1 short description, example, requirement, todo, license. 2013-05-21 13:40:14 +09:00
Tomoyuki Sahara e459ecc934 Merge branch 'master' of github.com:iij/mruby-socket 2013-05-21 13:19:32 +09:00
Tomoyuki Sahara 49e53bca5d Socket library for mruby. 2013-05-21 13:17:34 +09:00
Tomoyuki Sahara 06f1c82f64 Initial commit 2013-05-20 21:15:50 -07:00
Akira Yumiyama 0a21d9ec92 bufix of mrb_file__gethome() 2013-05-12 14:58:12 +09:00
Akira Yumiyama e277079616 update run_test.rb 2013-05-12 14:50:31 +09:00
Akira Yumiyama 55b6ef43c5 add return value check of fseek 2013-05-12 14:23:48 +09:00
Akira Yumiyama 14e1992ed0 add null check 2013-05-12 14:15:00 +09:00
Akira Yumiyama d39a05e68e remove unused variable. 2013-05-12 14:14:48 +09:00
Akira Yumiyama 49cc9c7cfa Use strncpy instead of strcpy. 2013-05-12 14:01:53 +09:00
Akira Yumiyama c25d386c41 Use mkstemp instead of mktemp. 2013-05-12 13:15:11 +09:00
Akira Yumiyama acc8995060 update run_test.rb 2013-05-12 12:54:35 +09:00
Akira Yumiyama df529a83d6 add $stdin $stdout $stderr STDIN STDOUT STDERR 2013-05-08 20:22:29 +09:00
Akira Yumiyama 7a94d02e8d add IO#print 2013-05-08 20:22:14 +09:00
Tomoyuki Sahara 38f4086a52 Merge pull request #2 from schmurfy/double
added support for E in pack
2013-05-08 01:53:56 -07:00
Julien Ammous dce09fb7fd removed unused variables 2013-05-08 10:26:15 +02:00
Julien Ammous c869bdedc0 added support for E in pack (double) 2013-05-08 10:26:15 +02:00
Tomoyuki Sahara 8c5cb5e782 cannot pack objects other than the first one. closes #1. 2013-05-08 09:40:24 +09:00
Akira Yumiyama f89ee88a6c rename mrb_class_obj_get -> mrb_class_get 2013-05-02 23:52:57 +09:00
Akira Yumiyama 7618ca6bb3 remove unused Makefile 2013-05-02 23:45:47 +09:00
Akira Yumiyama 8bfbca234f update run_test.rb 2013-05-02 23:44:40 +09:00
Akira Yumiyama 62e1823187 update run_test.rb 2013-05-02 23:36:20 +09:00
Akira Yumiyama 814f3305ca put MRB_ prefix before ARGS_XXX macros 2013-04-27 10:09:05 +09:00
Akira Yumiyama d5982b43c5 put MRB_ prefix before ARGS_XXX macros 2013-04-27 09:47:05 +09:00
Akira Yumiyama da557fbc82 add File.expand_path 2013-04-07 01:55:18 +09:00
Akira Yumiyama cc40f93ac8 Kernel#open block support 2013-04-02 15:51:36 +09:00
Akira Yumiyama 911003987b add Kernel#open 2013-04-02 15:32:01 +09:00
Akira Yumiyama 5a425f598b Update README.md 2013-04-01 10:17:18 +09:00
Akira Yumiyama b8a23e6be8 update README.md 2013-04-01 09:21:12 +09:00
Akira Yumiyama e8ca5e5169 initial commit 2013-04-01 09:12:01 +09:00
Tomoyuki Sahara 858d67c154 add "v" and "V". 2013-02-15 10:54:36 +09:00
Tomoyuki Sahara fc43022c95 support "V" and "v". 2013-02-15 10:52:37 +09:00
Tomoyuki Sahara abe9ccfe4b Merge branch 'master' of https://github.com/iij/mruby-pack 2013-02-15 10:46:21 +09:00
Tomoyuki Sahara 88fa5851f4 fix an issue large/negative integer may not be packed/unpacked correctly. 2013-02-15 10:45:30 +09:00
Tomoyuki Sahara a0c62dd4b8 fix an issue negative integer may not be packed/unpacked correctly. 2013-02-15 10:39:04 +09:00
Akira Yumiyama 53ff8bab17 update README.md 2013-01-30 17:03:42 +09:00
Akira Yumiyama aadcbb1690 add mrbgem test runner 2013-01-30 15:20:41 +09:00
Akira Yumiyama 0786e37ed6 update mrbgem.rake 2013-01-30 15:20:10 +09:00
Akira Yumiyama a0161d69a8 typo fix on mrbgem.rake 2013-01-24 10:12:02 +09:00
Akira Yumiyama f70a45ad3a update mrbgem.rake 2013-01-24 10:09:15 +09:00
Akira Yumiyama 558f6fc090 update mrbgem.rake 2013-01-24 09:00:55 +09:00
Akira Yumiyama e734ab3f95 add mrb_mruby_pack_gem_final 2013-01-24 09:00:40 +09:00
Akira Yumiyama 209ad3171d add mrbgem.rake 2013-01-04 00:04:02 +09:00
Akira Yumiyama fb79282a5b add README.md 2012-12-31 13:15:30 +09:00
Akira Yumiyama e205905d02 mruby-pack 2012-12-31 11:38:22 +09:00
414 changed files with 73137 additions and 24941 deletions
+19 -4
View File
@@ -1,9 +1,13 @@
# /
*.lock
*.bak
*.bc
*.d
*.i
*.o
*.orig
*.pdb
*.rej
*.s
*.sav
*.swp
*.tmp
@@ -11,9 +15,20 @@
.DS_Store
.ccmalloc
.svn
/.git
.vscode
.yardoc
cscope.files
cscope.out
/src/y.tab.c
tags
/.git
/bin
/build
/lib
/mruby-source-*.gem
/benchmark/**/*.dat
/benchmark/*.pdf
/benchmark/*.png
/doc/api
/doc/capi
+3214
View File
File diff suppressed because it is too large Load Diff
+17 -5
View File
@@ -1,7 +1,19 @@
# no installation...
language: c
install:
- sudo apt-get -q install gperf
sudo: false
env: MRUBY_CONFIG=travis_config.rb
script: "./minirake all test"
matrix:
include:
- os: linux
sudo: false
- os: osx
osx_image: xcode7.1
addons:
apt:
packages:
- gperf
env:
- MRUBY_CONFIG=travis_config.rb
script: "./minirake -j4 all test"
+17
View File
@@ -0,0 +1,17 @@
--markup markdown
--plugin mruby
--plugin coderay
--output-dir doc/api
src/**/*.c
mrblib/**/*.rb
include/**/*.h
mrbgems/*/src/**/*.c
mrbgems/*/mrblib/**/*.rb
mrbgems/*/include/**/*.h
-
AUTHORS
LICENSE
CONTRIBUTING.md
doc/guides/*.md
+28 -3
View File
@@ -1,6 +1,9 @@
Original Authors "mruby developers" are:
Yukihiro Matsumoto
FUKUOKA CSK CORPORATION
This is the (likely incomplete) list of "mruby developers".
If you submit a patch to mruby, please add your name to the end
of this list.
Yukihiro Matsumoto (Matz)
SCSK KYUSHU CORPORATION
Kyushu Institute of Technology
Network Applied Communication Laboratory, Inc.
Daniel Bovensiepen
@@ -17,3 +20,25 @@ Original Authors "mruby developers" are:
Jun Hiroe
Narihiro Nakamura
Yuichi Nishiwaki
Tatsuhiko Kubo
Takeshi Watanabe
Yuki Kurihara
specified non-profit corporation mruby Forum
Kazuaki Tanaka
Hiromasa Ishii
Hiroshi Mimaki
Satoshi Odawara
Mitsubishi Electric Micro-Computer Application Software Co.,Ltd.
Ralph Desir(Mav7)
Hiroyuki Matsuzaki
Yuhei Okazaki
Manycolors, Inc.
Shota Nakano
Yuichi Osawa
Terence Lee
Zachary Scott
Tomasz Dąbrowski
Christopher Aue
Masahiro Wakame
YAMAMOTO Masaya
KOBAYASHI Shuji
+15 -5
View File
@@ -14,6 +14,8 @@ things in mind before submitting your pull request:
* Don't mix several features or bug-fixes in one pull request
* Create a meaningful commit message
* Explain your change (i.e. with a link to the issue you are fixing)
* Use mrbgem to provide non ISO features (classes, modules and methods) unless
you have a special reason to implement them in the core
## Coding conventions
@@ -31,8 +33,16 @@ mruby should be highly portable to other systems and compilers. For this it is
recommended to keep your code as close as possible to the C99 standard
(http://www.open-std.org/jtc1/sc22/WG14/www/docs/n1256.pdf).
Although we target C99, Visual C++ is also an important target for mruby. For this
reason a declaration of a local variable has to be at the beginning of a scope block.
Although we target C99, we've heard some compilers in the embedded environment
still requires declarations of local variables to be at the beginning of a
scope. Until we confirm the situation has changed, we use the old-style
variable declaration.
Visual C++ is also an important target for mruby (supported version is 2013 or
later). For this reason features that are not supported by Visual C++ may not
be used (e.g. `%z` of `strftime()`).
NOTE: Old GCC requires `-std=gnu99` option to enable C99 support.
#### Reduce library dependencies to a minimum
@@ -42,7 +52,7 @@ on-demand.
#### Don't use C++ style comments
/* This is the prefered comment style */
/* This is the preferred comment style */
Use C++ style comments only for temporary comment e.g. commenting out some code lines.
@@ -56,8 +66,8 @@ Use C++ style comments only for temporary comment e.g. commenting out some code
### Ruby code
Parts of the standard library of mruby are written in the Ruby programming language
itself. Please note the following hints for your Ruby code:
Parts of the standard library of mruby are written in the Ruby programming
language itself. Please note the following hints for your Ruby code:
#### Comply with the Ruby standard (ISO/IEC 30170:2012)
-15
View File
@@ -1,15 +0,0 @@
Thu Apl 19 17:25:18 2012 Yukihiro Matsumoto <matz@ruby-lang.org>
* first release version 1.0.0 released.
Local variables:
add-log-time-format: (lambda ()
(let* ((time (current-time))
(system-time-locale "C")
(diff (+ (cadr time) 32400))
(lo (% diff 65536))
(hi (+ (car time) (/ diff 65536))))
(format-time-string "%a %b %e %H:%M:%S %Y" (list hi lo) t)))
indent-tabs-mode: t
tab-width: 8
end:
+2408
View File
File diff suppressed because it is too large Load Diff
-34
View File
@@ -1,34 +0,0 @@
* Prerequisites
1. Make sure you have bison (http://www.gnu.org/software/bison/) installed in your system.
2. Make sure you have ruby installed in your system (required to build).
* Compilation and Installation
1. Run make in the top directory.
This command will create a build directory with a directory for the host environment
and one for each crossbuild environment based on the settings in the build_config.rb
file.
Assuming a default build, each of the environment directories will have the following
important directories:
* bin - The binary executables for this environment
* lib - The libraries for this environment
You can find the header files in the include directory at the root of the project.
You can directory invoke 'minirake' as the following.
$ ruby ./minirake
If an error occurs when compiling mruby, it will be helpful for others if you
send a detailed report to the developers that includes the error log, machine,
and OS type.
* Porting to other platforms
That's all.
+1 -1
View File
@@ -2,5 +2,5 @@ LEGAL NOTICE INFORMATION
------------------------
All the files in this distribution are covered under the MIT license
(see the file MITL) except some files mentioned below:
(see the file LICENSE) except some files mentioned below:
+13 -13
View File
@@ -1,20 +1,20 @@
Copyright (c) 2013 mruby developers
Copyright (c) 2019 mruby developers
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
+4 -5
View File
@@ -1,18 +1,17 @@
# mruby is using Rake (http://rake.rubyforge.org) as a build tool.
# We provide a minimalistic version called minirake inside of our
# We provide a minimalistic version called minirake inside of our
# codebase.
RAKE = ruby ./minirake
.PHONY : all
all :
$(RAKE)
.PHONY : all
.PHONY : test
test : all
$(RAKE) test
.PHONY : test
.PHONY : clean
clean :
$(RAKE) clean
.PHONY : clean
+52 -65
View File
@@ -1,59 +1,44 @@
# !!Notice!!
This is a preliminary release for internal team review.
The URLs and addresses described below are not available yet.
The official release will be announced later.
Any suggestions for modification are welcome.
Delays in replies are to be expected. Sorry in advance.
[![Build Status][build-status-img]][travis-ci]
[![Build Status](https://travis-ci.org/mruby/mruby.png?branch=master)](https://travis-ci.org/mruby/mruby)
## What is mruby
## What's mruby
mruby is the lightweight implementation of the Ruby language complying to (part
of) the [ISO standard][ISO-standard]. Its syntax is Ruby 2.x compatible.
mruby is the lightweight implementation of the Ruby language complying to (part of)
the [ISO standard](http://www.iso.org/iso/iso_catalogue/catalogue_tc/catalogue_detail.htm?csnumber=59579).
mruby can be linked and embedded within your application. We provide the interpreter program "mruby" and
the interactive mruby shell "mirb" as examples. You can also compile Ruby programs into compiled byte code
using the mruby compiler "mrbc". All those tools reside in "bin" directory. The "mrbc" is also able to
generate compiled byte code in a C source file. You can check the "mrbtest" program under the "test" directory.
This achievement was sponsored by the Regional Innovation Creation R&D Programs of
the Ministry of Economy, Trade and Industry of Japan.
mruby can be linked and embedded within your application. We provide the
interpreter program "mruby" and the interactive mruby shell "mirb" as examples.
You can also compile Ruby programs into compiled byte code using the mruby
compiler "mrbc". All those tools reside in the "bin" directory. "mrbc" is
also able to generate compiled byte code in a C source file, see the "mrbtest"
program under the "test" directory for an example.
This achievement was sponsored by the Regional Innovation Creation R&D Programs
of the Ministry of Economy, Trade and Industry of Japan.
## How to get mruby
The mruby distribution files can be found in the following site:
The stable version 2.1.0 of mruby can be downloaded via the following URL: [https://github.com/mruby/mruby/archive/2.1.0.zip](https://github.com/mruby/mruby/archive/2.1.0.zip)
https://github.com/mruby/mruby/zipball/master
The latest development version of mruby can be downloaded via the following URL: [https://github.com/mruby/mruby/zipball/master](https://github.com/mruby/mruby/zipball/master)
The trunk of the mruby source tree can be checked out with the
following command:
$ git clone https://github.com/mruby/mruby.git
There are some other branches under development. Try the following
command and see the list of branches:
$ git branch -r
You can also install and compile mruby using [ruby-install](https://github.com/postmodern/ruby-install), [ruby-build](https://github.com/rbenv/ruby-build) or [rvm](https://github.com/rvm/rvm).
## mruby home-page
mruby's website is not launched yet but we are actively working on it.
The URL of the mruby home-page will be:
http://www.mruby.org/
The URL of the mruby home-page is: [http://www.mruby.org](http://www.mruby.org).
## Mailing list
To subscribe to the mruby mailing list....[T.B.D.]
We don't have a mailing list, but you can use [GitHub issues](https://github.com/mruby/mruby).
## How to compile and install (mruby and gems)
## How to compile and install
See the INSTALL file.
See the [compile.md](https://github.com/mruby/mruby/blob/master/doc/guides/compile.md) file.
## Running Tests
@@ -65,54 +50,56 @@ Or
$ ruby ./minirake test
## Customization
## Building documentation
There are two sets of documentation in mruby: the mruby API (generated by yard) and C API (Doxygen)
To build both of them, simply go
rake doc
You can also view them in your browser
rake view_api
rake view_capi
## How to customize mruby (mrbgems)
mruby contains a package manager called *mrbgems*. To create extensions
in C and/or Ruby you should create a *GEM*. You will find a complete
documentation with examples under *examples/mrbgems*.
in C and/or Ruby you should create a *GEM*. For a documentation of how to
use mrbgems consult the file [mrbgems.md](https://github.com/mruby/mruby/blob/master/doc/guides/mrbgems.md).
For example code of how to use mrbgems look into the folder *examples/mrbgems/*.
## License
Copyright (c) 2013 mruby developers
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
mruby is released under the [MIT License](https://github.com/mruby/mruby/blob/master/LICENSE).
## Note for License
mruby has chosen a MIT License due to its permissive license allowing
developers to target various environments such as embedded systems.
However, the license requires the display of the copyright notice and license
information in manuals for instance. Doing so for big projects can be
complicated or troublesome.
This is why mruby has decided to display "mruby developers" as the copyright name
to make it simple conventionally.
information in manuals for instance. Doing so for big projects can be
complicated or troublesome. This is why mruby has decided to display "mruby
developers" as the copyright name to make it simple conventionally.
In the future, mruby might ask you to distribute your new code
(that you will commit,) under the MIT License as a member of
"mruby developers" but contributors will keep their copyright.
(We did not intend for contributors to transfer or waive their copyrights,
Actual copyright holder name (contributors) will be listed in the AUTHORS file.)
Actual copyright holder name (contributors) will be listed in the AUTHORS
file.)
Please ask us if you want to distribute your code under another license.
## How to Contribute
See the [contribution guidelines](https://github.com/mruby/mruby/blob/master/CONTRIBUTING.md)
then send a pull request to <http://github.com/mruby/mruby>. We consider you have granted
non-exclusive right to your contributed code under MIT license. If you want to be named
as one of mruby developers, please include an update to the AUTHORS file in your pull request.
See the [contribution guidelines][contribution-guidelines], and then send a pull
request to <http://github.com/mruby/mruby>. We consider you have granted
non-exclusive right to your contributed code under MIT license. If you want to
be named as one of mruby developers, please include an update to the AUTHORS
file in your pull request.
[ISO-standard]: http://www.iso.org/iso/iso_catalogue/catalogue_tc/catalogue_detail.htm?csnumber=59579
[build-status-img]: https://travis-ci.org/mruby/mruby.svg?branch=master
[contribution-guidelines]: https://github.com/mruby/mruby/blob/master/CONTRIBUTING.md
[travis-ci]: https://travis-ci.org/mruby/mruby
+66 -21
View File
@@ -3,11 +3,13 @@
# basic build file for mruby
MRUBY_ROOT = File.dirname(File.expand_path(__FILE__))
MRUBY_BUILD_HOST_IS_CYGWIN = RUBY_PLATFORM.include?('cygwin')
MRUBY_BUILD_HOST_IS_OPENBSD = RUBY_PLATFORM.include?('openbsd')
$LOAD_PATH << File.join(MRUBY_ROOT, "lib")
# load build systems
load "#{MRUBY_ROOT}/tasks/ruby_ext.rake"
load "#{MRUBY_ROOT}/tasks/mruby_build.rake"
load "#{MRUBY_ROOT}/tasks/mrbgem_spec.rake"
require "mruby-core-ext"
require "mruby/build"
# load configuration file
MRUBY_CONFIG = (ENV['MRUBY_CONFIG'] && ENV['MRUBY_CONFIG'] != '') ? ENV['MRUBY_CONFIG'] : "#{MRUBY_ROOT}/build_config.rb"
@@ -21,25 +23,34 @@ end
# load custom rules
load "#{MRUBY_ROOT}/src/mruby_core.rake"
load "#{MRUBY_ROOT}/mrblib/mrblib.rake"
load "#{MRUBY_ROOT}/tools/mrbc/mrbc.rake"
load "#{MRUBY_ROOT}/tasks/mrbgems.rake"
load "#{MRUBY_ROOT}/tasks/libmruby.rake"
load "#{MRUBY_ROOT}/tasks/mrbgems_test.rake"
load "#{MRUBY_ROOT}/test/mrbtest.rake"
load "#{MRUBY_ROOT}/tasks/benchmark.rake"
load "#{MRUBY_ROOT}/tasks/gitlab.rake"
load "#{MRUBY_ROOT}/tasks/doc.rake"
def install_D(src, dst)
opts = { :verbose => $verbose }
FileUtils.rm_f dst, opts
FileUtils.mkdir_p File.dirname(dst), opts
FileUtils.cp src, dst, opts
end
##############################
# generic build targets, rules
task :default => :all
bin_path = ENV['INSTALL_DIR'] || "#{MRUBY_ROOT}/bin"
depfiles = MRuby.targets['host'].bins.map do |bin|
install_path = MRuby.targets['host'].exefile("#{MRUBY_ROOT}/bin/#{bin}")
install_path = MRuby.targets['host'].exefile("#{bin_path}/#{bin}")
source_path = MRuby.targets['host'].exefile("#{MRuby.targets['host'].build_dir}/bin/#{bin}")
file install_path => source_path do |t|
FileUtils.rm_f t.name, { :verbose => $verbose }
FileUtils.cp t.prerequisites.first, t.name, { :verbose => $verbose }
install_D t.prerequisites.first, t.name
end
install_path
@@ -49,29 +60,41 @@ MRuby.each_target do |target|
gems.map do |gem|
current_dir = gem.dir.relative_path_from(Dir.pwd)
relative_from_root = gem.dir.relative_path_from(MRUBY_ROOT)
current_build_dir = "#{build_dir}/#{relative_from_root}"
current_build_dir = File.expand_path "#{build_dir}/#{relative_from_root}"
if current_build_dir !~ /^#{build_dir}/
current_build_dir = "#{build_dir}/mrbgems/#{gem.name}"
end
gem.bins.each do |bin|
exec = exefile("#{build_dir}/bin/#{bin}")
objs = Dir.glob("#{current_dir}/tools/#{bin}/*.{c,cpp,cxx}").map { |f| objfile(f.pathmap("#{current_build_dir}/tools/#{bin}/%n")) }
objs = Dir.glob("#{current_dir}/tools/#{bin}/*.{c,cpp,cxx,cc}").map { |f| objfile(f.pathmap("#{current_build_dir}/tools/#{bin}/%n")) }
file exec => objs + [libfile("#{build_dir}/lib/libmruby")] do |t|
file exec => objs + target.libraries do |t|
gem_flags = gems.map { |g| g.linker.flags }
gem_flags_before_libraries = gems.map { |g| g.linker.flags_before_libraries }
gem_flags_after_libraries = gems.map { |g| g.linker.flags_after_libraries }
gem_libraries = gems.map { |g| g.linker.libraries }
gem_library_paths = gems.map { |g| g.linker.library_paths }
linker.run t.name, t.prerequisites, gem_libraries, gem_library_paths, gem_flags, gem_flags_before_libraries
linker.run t.name, t.prerequisites, gem_libraries, gem_library_paths, gem_flags, gem_flags_before_libraries, gem_flags_after_libraries
end
if target == MRuby.targets['host']
install_path = MRuby.targets['host'].exefile("#{MRUBY_ROOT}/bin/#{bin}")
install_path = MRuby.targets['host'].exefile("#{bin_path}/#{bin}")
file install_path => exec do |t|
FileUtils.rm_f t.name, { :verbose => $verbose }
FileUtils.cp t.prerequisites.first, t.name, { :verbose => $verbose }
install_D t.prerequisites.first, t.name
end
depfiles += [ install_path ]
elsif target == MRuby.targets['host-debug']
unless MRuby.targets['host'].gems.map {|g| g.bins}.include?([bin])
install_path = MRuby.targets['host-debug'].exefile("#{bin_path}/#{bin}")
file install_path => exec do |t|
install_D t.prerequisites.first, t.name
end
depfiles += [ install_path ]
end
else
depfiles += [ exec ]
end
@@ -80,7 +103,7 @@ MRuby.each_target do |target|
end
depfiles += MRuby.targets.map { |n, t|
[t.libfile("#{t.build_dir}/lib/libmruby")]
t.libraries
}.flatten
depfiles += MRuby.targets.reject { |n, t| n == 'host' }.map { |n, t|
@@ -95,12 +118,26 @@ task :all => depfiles do
MRuby.each_target do
print_build_summary
end
MRuby::Lockfile.write
end
desc "run all mruby tests"
task :test => MRuby.targets.values.map { |t| t.build_mrbtest_lib_only? ? t.libfile("#{t.build_dir}/test/mrbtest") : t.exefile("#{t.build_dir}/test/mrbtest") } do
MRuby.each_target do
run_test unless build_mrbtest_lib_only?
task :test
MRuby.each_target do
if test_enabled?
t = :"test_#{self.name}"
task t => ["all"] do
run_test
end
task :test => t
end
if bintest_enabled?
t = :"bintest_#{self.name}"
task t => ["all"] do
run_bintest
end
task :test => t
end
end
@@ -110,5 +147,13 @@ task :clean do
FileUtils.rm_rf t.build_dir, { :verbose => $verbose }
end
FileUtils.rm_f depfiles, { :verbose => $verbose }
puts "Cleaned up build folder"
puts "Cleaned up target build folder"
end
desc "clean everything!"
task :deep_clean => ["clean", "clean_doc"] do
MRuby.each_target do |t|
FileUtils.rm_rf t.gem_clone_dir, { :verbose => $verbose }
end
puts "Cleaned up mrbgems build folder"
end
+1 -4
View File
@@ -1,11 +1,8 @@
Things to do (Things that are not done yet)
* Special variables ($1,$2..)
* special variables ($1,$2..)
* super in aliased methods
Things to improve (Done but things to fix)
* Hash (Reduce size. Use khash or save the order)
* stringEx (Delete encoding、delete CODERANGE、delete everything except UTF-8 or ASCII)
* Make additions as they are noticed.
+42
View File
@@ -0,0 +1,42 @@
version: "{build}"
os: Visual Studio 2017
shallow_clone: true
cache:
- win_flex_bison
environment:
matrix:
# Visual Studio 2017 64bit
- visualcpp: C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvars64.bat
# Visual Studio 2015 64bit
- visualcpp: C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat
machine: amd64
# Visual Studio 2013 64bit
- visualcpp: C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\vcvarsall.bat
machine: amd64
init:
- call "%visualcpp%" %machine%
# For using Rubyinstaller's Ruby 2.4 64bit
- set PATH=C:\Ruby24-x64\bin;%PATH%
- ruby --version
install:
- if not exist win_flex_bison (
appveyor DownloadFile "https://github.com/lexxmark/winflexbison/releases/download/v.2.5.10/win_flex_bison-2.5.10.zip" &
7z x -y -owin_flex_bison win_flex_bison-2.5.10.zip
)
build_script:
- set YACC=.\win_flex_bison\win_bison.exe
- set MRUBY_CONFIG=appveyor_config.rb
- rake -E $stdout.sync=true test
+50
View File
@@ -0,0 +1,50 @@
MRuby::Build.new('debug') do |conf|
toolchain :visualcpp
enable_debug
# include all core GEMs
conf.gembox 'full-core'
conf.compilers.each do |c|
c.defines += %w(MRB_GC_STRESS MRB_GC_FIXED_ARENA MRB_METHOD_CACHE)
end
build_mrbc_exec
end
MRuby::Build.new('full-debug') do |conf|
toolchain :visualcpp
enable_debug
# include all core GEMs
conf.gembox 'full-core'
conf.cc.defines += %w(MRB_ENABLE_DEBUG_HOOK)
conf.enable_test
end
MRuby::Build.new do |conf|
toolchain :visualcpp
# include all core GEMs
conf.gembox 'full-core'
conf.compilers.each do |c|
c.defines += %w(MRB_GC_FIXED_ARENA)
end
conf.enable_bintest
conf.enable_test
end
MRuby::Build.new('cxx_abi') do |conf|
toolchain :visualcpp
conf.gembox 'full-core'
conf.compilers.each do |c|
c.defines += %w(MRB_GC_FIXED_ARENA)
end
conf.enable_bintest
conf.enable_test
enable_cxx_abi
build_mrbc_exec
end
@@ -1,13 +1,12 @@
# AO render benchmark
# Original program (C) Syoyo Fujita in Javascript (and other languages)
# http://lucille.atso-net.jp/blog/?p=642
# http://lucille.atso-net.jp/blog/?p=711
# https://code.google.com/p/aobench/
# Ruby(yarv2llvm) version by Hideki Miura
# mruby version by Hideki Miura
#
IMAGE_WIDTH = 256
IMAGE_HEIGHT = 256
IMAGE_WIDTH = 64
IMAGE_HEIGHT = 64
NSUBSAMPLES = 2
NAO_SAMPLES = 8
@@ -69,7 +68,7 @@ class Vec
def vnormalize
len = vlength
v = Vec.new(@x, @y, @z)
if len > 1.0e-17 then
if len > 1.0e-17
v.x = v.x / len
v.y = v.y / len
v.z = v.z / len
@@ -93,10 +92,10 @@ class Sphere
b = rs.vdot(ray.dir)
c = rs.vdot(rs) - (@radius * @radius)
d = b * b - c
if d > 0.0 then
if d > 0.0
t = - b - Math.sqrt(d)
if t > 0.0 and t < isect.t then
if t > 0.0 and t < isect.t
isect.t = t
isect.hit = true
isect.pl = Vec.new(ray.org.x + ray.dir.x * t,
@@ -119,16 +118,16 @@ class Plane
d = -@p.vdot(@n)
v = ray.dir.vdot(@n)
v0 = v
if v < 0.0 then
if v < 0.0
v0 = -v
end
if v0 < 1.0e-17 then
if v0 < 1.0e-17
return
end
t = -(ray.org.vdot(@n) + d) / v
if t > 0.0 and t < isect.t then
if t > 0.0 and t < isect.t
isect.hit = true
isect.t = t
isect.n = @n
@@ -171,10 +170,10 @@ end
def clamp(f)
i = f * 255.5
if i > 255.0 then
if i > 255.0
i = 255.0
end
if i < 0.0 then
if i < 0.0
i = 0.0
end
i.to_i
@@ -184,11 +183,11 @@ def otherBasis(basis, n)
basis[2] = Vec.new(n.x, n.y, n.z)
basis[1] = Vec.new(0.0, 0.0, 0.0)
if n.x < 0.6 and n.x > -0.6 then
if n.x < 0.6 and n.x > -0.6
basis[1].x = 1.0
elsif n.y < 0.6 and n.y > -0.6 then
elsif n.y < 0.6 and n.y > -0.6
basis[1].y = 1.0
elsif n.z < 0.6 and n.z > -0.6 then
elsif n.z < 0.6 and n.z > -0.6
basis[1].z = 1.0
else
basis[1].x = 1.0
@@ -222,8 +221,8 @@ class Scene
p0 = Vec.new(isect.pl.x + eps * isect.n.x,
isect.pl.y + eps * isect.n.y,
isect.pl.z + eps * isect.n.z)
nphi.times do |j|
ntheta.times do |i|
nphi.times do
ntheta.times do
r = Rand::rand
phi = 2.0 * 3.14159265 * Rand::rand
x = Math.cos(phi) * Math.sqrt(1.0 - r)
@@ -242,7 +241,7 @@ class Scene
@spheres[1].intersect(ray, occisect)
@spheres[2].intersect(ray, occisect)
@plane.intersect(ray, occisect)
if occisect.hit then
if occisect.hit
occlusion = occlusion + 1.0
else
0.0
@@ -284,7 +283,7 @@ class Scene
@spheres[1].intersect(ray, isect)
@spheres[2].intersect(ray, isect)
@plane.intersect(ray, isect)
if isect.hit then
if isect.hit
col = ambient_occlusion(isect)
rad.x = rad.x + col.x
rad.y = rad.y + col.y
File diff suppressed because one or more lines are too long
+1 -2
View File
@@ -1,8 +1,7 @@
# Fib 39
def fib n
return n if n < 2
fib(n-2) + fib(n-1)
end
puts fib(39)
puts fib(37)
+4 -4
View File
@@ -17,19 +17,19 @@ def test_lists()
# li2 must now be empty
# remove each individual item from right side of li3 and
# append to right side of li2 (reversing list)
while (not li3.empty?)
until li3.empty?
li2.push(li3.pop)
end
# li3 must now be empty
# reverse li1 in place
li1.reverse!
# check that first item is now SIZE
if li1[0] != SIZE then
if li1[0] != SIZE
p "not SIZE"
0
else
# compare li1 and li2 for equality
if li1 != li2 then
if li1 != li2
return(0)
else
# return the length of the list
@@ -40,7 +40,7 @@ end
i = 0
while i<NUM
i+=1
i += 1
result = test_lists()
end
+28
View File
@@ -0,0 +1,28 @@
MRuby::Build.new do |conf|
toolchain :gcc
end
MRuby::Build.new('no_boxing') do |conf|
toolchain :gcc
conf.gembox 'default'
end
MRuby::Build.new('word_boxing') do |conf|
toolchain :gcc
conf.gembox 'default'
conf.compilers.each do |c|
c.defines += %w(MRB_WORD_BOXING)
end
end
MRuby::Build.new('nan_boxing') do |conf|
toolchain :gcc
conf.gembox 'default'
conf.compilers.each do |c|
c.defines += %w(MRB_NAN_BOXING)
end
end
+13
View File
@@ -0,0 +1,13 @@
MRuby::Build.new do |conf|
toolchain :gcc
end
MRuby::Build.new('gcc') do |conf|
toolchain :gcc
conf.gembox 'default'
end
MRuby::Build.new('clang') do |conf|
toolchain :clang
conf.gembox 'default'
end
+5
View File
@@ -0,0 +1,5 @@
set yrange [0:]
set terminal pngcairo font 'Sans, 8' lw 1 size 1400,1024
set xtics rotate by -45
set style histogram errorbars gap 2 lw 1
set style fill solid border -1
View File
+64 -6
View File
@@ -2,30 +2,34 @@ MRuby::Build.new do |conf|
# load specific toolchain settings
# Gets set by the VS command prompts.
if ENV['VisualStudioVersion']
if ENV['VisualStudioVersion'] || ENV['VSINSTALLDIR']
toolchain :visualcpp
else
toolchain :gcc
end
# Turn on `enable_debug` for better debugging
# enable_debug
# Use mrbgems
# conf.gem 'examples/mrbgems/ruby_extension_example'
# conf.gem 'examples/mrbgems/c_extension_example' do |g|
# g.cc.flags << '-g' # append cflags in this gem
# end
# conf.gem 'examples/mrbgems/c_and_ruby_extension_example'
# conf.gem :github => 'masuidrive/mrbgems-example', :branch => 'master'
# conf.gem :git => 'git@github.com:masuidrive/mrbgems-example.git', :branch => 'master', :options => '-v'
# conf.gem :core => 'mruby-eval'
# conf.gem :mgem => 'mruby-onig-regexp'
# conf.gem :github => 'mattn/mruby-onig-regexp'
# conf.gem :git => 'git@github.com:mattn/mruby-onig-regexp.git', :branch => 'master', :options => '-v'
# include the default GEMs
conf.gembox 'default'
# C compiler settings
# conf.cc do |cc|
# cc.command = ENV['CC'] || 'gcc'
# cc.flags = [ENV['CFLAGS'] || %w()]
# cc.include_paths = ["#{root}/include"]
# cc.defines = %w(DISABLE_GEMS)
# cc.defines = %w()
# cc.option_include_path = '-I%s'
# cc.option_define = '-D%s'
# cc.compile_options = "%{flags} -MMD -o %{outfile} -c %{infile}"
@@ -76,8 +80,63 @@ MRuby::Build.new do |conf|
# file separetor
# conf.file_separator = '/'
# bintest
# conf.enable_bintest
end
MRuby::Build.new('host-debug') do |conf|
# load specific toolchain settings
# Gets set by the VS command prompts.
if ENV['VisualStudioVersion'] || ENV['VSINSTALLDIR']
toolchain :visualcpp
else
toolchain :gcc
end
enable_debug
# include the default GEMs
conf.gembox 'default'
# C compiler settings
conf.cc.defines = %w(MRB_ENABLE_DEBUG_HOOK)
# Generate mruby debugger command (require mruby-eval)
conf.gem :core => "mruby-bin-debugger"
# bintest
# conf.enable_bintest
end
MRuby::Build.new('test') do |conf|
# Gets set by the VS command prompts.
if ENV['VisualStudioVersion'] || ENV['VSINSTALLDIR']
toolchain :visualcpp
else
toolchain :gcc
end
enable_debug
conf.enable_bintest
conf.enable_test
conf.gembox 'default'
end
#MRuby::Build.new('bench') do |conf|
# # Gets set by the VS command prompts.
# if ENV['VisualStudioVersion'] || ENV['VSINSTALLDIR']
# toolchain :visualcpp
# else
# toolchain :gcc
# conf.cc.flags << '-O3'
# end
#
# conf.gembox 'default'
#end
# Define cross build settings
# MRuby::CrossBuild.new('32bit') do |conf|
# toolchain :gcc
@@ -90,5 +149,4 @@ end
# conf.gem 'examples/mrbgems/c_and_ruby_extension_example'
#
# conf.test_runner.command = 'env'
#
# end
View File
+238 -122
View File
@@ -1,40 +1,41 @@
# Compile
mruby is using Rake to compile and cross-compile all libraries and
mruby uses Rake to compile and cross-compile all libraries and
binaries.
## Prerequisites
To compile mruby out of the source code you need the following tools:
* C Compiler (i.e. ```gcc```)
* Linker (i.e. ```gcc```)
* Archive utility (i.e. ```ar```)
* Parser generator (i.e. ```bison```)
* Ruby 1.8 or 1.9 (i.e. ```ruby``` or ```jruby```)
* C Compiler (e.g. `gcc`)
* Linker (e.g. `gcc`)
* Archive utility (e.g. `ar`)
* Parser generator (e.g. `bison`)
* Ruby 2.0 or later (e.g. `ruby` or `jruby`)
Optional:
* GIT (to update mruby source and integrate mrbgems easier)
* C++ compiler (to use GEMs which include *.cpp)
* Assembler (to use GEMs which include *.asm)
* C++ compiler (to use GEMs which include \*.cpp, \*.cxx, \*.cc)
* Assembler (to use GEMs which include \*.asm)
## Usage
Inside of the root directory of the mruby source a file exists
called *build_config.rb*. This file contains the build configuration
of mruby and looks like this for example:
MRuby::Build.new do |conf|
toolchain :gcc
end
```ruby
MRuby::Build.new do |conf|
toolchain :gcc
end
```
All tools necessary to compile mruby can be set or modified here. In case
you want to maintain an additional *build_config.rb* you can define a
customized path using the *$MRUBY_CONFIG* environment variable.
To compile just call ```./minirake``` inside of the mruby source root. To
generate and execute the test tools call ```./minirake test```. To clean
all build files call ```./minirake clean```. To see full command line on
build, call ```./minirake -v```.
To compile just call `./minirake` inside of the mruby source root. To
generate and execute the test tools call `./minirake test`. To clean
all build files call `./minirake clean`. To see full command line on
build, call `./minirake -v`.
## Build Configuration
@@ -49,32 +50,36 @@ configure the build environment for specific compiler infrastructures.
#### GCC
Toolchain configuration for the GNU C Compiler.
toolchain :gcc
```ruby
toolchain :gcc
```
#### clang
Toolchain configuration for the LLVM C Compiler clang. Mainly equal to the
GCC toolchain.
toolchain :clang
```ruby
toolchain :clang
```
#### Visual Studio 2010, 2012 and 2013
Toolchain configuration for Visual Studio on Windows. If you use the
[Visual Studio Command Prompt](http://msdn.microsoft.com/en-us/library/ms229859\(v=vs.110\).aspx),
you normally do not have to specify this manually, since it gets automatically detected by our build process.
toolchain :visualcpp
```ruby
toolchain :visualcpp
```
#### Android
Toolchain configuration for Android.
toolchain :androideabi
```ruby
toolchain :android
```
Requires the custom standalone Android NDK and the toolchain path
in ```ANDROID_STANDALONE_TOOLCHAIN```.
in `ANDROID_STANDALONE_TOOLCHAIN`.
### Binaries
@@ -84,123 +89,232 @@ process. The following tools can be selected:
* mirb (mruby interactive shell)
To select them declare conf.gem as follows:
conf.gem "#{root}/mrbgems/mruby-bin-mruby"
conf.gem "#{root}/mrbgems/mruby-bin-mirb"
```ruby
conf.gem "#{root}/mrbgems/mruby-bin-mruby"
conf.gem "#{root}/mrbgems/mruby-bin-mirb"
```
### File Separator
Some environments require a different file separator character. It is possible to
set the character via ```conf.file_separator```.
conf.file_separator = '/'
set the character via `conf.file_separator`.
```ruby
conf.file_separator = '/'
```
### C Compiler
Configuration of the C compiler binary, flags and include paths.
```ruby
conf.cc do |cc|
cc.command = ...
cc.flags = ...
cc.include_paths = ...
cc.defines = ...
cc.option_include_path = ...
cc.option_define = ...
cc.compile_options = ...
end
```
conf.cc do |cc|
cc.command = ...
cc.flags = ...
cc.include_paths = ...
cc.defines = ...
cc.option_include_path = ...
cc.option_define = ...
cc.compile_options = ...
end
C Compiler has header searcher to detect installed library.
If you need a include path of header file use `search_header_path`:
```ruby
# Searches ```iconv.h```.
# If found it will return include path of the header file.
# Otherwise it will return nil .
fail 'iconv.h not found' unless conf.cc.search_header_path 'iconv.h'
```
If you need a full file name of header file use `search_header`:
```ruby
# Searches ```iconv.h```.
# If found it will return full path of the header file.
# Otherwise it will return nil .
iconv_h = conf.cc.search_header 'iconv.h'
print "iconv.h found: #{iconv_h}\n"
```
Header searcher uses compiler's `include_paths` by default.
When you are using GCC toolchain (including clang toolchain since its base is gcc toolchain)
it will use compiler specific include paths too. (For example `/usr/local/include`, `/usr/include`)
If you need a special header search paths define a singleton method `header_search_paths` to C compiler:
```ruby
def conf.cc.header_search_paths
['/opt/local/include'] + include_paths
end
```
### Linker
Configuration of the Linker binary, flags and library paths.
conf.linker do |linker|
linker.command = ...
linker.flags = ...
linker.flags_before_libraries = ...
linker.libraries = ...
linker.flags_after_libraries = ...
linker.library_paths = ....
linker.option_library = ...
linker.option_library_path = ...
linker.link_options = ...
end
```ruby
conf.linker do |linker|
linker.command = ...
linker.flags = ...
linker.flags_before_libraries = ...
linker.libraries = ...
linker.flags_after_libraries = ...
linker.library_paths = ....
linker.option_library = ...
linker.option_library_path = ...
linker.link_options = ...
end
```
### Archiver
Configuration of the Archiver binary and flags.
conf.archiver do |archiver|
archiver.command = ...
archiver.archive_options = ...
end
```ruby
conf.archiver do |archiver|
archiver.command = ...
archiver.archive_options = ...
end
```
### Parser Generator
Configuration of the Parser Generator binary and flags.
conf.yacc do |yacc|
yacc.command = ...
yacc.compile_options = ...
end
```ruby
conf.yacc do |yacc|
yacc.command = ...
yacc.compile_options = ...
end
```
### GPerf
Configuration of the GPerf binary and flags.
conf.gperf do |gperf|
gperf.command = ...
gperf.compile_options = ...
end
```ruby
conf.gperf do |gperf|
gperf.command = ...
gperf.compile_options = ...
end
```
### File Extensions
conf.exts do |exts
exts.object = ...
exts.executable = ...
exts.library = ...
end
```ruby
conf.exts do |exts|
exts.object = ...
exts.executable = ...
exts.library = ...
end
```
### Mrbgems
Integrate GEMs in the build process.
```ruby
# Integrate GEM with additional configuration
conf.gem 'path/to/gem' do |g|
g.cc.flags << ...
end
# Integrate GEM with additional configuration
conf.gem 'path/to/gem' do |g|
g.cc.flags << ...
end
# Integrate GEM without additional configuration
conf.gem 'path/to/another/gem'
# Integrate GEM without additional configuration
conf.gem 'path/to/another/gem'
```
See doc/mrbgems/README.md for more option about mrbgems.
### Mrbtest
Configuration Mrbtest build process.
If you want mrbtest.a only, You should set ```conf.build_mrbtest_lib_only```
If you want mrbtest.a only, You should set `conf.build_mrbtest_lib_only`
```ruby
conf.build_mrbtest_lib_only
```
conf.build_mrbtest_lib_only
### Bintest
Tests for mrbgem tools using CRuby.
To have bintests place \*.rb scripts to `bintest/` directory of mrbgems.
See `mruby-bin-*/bintest/*.rb` if you need examples.
If you want a temporary files use `tempfile` module of CRuby instead of `/tmp/`.
You can enable it with following:
```ruby
conf.enable_bintest
```
### C++ ABI
By default, mruby uses setjmp/longjmp to implement its
exceptions. But it doesn't release C++ stack object
correctly. To support mrbgems written in C++, mruby can be
configured to use C++ exception.
There are two levels of C++ exception handling. The one is
`enable_cxx_exception` that enables C++ exception, but
uses C ABI. The other is `enable_cxx_abi` where all
files are compiled by C++ compiler.
When you mix C++ code, C++ exception would be enabled automatically.
If you need to enable C++ exception explicitly add the following:
```ruby
conf.enable_cxx_exception
```
#### C++ exception disabling.
If your compiler does not support C++ and you want to ensure
you don't use mrbgem written in C++, you can explicitly disable
C++ exception, add following:
```ruby
conf.disable_cxx_exception
```
and you will get an error when you try to use C++ gem.
Note that it must be called before `enable_cxx_exception` or `gem` method.
### Debugging mode
To enable debugging mode add the following:
```ruby
conf.enable_debug
```
When debugging mode is enabled
* Macro `MRB_DEBUG` would be defined.
* Which means `mrb_assert()` macro is enabled.
* Debug information of irep would be generated by `mrbc`.
* Because `-g` flag would be added to `mrbc` runner.
* You can have better backtrace of mruby scripts with this.
## Cross-Compilation
mruby can also be cross-compiled from one platform to another. To
achieve this the *build_config.rb* needs to contain an instance of
```MRuby::CrossBuild```. This instance defines the compilation
`MRuby::CrossBuild`. This instance defines the compilation
tools and flags for the target platform. An example could look
like this:
```ruby
MRuby::CrossBuild.new('32bit') do |conf|
toolchain :gcc
MRuby::CrossBuild.new('32bit') do |conf|
toolchain :gcc
conf.cc.flags << "-m32"
conf.linker.flags << "-m32"
end
```
conf.cc.flags << "-m32"
conf.linker.flags << "-m32"
end
All configuration options of `MRuby::Build` can also be used
in `MRuby::CrossBuild`.
All configuration options of ```MRuby::Build``` can also be used
in ```MRuby::CrossBuild```.
### Mrbtest in Cross-Compilation
In cross compilation, you can run `mrbtest` on emulator if
you have it by changing configuration of test runner.
```ruby
conf.test_runner do |t|
t.command = ... # set emulator. this value must be non nil or false
t.flags = ... # set flags of emulator
def t.run(bin) # override `run` if you need to change the behavior of it
... # `bin` is the full path of mrbtest
end
end
```
## Build process
@@ -226,25 +340,25 @@ root directory. The structure of this directory will look like this:
+- mirb
|
+- mrbc
|
|
+- mruby
The compilation workflow will look like this:
* compile all files under *src* (object files will be stored
* compile all files under *src* (object files will be stored
in *build/host/src*)
* generate parser grammar out of *src/parse.y* (generated
result will be stored in *build/host/src/y.tab.c*)
* compile *build/host/src/y.tab.c* to *build/host/src/y.tab.o*
* create *build/host/lib/libmruby_core.a* out of all object files (C only)
* create ```build/host/bin/mrbc``` by compiling *tools/mrbc/mrbc.c* and
linking with *build/host/lib/libmruby_core.a*
* create *build/host/mrblib/mrblib.c* by compiling all *.rb files
under *mrblib* with ```build/host/bin/mrbc```
* compile *build/host/mrblib/mrblib.c* to *build/host/mrblib/mrblib.o*
* create `build/host/bin/mrbc` by compiling *tools/mrbc/mrbc.c* and
linking with *build/host/lib/libmruby_core.a*
* create *build/host/mrblib/mrblib.c* by compiling all \*.rb files
under *mrblib* with `build/host/bin/mrbc`
* compile *build/host/mrblib/mrblib.c* to *build/host/mrblib/mrblib.o*
* create *build/host/lib/libmruby.a* out of all object files (C and Ruby)
* create ```build/host/bin/mruby``` by compiling *mrbgems/mruby-bin-mruby/tools/mruby/mruby.c* and
* create `build/host/bin/mruby` by compiling *mrbgems/mruby-bin-mruby/tools/mruby/mruby.c* and
linking with *build/host/lib/libmruby.a*
* create ```build/host/bin/mirb``` by compiling *mrbgems/mruby-bin-mirb/tools/mirb/mirb.c* and
* create `build/host/bin/mirb` by compiling *mrbgems/mruby-bin-mirb/tools/mirb/mirb.c* and
linking with *build/host/lib/libmruby.a*
```
@@ -278,8 +392,8 @@ like this:
| +- mirb
| |
| +- mrbc
| |
| +- mruby
| |
| +- mruby
+- i386
|
+- bin <- Cross-compiled Binaries
@@ -297,32 +411,32 @@ like this:
+- mirb
|
+- mrbc
|
|
+- mruby
An extra directory is created for the target platform. In case you
compile for *i386* a directory called *i386* is created under the
build direcotry.
build directory.
The cross compilation workflow starts in the same way as the normal
compilation by compiling all *native* libraries and binaries.
Afterwards the cross compilation process proceeds like this:
* cross-compile all files under *src* (object files will be stored
* cross-compile all files under *src* (object files will be stored
in *build/i386/src*)
* generate parser grammar out of *src/parse.y* (generated
result will be stored in *build/i386/src/y.tab.c*)
* cross-compile *build/i386/src/y.tab.c* to *build/i386/src/y.tab.o*
* create *build/i386/mrblib/mrblib.c* by compiling all *.rb files
under *mrblib* with the native ```build/host/bin/mrbc```
* create *build/i386/mrblib/mrblib.c* by compiling all \*.rb files
under *mrblib* with the native `build/host/bin/mrbc`
* cross-compile *build/host/mrblib/mrblib.c* to *build/host/mrblib/mrblib.o*
* create *build/i386/lib/libmruby.a* out of all object files (C and Ruby)
* create ```build/i386/bin/mruby``` by cross-compiling *mrbgems/mruby-bin-mruby/tools/mruby/mruby.c* and
* create `build/i386/bin/mruby` by cross-compiling *mrbgems/mruby-bin-mruby/tools/mruby/mruby.c* and
linking with *build/i386/lib/libmruby.a*
* create ```build/i386/bin/mirb``` by cross-compiling *mrbgems/mruby-bin-mirb/tools/mirb/mirb.c* and
* create `build/i386/bin/mirb` by cross-compiling *mrbgems/mruby-bin-mirb/tools/mirb/mirb.c* and
linking with *build/i386/lib/libmruby.a*
* create *build/i386/lib/libmruby_core.a* out of all object files (C only)
* create ```build/i386/bin/mrbc``` by cross-compiling *tools/mrbc/mrbc.c* and
linking with *build/i386/lib/libmruby_core.a*
* create `build/i386/bin/mrbc` by cross-compiling *tools/mrbc/mrbc.c* and
linking with *build/i386/lib/libmruby_core.a*
```
_______________________________________________________________
@@ -348,25 +462,27 @@ linking with *build/i386/lib/libmruby_core.a*
### Minimal Library
To build a minimal mruby library you need to use the Cross Compiling
feature due to the reason that there are functions (i.e. stdio) which
To build a minimal mruby library you need to use the Cross Compiling
feature due to the reason that there are functions (e.g. stdio) which
can't be disabled for the main build.
MRuby::CrossBuild.new('Minimal') do |conf|
toolchain :gcc
```ruby
MRuby::CrossBuild.new('Minimal') do |conf|
toolchain :gcc
conf.cc.defines = %w(DISABLE_STDIO)
conf.bins = []
end
conf.cc.defines = %w(MRB_DISABLE_STDIO)
conf.bins = []
end
```
This configuration defines a cross compile build called 'Minimal' which
is using the GCC and compiles for the host machine. It also disables
all usages of stdio and doesn't compile any binaries (i.e. mrbc).
all usages of stdio and doesn't compile any binaries (e.g. mrbc).
## Test Environment
mruby's build process includes a test environment. In case you start the testing
of mruby, a native binary called ```mrbtest``` will be generated and executed.
of mruby, a native binary called `mrbtest` will be generated and executed.
This binary contains all test cases which are defined under *test/t*. In case
of a cross-compilation an additional cross-compiled *mrbtest* binary is
of a cross-compilation an additional cross-compiled *mrbtest* binary is
generated. You can copy this binary and run on your target system.
+370
View File
@@ -0,0 +1,370 @@
# How to Use the mruby Debugger
copyright (c) 2014 Specified Non-Profit Corporation mruby Forum
## 1. Summary
This file documents the mruby debugger ('mrdb') methods.
## 2 Debugging with mrdb
## 2.1 Building mrdb
The trunk of the mruby source tree, with the most recent mrdb, can be checked out with the following command:
```bash
$ git clone https://github.com/mruby/mruby.git
```
To run the `make` command:
```bash
$ cd mruby
$ make
```
By default, the `make` command will install the debugger files into mruby/bin.
You can add the path for mrdb on your host environment with the following command:
```bash
$ echo "export PATH=\$PATH:MRUBY_ROOT/bin" >> ~/.bashrc
$ source ~/.bashrc
```
`*MRUBY_ROOT` is the directory in which mruby source code will be installed.
To confirm mrdb was installed properly, run mrdb with the `--version` option:
```bash
$ mrdb --version
mruby 2.1.0 (2019-10-18)
```
## 2.2 Basic Operation
### 2.2.1 Debugging mruby Script Files (rb file) with mrdb
To invoke the mruby debugger, just type `mrdb`.
To specify the script file:
```bash
$ mrdb [option] file name
```
For example: Debugging sample.rb
```bash
$ mrdb sample.rb
```
You can execute the shell commands listed below:
|command|description|
|:-:|:--|
|run|execute programs|
|step|execute stepping|
|continue|execute continuing program|
|break|configure the breaking point|
|delete|deleting the breaking points|
|disable|disabling the breaking points|
|enable|enabling the breaking points|
|info breakpoints|showing list of the breaking points|
|print|evaluating and printing the values of the mruby expressions in the script|
|list|displaying the source cords|
|help|showing help|
|quit|terminating the mruby debugger|
### 2.2.2 Debugging mruby Binary Files (mrb file) with mrdb
You can debug the mruby binary files.
#### 2.2.2.1 Debugging the binary files
* notice
To debug mruby binary files, you need to compile mruby files with option `-g`.
```bash
$ mrbc -g sample.rb
```
You can debug the mruby binary files with following command and the option `-b`.
```bash
$ mrdb -b sample.mrb
```
Then you can execute all debugger shell commands.
#### Break Command
You can use any breakpoint to stop the program by specifying the line number and method name.
The breakpoint list will be displayed after you have set the breakpoint successfully.
Usage:
```
break [file:]linenum
b [file:]linenum
break [class:]method
b [class:]method
```
The breakpoint will be ordered in serial from 1.
The number, which was given to the deleted breakpoint, will never be given to another breakpoint again.
You can give multiple breakpoints to specified the line number and method.
Be ware that breakpoint command will not check the validity of the class name and method name.
You can get the current breakpoint information by the following options.
breakpoint breakpoint number : file name. line number
breakpoint breakpoint number : [class name,] method name
#### Continue Command
Usage:
```
continue [N]
c [N]
```
N: the next breakpoint number
When resuming the program, it will stop at breakpoint N (N-1 breakpoint will be ignored).
When you run the `continue` command without specifying N, the program will be stopped at the next breakpoint.
Example:
```
(foo.rb:1) continue 3
```
This will resume the program and stop it at the third breakpoint.
#### Delete Command
This will delete the specified breakpoint.
Usage:
```
delete [breakpoint-no]
d [breakpoint-no]
```
breakpoint-no: breakpoint number
Example:
```
(foo.rb:1) delete
```
This will delete all of the breakpoints.
```
(foo.rb:1) delete 1 3
```
This will delete the breakpoint at 1 and 3.
#### Disable Command
This will disable the specified breakpoint.
Usage:
```
disable [breakpoint-no]
dis [breakpoint-no]
```
reappointing: breakpoint number
Example:
```
(foo.rb:1) disable
```
Use `disable` if you would like to disable all of the breakpoints.
```
(foo.rb:1) disable 1 3
```
This will disable the breakpoints at 1 and 3.
#### Enable Command
This will enable the specified breakpoints.
Usage:
```
enable [breakpoint-no]
e [breakpoint-no]
```
breakpoint-no: breakpoint number
Example:
```
(foo.rb:1) enable
```
Enabling all breakpoints
```
(foo.rb:1) enable 1 3
```
Enabling the breakpoint 1 and 3
#### eval command
Evaluating the string as source code and printing the value.
Same as print command, please see print command.
#### help command
Displaying the help message.
Usage:
```
help [command]
h [command]
```
Typing `help` without any options will display the command list.
#### Info Breakpoints Command
Displaying the specified breakpoint information.
Usage:
```
info breakpoints [breakpoint-no]
i b [breakpoint-no]
```
breakpoint-no: breakpoint number
Typing "info breakpoints" without ant option will display all breakpoint information.
Example:
```
(sample.rb:1) info breakpoints
Num Type Enb What
1 breakpoint y at sample.rb:3 -> file name,line number
2 breakpoint n in Sample_class:sample_class_method -> [class:]method name
3 breakpoint y in sample_global_method
```
Displaying the specified breakpoint number:
```
(foo.rb:1) info breakpoints 1 3
Num Type Enb What
1 breakpoint y at sample.rb:3
3 breakpoint y in sample_global_method
```
#### List Command
To display the code of the source file.
Usage:
```
list [filename:]first[,last]
l [filename]:first[,last]
```
first: the opening row number
last : the closing row number
When you specify the `first`, but not the `last` option, you will receive 10 rows.
When you do not specify both the `first` and `last` options, you will receive the next 10 rows.
Example:
```
Specifying file name and first row number
sample.rb:1) list sample2.rb:5
```
Specifying the file name and the first and last row number:
```
(sample.rb:1) list sample2.rb:6,7
```
#### Print Command
Evaluating the string as source code and printing the value.
Usage:
```
print [expr]
p [expr]
```
expr: expression
The expression is mandatory.
The displayed expressions will be serially ordered from 1.
If an exception occurs, the exception information will be displayed and the debugging will be continued.
Example:
```
(sample.rb:1) print 1+2
$1 = 3
(sample.rb:1) print self
$2 = main
```
Below is the case of the exception:
```
(sample.rb:1) print (1+2
$1 = SyntaxError: line 1: syntax error, unexpected $end, expecting ')'
```
#### Quit Command
Quitting the debugger.
Usage:
```
quit
q
```
#### Run Command
Running the program and stopping at the first breakpoint.
Usage:
```
run
r
```
#### Step Command
This will run the program step by step.
When the method and the block are invoked, the program will be stop at the first row.
The program, which is developed in C, will be ignored.
+177
View File
@@ -0,0 +1,177 @@
# How to use `mrb_gc_arena_save()`/`mrb_gc_arena_restore()`/`mrb_gc_protect()`
_This is an English translation of [Matz's blog post][matz blog post]
written in Japanese._
_Some parts are updated to reflect recent changes._
[matz blog post]: http://www.rubyist.net/~matz/20130731.html
When you are extending mruby using C language, you may encounter
mysterious "arena overflow error" or memory leak or very slow
execution speed. This is an error indicating overflow of "GC arena"
implementing "conservative GC".
GC (garbage collector) must ensure that object is "alive", in other
words, that it is referenced by somewhere from program. This can be
determined by checking if the object can be directly or indirectly
referenced by root. The local variables, global variables and
constants etc are root.
If program execution is performed inside mruby VM, there is nothing to
worry about because GC can access all roots owned by VM.
The problem arises when executing C functions. The object referenced
by C variable is also "alive", but mruby GC cannot aware of this, so
it might mistakenly recognize the objects referenced by only C
variables as dead.
This can be a fatal bug if the GC tries to collect a live object.
In CRuby, we scan C stack area, and use C variable as root to check
whether object is alive or not. Of course, because we are accessing C
stack just as memory region, we never know it is an integer or a
pointer. We workaround this by assuming that if it looks like a
pointer, then assume it as a pointer. We call it "conservative".
By the way, CRuby's "conservative GC" has some problems.
The biggest problem is we have no way to access to the stack area in
portable way. Therefore, we cannot use this method if we'd like to
implement highly portable runtime, like mruby.
So we came up with an another plan to implement "conservative GC" in mruby.
Again, the problem is when an object which was created in C function, becomes
no longer referenced in the Ruby world, and cannot be treated as garbage.
In mruby, we recognize all objects created in C function are alive.
Then we have no problem such as confusing a live object as dead.
This means that because we cannot collect truly dead object, we may
lose efficiency, but as a trade-off the GC itself is highly portable.
We can say goodbye to the problem that GC deletes live objects due to
optimization which sometimes occurs in CRuby.
According to this idea, we have a table, called "GC arena", which
remembers objects created in C function.
The arena is stack structure, when C function execution is returned to mruby
VM, all objects registered in the arena are popped.
This works very well, but can cause another problem: "arena overflow error" or
memory leak.
As of this writing, mruby automatically extend arena to remember
objects (See `MRB_GC_FIXED_ARENA` and `MRB_GC_ARENA_SIZE` in
doc/guides/mrbconf.md).
If you create many objects in C functions, memory usage will increase, since
GC never kick in. This memory usage may look like memory leak, but will also
make execution slower as more memory will need to be allocated.
With the build time configuration, you can limit the maximum size of
arena (e.g., 100). Then if you create many objects, arena overflows,
thus you will get an "arena overflow error".
To workaround these problems, we have `mrb_gc_arena_save()` and
`mrb_gc_arena_restore()` functions.
`int mrb_gc_arena_save(mrb)` returns the current position of the stack
top of GC arena, and `void mrb_gc_arena_restore(mrb, idx)` sets the
stack top position to back to given `idx`.
We can use them like this:
```c
int arena_idx = mrb_gc_arena_save(mrb);
// ...create objects...
mrb_gc_arena_restore(mrb, arena_idx);
```
In mruby, C function calls are surrounded by this save/restore, but we
can further optimize memory usage by surrounding save/restore, and can
avoid creating arena overflow bugs.
Let's take a real example. Here is the source code of `Array#inspect`:
```c
static mrb_value
inspect_ary(mrb_state *mrb, mrb_value ary, mrb_value list)
{
mrb_int i;
mrb_value s, arystr;
char head[] = { '[' };
char sep[] = { ',', ' ' };
char tail[] = { ']' };
/* check recursive */
for(i=0; i<RARRAY_LEN(list); i++) {
if (mrb_obj_equal(mrb, ary, RARRAY_PTR(list)[i])) {
return mrb_str_new(mrb, "[...]", 5);
}
}
mrb_ary_push(mrb, list, ary);
arystr = mrb_str_new_capa(mrb, 64);
mrb_str_cat(mrb, arystr, head, sizeof(head));
for(i=0; i<RARRAY_LEN(ary); i++) {
int ai = mrb_gc_arena_save(mrb);
if (i > 0) {
mrb_str_cat(mrb, arystr, sep, sizeof(sep));
}
if (mrb_array_p(RARRAY_PTR(ary)[i])) {
s = inspect_ary(mrb, RARRAY_PTR(ary)[i], list);
}
else {
s = mrb_inspect(mrb, RARRAY_PTR(ary)[i]);
}
mrb_str_cat(mrb, arystr, RSTRING_PTR(s), RSTRING_LEN(s));
mrb_gc_arena_restore(mrb, ai);
}
mrb_str_cat(mrb, arystr, tail, sizeof(tail));
mrb_ary_pop(mrb, list);
return arystr;
}
```
This is a real example, so a little bit complicated, but bear with me.
The essence of `Array#inspect` is that after stringifying each element
of array using `inspect` method, we join them together so that we can
get `inspect` representation of the entire array.
After the `inspect` representation is created, we no longer require the
individual string representation. This means that we don't have to register
these temporal objects into GC arena.
Therefore, in order to keep the arena size small; the `ary_inspect()` function
will do the following:
* save the position of the stack top using `mrb_gc_arena_save()`.
* get `inspect` representation of each element.
* append it to the constructing entire `inspect` representation of array.
* restore stack top position using `mrb_gc_arena_restore()`.
Please note that the final `inspect` representation of entire array
was created before the call of `mrb_gc_arena_restore()`. Otherwise,
required temporal object may be deleted by GC.
We may have a usecase where after creating many temporal objects, we'd
like to keep some of them. In this case, we cannot use the same idea
in `ary_inspect()` like appending objects to existing one.
Instead, after `mrb_gc_arena_restore()`, we must re-register the objects we
want to keep in the arena using `mrb_gc_protect(mrb, obj)`.
Use `mrb_gc_protect()` with caution because it could also lead to an "arena
overflow error".
We must also mention that when `mrb_funcall` is called in top level, the return
value is also registered to GC arena, so repeated use of `mrb_funcall` may
eventually lead to an "arena overflow error".
Use `mrb_gc_arena_save()` and `mrb_gc_arena_restore()` or possible use of
`mrb_gc_protect()` to workaround this.
+185
View File
@@ -0,0 +1,185 @@
# mruby configuration macros.
## How to use these macros.
You can use mrbconfs with following ways:
* Write them in `mrbconf.h`.
* Using compiler flags is preferred when building a cross binaries or multiple mruby binaries
since it's easier to use different mrbconf per each `MRuby::Build`.
* Most flags can be enabled by just commenting in.
* Pass them as compiler flags.
* Make sure you pass the same flags to all compilers since some mrbconf(e.g., `MRB_GC_FIXED_ARENA`)
changes `struct` layout and cause memory access error when C and other language(e.g., C++) is mixed.
## stdio setting.
`MRB_DISABLE_STDIO`
* When defined `<stdio.h>` functions won't be used.
* Some features will be disabled when this is enabled:
* `mrb_irep` load/dump from/to file.
* Compiling mruby script from file.
* Printing features in **src/print.c**.
## Debug macros.
`MRB_ENABLE_DEBUG_HOOK`
* When defined code fetch hook and debug OP hook will be enabled.
* When using any of the hook set function pointer `code_fetch_hook` and/or `debug_op_hook` of `mrb_state`.
* Fetch hook will be called before any OP.
* Debug OP hook will be called when dispatching `OP_DEBUG`.
`MRB_DEBUG`
* When defined `mrb_assert*` macro will be defined with macros from `<assert.h>`.
* Could be enabled via `enable_debug` method of `MRuby::Build`.
## Stack configuration
`MRB_STACK_EXTEND_DOUBLING`
* If defined doubles the stack size when extending it.
* Else extends stack with `MRB_STACK_GROWTH`.
`MRB_STACK_GROWTH`
* Default value is `128`.
* Used in stack extending.
* Ignored when `MRB_STACK_EXTEND_DOUBLING` is defined.
`MRB_STACK_MAX`
* Default value is `0x40000 - MRB_STACK_GROWTH`.
* Raises `RuntimeError` when stack size exceeds this value.
## Primitive type configuration.
`MRB_USE_FLOAT`
* When defined single precision floating point type(C type `float`) is used as `mrb_float`.
* Else double precision floating point type(C type `double`) is used as `mrb_float`.
`MRB_WITHOUT_FLOAT`
* When defined removes floating point numbers from mruby.
* It makes mruby easier to handle in "Microcontroller without FPU" and "Kernel Space".
`MRB_INT16`
* When defined `int16_t` will be defined as `mrb_int`.
* Conflicts with `MRB_INT32` and `MRB_INT64`.
`MRB_INT32`
* When defined, or both `MRB_INT16` and `MRB_INT64` are not defined on 32-bit CPU mode, `int32_t` will be defined as `mrb_int`.
* Conflicts with `MRB_INT16` and `MRB_INT64`.
`MRB_INT64`
* When defined, or both `MRB_INT16` and `MRB_INT32` are not defined on 64-bit CPU mode, `int64_t` will be defined as `mrb_int`.
* Conflicts with `MRB_INT16` and `MRB_INT32`.
## Garbage collector configuration.
`MRB_GC_STRESS`
* When defined full GC is emitted per each `RBasic` allocation.
* Mainly used in memory manager debugging.
`MRB_GC_TURN_OFF_GENERATIONAL`
* When defined turns generational GC by default.
`MRB_GC_FIXED_ARENA`
* When defined used fixed size GC arena.
* Raises `RuntimeError` when this is defined and GC arena size exceeds `MRB_GC_ARENA_SIZE`.
* Useful tracking unnecessary mruby object allocation.
`MRB_GC_ARENA_SIZE`
* Default value is `100`.
* Ignored when `MRB_GC_FIXED_ARENA` isn't defined.
* Defines fixed GC arena size.
`MRB_HEAP_PAGE_SIZE`
* Defines value is `1024`.
* Specifies number of `RBasic` per each heap page.
## Memory pool configuration.
`POOL_ALIGNMENT`
* Default value is `4`.
* If you're allocating data types that requires alignment more than default value define the
largest value of required alignment.
`POOL_PAGE_SIZE`
* Default value is `16000`.
* Specifies page size of pool page.
* Smaller the value is increases memory overhead.
## State atexit configuration.
`MRB_FIXED_STATE_ATEXIT_STACK`
* If defined enables fixed size `mrb_state` atexit stack.
* Raises `RuntimeError` when `mrb_state_atexit` call count to same `mrb_state` exceeds
`MRB_FIXED_STATE_ATEXIT_STACK_SIZE`'s value.
`MRB_FIXED_STATE_ATEXIT_STACK_SIZE`
* Default value is `5`.
* If `MRB_FIXED_STATE_ATEXIT_STACK` isn't defined this macro is ignored.
## `mrb_value` configuration.
`MRB_ENDIAN_BIG`
* If defined compiles mruby for big endian machines.
* Used in `MRB_NAN_BOXING`.
* Some mrbgem use this mrbconf.
`MRB_NAN_BOXING`
* If defined represent `mrb_value` in boxed `double`.
* Conflicts with `MRB_USE_FLOAT` and `MRB_WITHOUT_FLOAT`.
`MRB_WORD_BOXING`
* If defined represent `mrb_value` as a word.
* If defined `Float` will be a mruby object with `RBasic`.
## Instance variable configuration.
`MRB_IV_SEGMENT_SIZE`
* Default value is `4`.
* Specifies size of each segment in segment list.
## Reduce heap memory configuration.
`MRB_USE_LINK_TIME_RO_DATA_P`
* Only available on ELF platforms.
* If you specify the address of a read-only section when creating a symbol or string, that string will be used as it is.
* Heap memory can be saved.
* Uses `__ehdr_start` and `__init_array_start`.
* It must be `__ehdr_start < data_addr < __init_array_start`.
`MRB_USE_CUSTOM_RO_DATA_P`
* Takes precedence over `MRB_USE_LINK_TIME_RO_DATA_P`.
* Please try if `MRB_USE_LINK_TIME_RO_DATA_P` is not available.
* The `mrb_ro_data_p()` function is implemented by the user in an arbitrary file.
* The prototype declaration is `mrb_bool mrb_ro_data_p(const char *ptr)`.
* Return `TRUE` if `ptr` is in read-only section, otherwise return `FALSE`.
## Other configuration.
`MRB_UTF8_STRING`
* Adds UTF-8 encoding support to character-oriented String instance methods.
* If it isn't defined, they only support the US-ASCII encoding.
`MRB_FUNCALL_ARGC_MAX`
* Default value is `16`.
* Specifies 4th argument(`argc`) max value of `mrb_funcall`.
* Raises `ArgumentError` when the `argc` argument is bigger then this value `mrb_funcall`.
`KHASH_DEFAULT_SIZE`
* Default value is `32`.
* Specifies default size of khash table bucket.
* Used in `kh_init_ ## name` function.
`MRB_STR_BUF_MIN_SIZE`
* Default value is `128`.
* Specifies initial capacity of `RString` created by `mrb_str_buf_new` function..
`MRB_METHOD_CACHE`
* Improve performance for method dispatch.
`MRB_METHOD_CACHE_SIZE`
* Default value is `128`.
* Ignored if `MRB_METHOD_CACHE` is not defined.
* Need to be the power of 2.
`MRB_METHOD_T_STRUCT`
* Use C struct to represent `mrb_method_t`
* No `MRB_METHOD_T_STRUCT` requires highest 2 bits of function pointers to be zero
* Define this macro on machines that use higher bits of pointers
`MRB_ENABLE_ALL_SYMBOLS`
* Make it available `Symbols.all_symbols` in `mrbgems/mruby-symbol-ext`
* Increase heap memory usage.
+160 -64
View File
@@ -10,60 +10,82 @@ build configuration (i.e. *build_config.rb*), mrbgems will be activated and the
extension integrated.
To add a GEM into the *build_config.rb* add the following line for example:
conf.gem '/path/to/your/gem/dir'
```ruby
conf.gem '/path/to/your/gem/dir'
```
You can also use a relative path which would be relative from the mruby root:
conf.gem 'examples/mrbgems/ruby_extension_example'
```ruby
conf.gem 'examples/mrbgems/ruby_extension_example'
```
A remote GIT repository location for a GEM is also supported:
```ruby
conf.gem :git => 'https://github.com/masuidrive/mrbgems-example.git', :branch => 'master'
conf.gem :github => 'masuidrive/mrbgems-example', :branch => 'master'
conf.gem :bitbucket => 'mruby/mrbgems-example', :branch => 'master'
```
conf.gem :git => 'https://github.com/masuidrive/mrbgems-example.git', :branch => 'master'
You can specify the sub directory of the repository with `:path` option:
```ruby
conf.gem github: 'mruby/mruby', path: 'mrbgems/mruby-socket'
```
conf.gem :github => 'masuidrive/mrbgems-example', :branch => 'master'
To use mrbgem from [mgem-list](https://github.com/mruby/mgem-list) use `:mgem` option:
```ruby
conf.gem :mgem => 'mruby-yaml'
conf.gem :mgem => 'yaml' # 'mruby-' prefix could be omitted
```
conf.gem :bitbucket => 'mruby/mrbgems-example', :branch => 'master'
For specifying commit hash to checkout use `:checksum_hash` option:
```ruby
conf.gem mgem: 'mruby-redis', checksum_hash: '3446d19fc4a3f9697b5ddbf2a904f301c42f2f4e'
```
To pull all gems from remote GIT repository on build, call ```./minirake -p```,
If there is missing dependencies, mrbgem dependencies solver will reference
mrbgem from core or mgem-list.
To pull all gems from remote GIT repository on build, call ```./minirake -p```,
or ```./minirake --pull-gems```.
NOTE: `:bitbucket` option supports only git. Hg is unsupported in this version.
## GemBox
There are instances when you wish to add a collection of mrbgems into mruby at
There are instances when you wish to add a collection of mrbgems into mruby at
once, or be able to substitute mrbgems based on configuration, without having to
add each gem to the *build_config.rb* file. A packaged collection of mrbgems
is called a GemBox. A GemBox is a file that contains a list of mrbgems to load
add each gem to the *build_config.rb* file. A packaged collection of mrbgems
is called a GemBox. A GemBox is a file that contains a list of mrbgems to load
into mruby, in the same format as if you were adding them to *build_config.rb*
via `config.gem`, but wrapped in an `MRuby::GemBox` object. GemBoxes are
via `config.gem`, but wrapped in an `MRuby::GemBox` object. GemBoxes are
loaded into mruby via `config.gembox 'boxname'`.
Below we have created a GemBox containing *mruby-time* and *mrbgems-example*:
MRuby::GemBox.new do |conf|
conf.gem "#{root}/mrbgems/mruby-time"
conf.gem :github => 'masuidrive/mrbgems-example'
end
```ruby
MRuby::GemBox.new do |conf|
conf.gem "#{root}/mrbgems/mruby-time"
conf.gem :github => 'masuidrive/mrbgems-example'
end
```
As mentioned, the GemBox uses the same conventions as `MRuby::Build`. The GemBox
must be saved with a *.gembox* extension inside the *mrbgems* directory to to be
picked up by mruby.
To use this example GemBox, we save it as `custom.gembox` inside the *mrbgems*
directory in mruby, and add the following to our *build_config.rb* file inside
To use this example GemBox, we save it as `custom.gembox` inside the *mrbgems*
directory in mruby, and add the following to our *build_config.rb* file inside
the build block:
conf.gembox 'custom'
```ruby
conf.gembox 'custom'
```
This will cause the *custom* GemBox to be read in during the build process,
adding *mruby-time* and *mrbgems-example* to the build.
If you want, you can put GemBox outside of mruby directory. In that case you must
specify absolute path like below.
conf.gembox "#{ENV["HOME"]}/mygemboxes/custom"
If you want, you can put GemBox outside of mruby directory. In that case you must
specify an absolute path like below.
```ruby
conf.gembox "#{ENV["HOME"]}/mygemboxes/custom"
```
There are two GemBoxes that ship with mruby: [default](../../mrbgems/default.gembox)
and [full-core](../../mrbgems/full-core.gembox). The [default](../../mrbgems/default.gembox) GemBox
@@ -75,6 +97,8 @@ contains every gem found in the *mrbgems* directory.
The maximal GEM structure looks like this:
+- GEM_NAME <- Name of GEM
|
+- include/ <- Header for Ruby extension (will exported)
|
+- mrblib/ <- Source for Ruby extension
|
@@ -87,20 +111,22 @@ The maximal GEM structure looks like this:
+- README.md <- Readme for GEM
The folder *mrblib* contains pure Ruby files to extend mruby. The folder *src*
contains C files to extend mruby. The folder *test* contains C and pure Ruby files
for testing purposes which will be used by `mrbtest`. *mrbgem.rake* contains
the specification to compile C and Ruby files. *README.md* is a short description
of your GEM.
contains C/C++ files to extend mruby. The folder *include* contains C/C++ header
files. The folder *test* contains C/C++ and pure Ruby files for testing purposes
which will be used by `mrbtest`. *mrbgem.rake* contains the specification
to compile C and Ruby files. *README.md* is a short description of your GEM.
## Build process
mrbgems expects a specification file called *mrbgem.rake* inside of your
GEM directory. A typical GEM specification could look like this for example:
MRuby::Gem::Specification.new('c_and_ruby_extension_example') do |spec|
spec.license = 'MIT'
spec.author = 'mruby developers'
end
```ruby
MRuby::Gem::Specification.new('c_and_ruby_extension_example') do |spec|
spec.license = 'MIT'
spec.author = 'mruby developers'
spec.summary = 'Example mrbgem using C and ruby'
end
```
The mrbgems build process will use this specification to compile Object and Ruby
files. The compilation results will be added to *lib/libmruby.a*. This file exposes
@@ -113,44 +139,106 @@ information purpose:
* `spec.author` or `spec.authors` (Developer name or a list of them)
* `spec.version` (Current version)
* `spec.description` (Detailed description)
* `spec.summary` (Short summary)
* `spec.summary`
* One line short description of mrbgem.
* Printed in build summary of rake when set.
* `spec.homepage` (Homepage)
* `spec.requirements` (External requirements as information for user)
The license and author properties are required in every GEM!
The `license` and `author` properties are required in every GEM!
In case your GEM is depending on other GEMs please use
`spec.add_dependency(gem, *requirements)` like:
`spec.add_dependency(gem, *requirements[, default_get_info])` like:
```ruby
MRuby::Gem::Specification.new('c_and_ruby_extension_example') do |spec|
spec.license = 'MIT'
spec.author = 'mruby developers'
MRuby::Gem::Specification.new('c_and_ruby_extension_example') do |spec|
spec.license = 'MIT'
spec.author = 'mruby developers'
# Add GEM dependency mruby-parser.
# The version must be between 1.0.0 and 1.5.2 .
spec.add_dependency('mruby-parser', '>= 1.0.0', '<= 1.5.2')
# add GEM dependency mruby-parser.
# Version has to be between 1.0.0 and 1.5.2
spec.add_dependency('mruby-parser', '> 1.0.0', '< 1.5.2')
end
# Use any version of mruby-uv from github.
spec.add_dependency('mruby-uv', '>= 0.0.0', :github => 'mattn/mruby-uv')
The usage of versions is optional.
# Use latest mruby-onig-regexp from github. (version requirements can be omitted)
spec.add_dependency('mruby-onig-regexp', :github => 'mattn/mruby-onig-regexp')
__ATTENTION:__
The dependency system is currently (May 2013) under development and doesn't check
or resolve dependencies!
# You can add extra mgems active only on test
spec.add_test_dependency('mruby-process', :github => 'iij/mruby-process')
end
```
The version requirements and default gem information are optional.
Version requirement supports following operators:
* '=': is equal
* '!=': is not equal
* '>': is greater
* '<': is lesser
* '>=': is equal or greater
* '<=': is equal or lesser
* '~>': is equal or greater and is lesser than the next major version
* example 1: '~> 2.2.2' means '>= 2.2.2' and '< 2.3.0'
* example 2: '~> 2.2' means '>= 2.2.0' and '< 3.0.0'
When more than one version requirements is passed, the dependency must satisfy all of it.
You can have default gem to use as dependency when it's not defined in *build_config.rb*.
When the last argument of `add_dependency` call is `Hash`, it will be treated as default gem information.
Its format is same as argument of method `MRuby::Build#gem`, expect that it can't be treated as path gem location.
When a special version of dependency is required,
use `MRuby::Build#gem` in *build_config.rb* to override default gem.
If you have conflicting GEMs use the following method:
* `spec.add_conflict(gem, *requirements)`
* The `requirements` argument is same as in `add_dependency` method.
like following code:
```ruby
MRuby::Gem::Specification.new 'some-regexp-binding' do |spec|
spec.license = 'BSD'
spec.author = 'John Doe'
spec.add_conflict 'mruby-onig-regexp', '> 0.0.0'
spec.add_conflict 'mruby-hs-regexp'
spec.add_conflict 'mruby-pcre-regexp'
spec.add_conflict 'mruby-regexp-pcre'
end
```
In case your GEM has more complex build requirements you can use
the following options additionally inside of your GEM specification:
* `spec.cflags` (C compiler flags)
* `spec.mruby_cflags` (global C compiler flags for everything)
* `spec.mruby_ldflags` (global linker flags for everything)
* `spec.mruby_libs` (global libraries for everything)
* `spec.mruby_includes` (global includes for everything)
* `spec.cc.flags` (C compiler flags)
* `spec.cc.defines` (C compiler defines)
* `spec.cc.include_paths` (C compiler include paths)
* `spec.linker.flags` (Linker flags)
* `spec.linker.libraries` (Linker libraries)
* `spec.linker.library_paths` (Linker additional library path)
* `spec.bins` (Generate binary file)
* `spec.rbfiles` (Ruby files to compile)
* `spec.objs` (Object files to compile)
* `spec.test_rbfiles` (Ruby test files for integration into mrbtest)
* `spec.test_objs` (Object test files for integration into mrbtest)
* `spec.test_preload` (Initialization files for mrbtest)
You also can use `spec.mruby.cc` and `spec.mruby.linker` to add extra global parameters for compiler and linker.
### include_paths and dependency
Your GEM can export include paths to another GEMs that depends on your GEM.
By default, `/...absolute path.../{GEM_NAME}/include` will be exported.
So it is recommended not to put GEM's local header files on include/.
These exports are retroactive.
For example: when B depends to C and A depends to B, A will get include paths exported by C.
Exported include_paths are automatically appended to GEM local include_paths by Minirake.
You can use `spec.export_include_paths` accessor if you want more complex build.
## C Extension
mruby can be extended with C. This is possible by using the C API to
@@ -162,12 +250,13 @@ mrbgems expects that you have implemented a C method called
`mrb_YOURGEMNAME_gem_init(mrb_state)`. `YOURGEMNAME` will be replaced
by the name of your GEM. If you call your GEM *c_extension_example*, your
initialisation method could look like this:
void
mrb_c_extension_example_gem_init(mrb_state* mrb) {
struct RClass *class_cextension = mrb_define_module(mrb, "CExtension");
mrb_define_class_method(mrb, class_cextension, "c_method", mrb_c_method, MRB_ARGS_NONE());
}
```C
void
mrb_c_extension_example_gem_init(mrb_state* mrb) {
struct RClass *class_cextension = mrb_define_module(mrb, "CExtension");
mrb_define_class_method(mrb, class_cextension, "c_method", mrb_c_method, MRB_ARGS_NONE());
}
```
### Finalize
@@ -176,10 +265,12 @@ mrbgems expects that you have implemented a C method called
by the name of your GEM. If you call your GEM *c_extension_example*, your
finalizer method could look like this:
void
mrb_c_extension_example_gem_final(mrb_state* mrb) {
free(someone);
}
```C
void
mrb_c_extension_example_gem_final(mrb_state* mrb) {
free(someone);
}
```
### Example
@@ -203,6 +294,7 @@ mruby can be extended with pure Ruby. It is possible to override existing
classes or add new ones in this way. Put all Ruby files into the *mrblib*
folder.
### Pre-Conditions
none
@@ -229,6 +321,10 @@ mruby can be extended with C and Ruby at the same time. It is possible to
override existing classes or add new ones in this way. Put all Ruby files
into the *mrblib* folder and all C files into the *src* folder.
mruby codes under *mrblib* directory would be executed after gem init C
function is called. Make sure *mruby script* depends on *C code* and
*C code* doesn't depend on *mruby script*.
### Pre-Conditions
See C and Ruby example.
+299
View File
@@ -0,0 +1,299 @@
# Limitations and Differences
The philosophy of mruby is to be a lightweight implementation of
the Ruby ISO standard. These two objectives are partially contradicting.
Ruby is an expressive language with complex implementation details which
are difficult to implement in a lightweight manner. To cope with this,
limitations to the "Ruby Compatibility" are defined.
This document is collecting these limitations.
## Integrity
This document does not contain a complete list of limitations.
Please help to improve it by submitting your findings.
## `1/2` gives `0.5`
Since mruby does not have `Bignum`, bigger integers are represented
by `Float` numbers. To enhance interoperability between `Fixnum`
and `Float`, mruby provides `Float#upto` and other iterating
methods for the `Float` class. As a side effect, `1/2` gives `0.5`
not `0`.
## `Array` passed to `puts`
Passing an Array to `puts` results in different output.
```ruby
puts [1,2,3]
```
#### Ruby [ruby 2.0.0p645 (2015-04-13 revision 50299)]
```
1
2
3
```
#### mruby [2.1.0 (2019-10-18)]
```
[1, 2, 3]
```
## `Kernel.raise` in rescue clause
`Kernel.raise` without arguments does not raise the current exception within
a rescue clause.
```ruby
begin
1 / 0
rescue
raise
end
```
#### Ruby [ruby 2.0.0p645 (2015-04-13 revision 50299)]
`ZeroDivisionError` is raised.
#### mruby [2.1.0 (2019-10-18)]
No exception is raised.
## Fiber execution can't cross C function boundary
mruby's `Fiber` is implemented in a similar way to Lua's co-routine. This
results in the consequence that you can't switch context within C functions.
Only exception is `mrb_fiber_yield` at return.
## `Array` does not support instance variables
To reduce memory consumption `Array` does not support instance variables.
```ruby
class Liste < Array
def initialize(str = nil)
@feld = str
end
end
p Liste.new "foobar"
```
#### Ruby [ruby 2.0.0p645 (2015-04-13 revision 50299)]
` [] `
#### mruby [2.1.0 (2019-10-18)]
`ArgumentError` is raised.
## Method visibility
For simplicity reasons no method visibility (public/private/protected) is
supported. Those methods are defined but they are dummy methods.
```ruby
class VisibleTest
def public_method; end
private
def private_method; end
end
p VisibleTest.new.respond_to?(:private_method, false)
p VisibleTest.new.respond_to?(:private_method, true)
```
#### Ruby [ruby 2.0.0p645 (2015-04-13 revision 50299)]
```
false
true
```
#### mruby [2.1.0 (2019-10-18)]
```
true
true
```
### Visibility Declaration
The declaration form of following visibility methods are not implemented.
* `public`
* `private`
* `protected`
* `module_function`
Especially, `module_function` method is not dummy, but no declaration form.
```
module TestModule
module_function
def test_func
p 'test_func called'
end
test_func
end
p 'ok'
```
#### Ruby [ruby 2.5.5p157 (2019-03-15 revision 67260)]
```
ok
```
#### mruby [2.1.0 (2019-10-18)]
```
test.rb:8: undefined method 'test_func' (NoMethodError)
```
## `defined?`
The `defined?` keyword is considered too complex to be fully
implemented. It is recommended to use `const_defined?` and
other reflection methods instead.
```ruby
defined?(Foo)
```
#### Ruby [ruby 2.0.0p645 (2015-04-13 revision 50299)]
```
nil
```
#### mruby [2.1.0 (2019-10-18)]
`NameError` is raised.
## `alias` on global variables
Aliasing a global variable works in CRuby but is not part
of the ISO standard.
```ruby
alias $a $__a__
```
#### Ruby [ruby 2.0.0p645 (2015-04-13 revision 50299)]
` nil `
#### mruby [2.1.0 (2019-10-18)]
Syntax error
## Operator modification
An operator can't be overwritten by the user.
```ruby
class String
def +
end
end
'a' + 'b'
```
#### Ruby [ruby 2.0.0p645 (2015-04-13 revision 50299)]
`ArgumentError` is raised.
The re-defined `+` operator does not accept any arguments.
#### mruby [2.1.0 (2019-10-18)]
` 'ab' `
Behavior of the operator wasn't changed.
## `Kernel#binding` is not supported
`Kernel#binding` method is not supported.
#### Ruby [ruby 2.5.1p57 (2018-03-29 revision 63029)]
```
$ ruby -e 'puts Proc.new {}.binding'
#<Binding:0x00000e9deabb9950>
```
#### mruby [2.1.0 (2019-10-18)]
```
$ ./bin/mruby -e 'puts Proc.new {}.binding'
trace (most recent call last):
[0] -e:1
-e:1: undefined method 'binding' (NoMethodError)
```
## Keyword arguments
mruby keyword arguments behave slightly different from CRuby 2.5
to make the behavior simpler and less confusing. Maybe in the
future, the simpler behavior will be adopted to CRuby as well.
#### Ruby [ruby 2.5.1p57 (2018-03-29 revision 63029)]
```
$ ruby -e 'def m(*r,**k) p [r,k] end; m("a"=>1,:b=>2)'
[[{"a"=>1}], {:b=>2}]
```
#### mruby [mruby 2.1.0]
```
$ ./bin/mruby -e 'def m(*r,**k) p [r,k] end; m("a"=>1,:b=>2)'
trace (most recent call last):
[0] -e:1
-e:1: keyword argument hash with non symbol keys (ArgumentError)
```
## Argument Destructuring
```ruby
def m(a,(b,c),d); p [a,b,c,d]; end
m(1,[2,3],4) # => [1,2,3,4]
```
Destructured arguments (`b` and `c` in above example) cannot be accessed
from the default expression of optional arguments and keyword arguments,
since actual assignment is done after the evaluation of those default
expressions. Thus:
```ruby
def f(a,(b,c),d=b)
p [a,b,c,d]
end
f(1,[2,3])
```
CRuby gives `[1,2,3,nil]`. mruby raises `NoMethodError` for `b`.
## `nil?` redefinition in conditional expressions
Redefinition of `nil?` is ignored in conditional expressions.
```ruby
a = "a"
def a.nil?
true
end
puts(a.nil? ? "truthy" : "falsy")
```
Ruby outputs `falsy`. mruby outputs `truthy`.
Binary file not shown.

After

Width:  |  Height:  |  Size: 8.4 KiB

+127
View File
@@ -0,0 +1,127 @@
# The new bytecode
We will reimplement VM to use 8bit instruction code. By
bytecode, we mean real byte code. The whole purpose is
reducing the memory consumption of mruby VM.
# Instructions
Instructions are bytes. There can be 256 instructions. Currently we
have 94 instructions. Instructions can take 0 to 3 operands.
## operands
The size of operands can be either 8bits, 16bits or 24bits.
In the table.1 below, the second field describes the size (and
sign) of operands.
* B: 8bit
* sB: signed 8bit
* S: 16bit
* sS: signed 16bit
* W: 24bit
First two byte operands may be extended to 16bit. When those byte
operands are bigger than 256, the instruction will be prefixed by
`OP_EXT1` (means 1st operand is 16bit) or `OP_EXT2` (means 2nd operand
is 16bit) or `OP_EXT3` (means 1st and 2nd operands are 16bit).
For instructions marked by `'`, `OP_EXT1` can be prefixed. For those
with `"`, either `OP_EXT1` or `OP_EXT2` or `OP_EXT2` can be prefixed.
## table.1 Instruction Table
| Instruction Name | Operand type | Semantics |
|:-----------------|--------------|---------------------|
| OP_NOP | - | |
| OP_MOVE" | BB | R(a) = R(b)
| OP_LOADL" | BB | R(a) = Pool(b)
| OP_LOADI" | BsB | R(a) = mrb_int(b)
| OP_LOADI_0' | B | R(a) = 0
| OP_LOADI_1' | B | R(a) = 1
| OP_LOADI_2' | B | R(a) = 2
| OP_LOADI_3' | B | R(a) = 3
| OP_LOADSYM" | BB | R(a) = Syms(b)
| OP_LOADNIL' | B | R(a) = nil
| OP_LOADSELF' | B | R(a) = self
| OP_LOADT' | B | R(a) = true
| OP_LOADF' | B | R(a) = false
| OP_GETGV" | BB | R(a) = getglobal(Syms(b))
| OP_SETGV" | BB | setglobal(Syms(b), R(a))
| OP_GETSV" | BB | R(a) = Special[b]
| OP_SETSV" | BB | Special[b] = R(a)
| OP_GETIV" | BB | R(a) = ivget(Syms(b))
| OP_SETIV" | BB | ivset(Syms(b),R(a))
| OP_GETCV" | BB | R(a) = cvget(Syms(b))
| OP_SETCV" | BB | cvset(Syms(b),R(a))
| OP_GETCONST" | BB | R(a) = constget(Syms(b))
| OP_SETCONST" | BB | constset(Syms(b),R(a))
| OP_GETMCNST" | BB | R(a) = R(a)::Syms(b)
| OP_SETMCNST" | BB | R(a+1)::Syms(b) = R(a)
| OP_GETUPVAR' | BBB | R(a) = uvget(b,c)
| OP_SETUPVAR' | BBB | uvset(b,c,R(a))
| OP_JMP | S | pc+=a
| OP_JMPIF' | SB | if R(b) pc+=a
| OP_JMPNOT' | SB | if !R(b) pc+=a
| OP_ONERR | sS | rescue_push(pc+a)
| OP_EXCEPT' | B | R(a) = exc
| OP_RESCUE" | BB | R(b) = R(a).isa?(R(b))
| OP_POPERR | B | a.times{rescue_pop()}
| OP_RAISE' | B | raise(R(a))
| OP_EPUSH' | B | ensure_push(SEQ[a])
| OP_EPOP | B | A.times{ensure_pop().call}
| OP_SENDV" | BB | R(a) = call(R(a),Syms(b),*R(a+1))
| OP_SENDVB" | BB | R(a) = call(R(a),Syms(b),*R(a+1),&R(a+2))
| OP_SEND" | BBB | R(a) = call(R(a),Syms(b),R(a+1),...,R(a+c))
| OP_SENDB" | BBB | R(a) = call(R(a),Syms(Bx),R(a+1),...,R(a+c),&R(a+c+1))
| OP_CALL' | B | R(a) = self.call(frame.argc, frame.argv)
| OP_SUPER' | BB | R(a) = super(R(a+1),... ,R(a+b+1))
| OP_ARGARY' | BS | R(a) = argument array (16=5:1:5:1:4)
| OP_ENTER | W | arg setup according to flags (23=5:5:1:5:5:1:1)
| OP_KARG" | BB | R(a) = kdict[Syms(Bx)] # todo
| OP_KARG2" | BB | R(a) = kdict[Syms(Bx)]; kdict.rm(Syms(b)) # todo
| OP_RETURN' | B | return R(a) (normal)
| OP_RETURN_BLK' | B | return R(a) (in-block return)
| OP_BREAK' | B | break R(a)
| OP_BLKPUSH' | BS | R(a) = block (16=5:1:5:1:4)
| OP_ADD" | BB | R(a) = R(a)+R(a+1)
| OP_ADDI" | BBB | R(a) = R(a)+mrb_int(c)
| OP_SUB" | BB | R(a) = R(a)-R(a+1)
| OP_SUBI" | BB | R(a) = R(a)-C
| OP_MUL" | BB | R(a) = R(a)*R(a+1)
| OP_DIV" | BB | R(a) = R(a)/R(a+1)
| OP_EQ" | BB | R(a) = R(a)==R(a+1)
| OP_LT" | BB | R(a) = R(a)<R(a+1)
| OP_LE" | BB | R(a) = R(a)<=R(a+1)
| OP_GT" | BB | R(a) = R(a)>R(a+1)
| OP_GE" | BB | R(a) = R(a)>=R(a+1)
| OP_ARRAY' | BB | R(a) = ary_new(R(a),R(a+1)..R(a+b))
| OP_ARRAY2" | BB | R(a) = ary_new(R(b),R(b+1)..R(b+c))
| OP_ARYCAT' | B | ary_cat(R(a),R(a+1))
| OP_ARYPUSH' | B | ary_push(R(a),R(a+1))
| OP_AREF' | BB | R(a) = R(a)[b]
| OP_ASET' | BB | R(a)[b] = R(a+1)
| OP_APOST' | BB | *R(a),R(A+1)..R(A+C) = R(a)[B..]
| OP_STRING" | BB | R(a) = str_dup(Lit(b))
| OP_STRCAT' | B | str_cat(R(a),R(a+1))
| OP_HASH' | BB | R(a) = hash_new(R(a),R(a+1)..R(a+b))
| OP_HASHADD' | BB | R(a) = hash_push(R(a),R(a+1)..R(a+b))
| OP_LAMBDA" | BB | R(a) = lambda(SEQ[b],OP_L_LAMBDA)
| OP_BLOCK" | BB | R(a) = lambda(SEQ[b],OP_L_BLOCK)
| OP_METHOD" | BB | R(a) = lambda(SEQ[b],OP_L_METHOD)
| OP_RANGE_INC' | B | R(a) = range_new(R(a),R(a+1),FALSE)
| OP_RANGE_EXC' | B | R(a) = range_new(R(a),R(a+1),TRUE)
| OP_OCLASS' | B | R(a) = ::Object
| OP_CLASS" | BB | R(a) = newclass(R(a),Syms(b),R(a+1))
| OP_MODULE" | BB | R(a) = newmodule(R(a),Syms(b))
| OP_EXEC" | BB | R(a) = blockexec(R(a),SEQ[b])
| OP_DEF" | BB | R(a).newmethod(Syms(b),R(a+1))
| OP_ALIAS' | B | alias_method(R(a),R(a+1),R(a+2))
| OP_UNDEF" | BB | undef_method(R(a),Syms(b))
| OP_SCLASS' | B | R(a) = R(a).singleton_class
| OP_TCLASS' | B | R(a) = target_class
| OP_ERR' | B | raise(RuntimeError, Lit(Bx))
| OP_EXT1 | - | make 1st operand 16bit
| OP_EXT2 | - | make 2nd operand 16bit
| OP_EXT3 | - | make 1st and 2nd operands 16bit
| OP_STOP | - | stop VM
@@ -1,7 +1,7 @@
MRuby::Gem::Specification.new('c_and_ruby_extension_example') do |spec|
spec.license = 'MIT'
spec.author = 'mruby developers'
# Add compile flags
# spec.cc.flags << ''
@@ -16,5 +16,5 @@ mrb_c_and_ruby_extension_example_gem_init(mrb_state* mrb) {
void
mrb_c_and_ruby_extension_example_gem_final(mrb_state* mrb) {
// finalizer
/* finalizer */
}
@@ -1,7 +1,7 @@
MRuby::Gem::Specification.new('c_extension_example') do |spec|
spec.license = 'MIT'
spec.author = 'mruby developers'
# Add compile flags
# spec.cc.flags << '-g'
@@ -16,5 +16,5 @@ mrb_c_extension_example_gem_init(mrb_state* mrb) {
void
mrb_c_extension_example_gem_final(mrb_state* mrb) {
// finalizer
/* finalizer */
}
@@ -1,7 +1,7 @@
MRuby::Gem::Specification.new('ruby_extension_example') do |spec|
spec.license = 'MIT'
spec.author = 'mruby developers'
# Add compile flags
# spec.cc.flags << ''
@@ -11,6 +11,8 @@ MRuby::Gem::Specification.new('ruby_extension_example') do |spec|
# Add libraries
# spec.linker.libraries << 'external_lib'
spec.add_dependency('mruby-print', :core => 'mruby-print')
# Default build files
# spec.rbfiles = Dir.glob("#{dir}/mrblib/*.rb")
# spec.objs = Dir.glob("#{dir}/src/*.{c,cpp,m,asm,S}").map { |f| objfile(f.relative_path_from(dir).pathmap("#{build_dir}/%X")) }
@@ -1,15 +1,36 @@
MRuby::Build.new do |conf|
# Gets set by the VS command prompts.
if ENV['VisualStudioVersion'] || ENV['VSINSTALLDIR']
toolchain :visualcpp
else
toolchain :gcc
end
enable_debug
# include the default GEMs
conf.gembox 'default'
end
# Cross Compiling configuration for Arduino Due
# http://arduino.cc/en/Main/ArduinoBoardDue
#
# Requires Arduino IDE >= 1.5
MRuby::CrossBuild.new("Arduino Due") do |conf|
MRuby::CrossBuild.new("ArduinoDue") do |conf|
toolchain :gcc
# Mac OS X
# Mac OS X, Arduino IDE <= 1.5.6
# ARDUINO_PATH = '/Applications/Arduino.app/Contents/Resources/Java'
# Mac OS X, Arduino IDE >= 1.5.7
# ARDUINO_PATH = '/Applications/Arduino.app/Contents/Java'
# GNU Linux
ARDUINO_PATH = '/opt/arduino'
# Arduino IDE <= 1.5.6
BIN_PATH = "#{ARDUINO_PATH}/hardware/tools/g++_arm_none_eabi/bin"
# Arduino IDE >= 1.5.7
# BIN_PATH = "#{ARDUINO_PATH}/hardware/tools/gcc-arm-none-eabi-4.8.3-2014q1/bin"
SAM_PATH = "#{ARDUINO_PATH}/hardware/arduino/sam"
TARGET_PATH = "#{SAM_PATH}/variants/arduino_due_x"
@@ -18,17 +39,17 @@ MRuby::CrossBuild.new("Arduino Due") do |conf|
cc.include_paths << ["#{SAM_PATH}/system/libsam", "#{SAM_PATH}/system/CMSIS/CMSIS/Include/",
"#{SAM_PATH}/system/CMSIS/Device/ATMEL/",
"#{SAM_PATH}/cores/arduino", "#{SAM_PATH}/libraries","#{TARGET_PATH}"]
cc.flags = %w(-g -Os -w -ffunction-sections -fdata-sections -nostdlib --param max-inline-insns-single=500
-Dprintf=iprintf -mcpu=cortex-m3 -DF_CPU=84000000L -DARDUINO=152 -D__SAM3X8E__ -mthumb -DUSB_PID=0x003e -DUSB_VID=0x2341 -DUSBCON)
cc.flags = %w(-g -Os -w -ffunction-sections -fdata-sections -nostdlib --param max-inline-insns-single=500
-Dprintf=iprintf -mcpu=cortex-m3 -DF_CPU=84000000L -DARDUINO=156 -DARDUINO_SAM_DUE -DARDUINO_ARCH_SAM
-D__SAM3X8E__ -mthumb -DUSB_PID=0x003e -DUSB_VID=0x2341 -DUSBCON -DUSB_MANUFACTURER="Unknown" -DUSB_PRODUCT="Arduino Due")
cc.compile_options = "%{flags} -o %{outfile} -c %{infile}"
#configuration for low memory environment
cc.defines << %w(MRB_HEAP_PAGE_SIZE=64)
cc.defines << %w(MRB_USE_IV_SEGLIST)
cc.defines << %w(KHASH_DEFAULT_SIZE=8)
cc.defines << %w(MRB_STR_BUF_MIN_SIZE=20)
cc.defines << %w(MRB_GC_STRESS)
#cc.defines << %w(DISABLE_STDIO) #if you dont need stdio.
#cc.defines << %w(MRB_DISABLE_STDIO) #if you dont need stdio.
#cc.defines << %w(POOL_PAGE_SIZE=1000) #effective only for use with mruby-eval
end
@@ -36,6 +57,7 @@ MRuby::CrossBuild.new("Arduino Due") do |conf|
cxx.command = conf.cc.command.dup
cxx.include_paths = conf.cc.include_paths.dup
cxx.flags = conf.cc.flags.dup
cxx.flags << %w(-fno-rtti -fno-exceptions)
cxx.defines = conf.cc.defines.dup
cxx.compile_options = conf.cc.compile_options.dup
end
@@ -51,13 +73,16 @@ MRuby::CrossBuild.new("Arduino Due") do |conf|
#do not build executable test
conf.build_mrbtest_lib_only
#disable C++ exception
conf.disable_cxx_exception
#gems from core
conf.gem :core => "mruby-print"
conf.gem :core => "mruby-print"
conf.gem :core => "mruby-math"
conf.gem :core => "mruby-enum-ext"
#light-weight regular expression
conf.gem :github => "masamitsu-murase/mruby-hs-regexp", :branch => "master"
conf.gem :github => "masamitsu-murase/mruby-hs-regexp", :branch => "master"
#Arduino API
#conf.gem :github =>"kyab/mruby-arduino", :branch => "master"
@@ -0,0 +1,69 @@
# Cross-compiling setup for Intel Edison (poky linux) platform
# Get SDK from here: https://software.intel.com/en-us/iot/hardware/edison/downloads
# REMEMBER to check and update the SDK root in the constant POKY_EDISON_PATH
MRuby::Build.new do |conf|
toolchain :gcc
conf.gembox 'default'
conf.cc.defines = %w(ENABLE_READLINE)
conf.gembox 'default'
#lightweight regular expression
conf.gem :github => "pbosetti/mruby-hs-regexp", :branch => "master"
end
# Define cross build settings
MRuby::CrossBuild.new('core2-32-poky-linux') do |conf|
toolchain :gcc
# Mac OS X
#
POKY_EDISON_PATH = '/opt/poky-edison/1.7.2'
POKY_EDISON_SYSROOT = "#{POKY_EDISON_PATH}/sysroots/core2-32-poky-linux"
POKY_EDISON_X86_PATH = "#{POKY_EDISON_PATH}/sysroots/i386-pokysdk-darwin"
POKY_EDISON_BIN_PATH = "#{POKY_EDISON_X86_PATH}/usr/bin/i586-poky-linux"
conf.cc do |cc|
cc.command = "#{POKY_EDISON_BIN_PATH}/i586-poky-linux-gcc"
cc.include_paths << ["#{POKY_EDISON_SYSROOT}/usr/include", "#{POKY_EDISON_X86_PATH}/usr/include"]
cc.flags = %w(-m32 -march=core2 -mtune=core2 -msse3 -mfpmath=sse -mstackrealign -fno-omit-frame-pointer)
cc.flags << %w(-O2 -pipe -g -feliminate-unused-debug-types)
cc.flags << "--sysroot=#{POKY_EDISON_SYSROOT}"
cc.compile_options = "%{flags} -o %{outfile} -c %{infile}"
cc.defines = %w(ENABLE_READLINE)
end
conf.cxx do |cxx|
cxx.command = "#{POKY_EDISON_BIN_PATH}/i586-poky-linux-g++"
cxx.include_paths = conf.cc.include_paths.dup
cxx.include_paths << ["#{POKY_EDISON_SYSROOT}/usr/include/c++/4.9.1"]
cxx.flags = conf.cc.flags.dup
cxx.defines = conf.cc.defines.dup
cxx.compile_options = conf.cc.compile_options.dup
end
conf.archiver do |archiver|
archiver.command = "#{POKY_EDISON_BIN_PATH}/i586-poky-linux-ar"
archiver.archive_options = 'rcs %{outfile} %{objs}'
end
conf.linker do |linker|
linker.command = "#{POKY_EDISON_BIN_PATH}/i586-poky-linux-g++"
linker.flags = %w(-m32 -march=i586)
linker.flags << "--sysroot=#{POKY_EDISON_SYSROOT}"
linker.flags << %w(-O1)
linker.libraries = %w(m pthread)
end
#do not build executable test
conf.build_mrbtest_lib_only
conf.gembox 'default'
#lightweight regular expression
conf.gem :github => "pbosetti/mruby-hs-regexp", :branch => "master"
end
@@ -0,0 +1,106 @@
MRuby::Build.new do |conf|
# Gets set by the VS command prompts.
if ENV['VisualStudioVersion'] || ENV['VSINSTALLDIR']
toolchain :visualcpp
else
toolchain :gcc
end
enable_debug
# include the default GEMs
conf.gembox 'default'
end
# Cross Compiling configuration for Intel Galileo on Arduino environment
# http://arduino.cc/en/ArduinoCertified/IntelGalileo
#
# Requires Arduino IDE for Intel Galileo
MRuby::CrossBuild.new("Galileo") do |conf|
toolchain :gcc
# Mac OS X
# Assume you renamed Arduino.app to Arduino_Galileo.app
GALILEO_ARDUINO_PATH = '/Applications/Arduino_Galileo.app/Contents/Resources/Java'
# GNU Linux
#ARDUINO_GALILEO_PATH = '/opt/arduino'
GALILEO_BIN_PATH = "#{GALILEO_ARDUINO_PATH}/hardware/tools/x86/i386-pokysdk-darwin/usr/bin/i586-poky-linux-uclibc"
GALILEO_SYSROOT = "#{GALILEO_ARDUINO_PATH}/hardware/tools/x86/i586-poky-linux-uclibc"
GALILEO_X86_PATH = "#{GALILEO_ARDUINO_PATH}/hardware/arduino/x86"
conf.cc do |cc|
cc.command = "#{GALILEO_BIN_PATH}/i586-poky-linux-uclibc-gcc"
cc.include_paths << ["#{GALILEO_X86_PATH}/cores/arduino", "#{GALILEO_X86_PATH}/variants/galileo_fab_d"]
cc.flags = %w(-m32 -march=i586 -c -g -Os -w
-ffunction-sections -fdata-sections -MMD -DARDUINO=153)
cc.flags << "--sysroot=#{GALILEO_SYSROOT}"
cc.compile_options = "%{flags} -o %{outfile} -c %{infile}"
end
conf.cxx do |cxx|
cxx.command = "#{GALILEO_BIN_PATH}/i586-poky-linux-uclibc-g++"
cxx.include_paths = conf.cc.include_paths.dup
cxx.include_paths << "#{GALILEO_ARDUINO_PATH}/hardware/tools/x86/i586-poky-linux-uclibc/usr/include/c++"
cxx.include_paths << "#{GALILEO_ARDUINO_PATH}/hardware/tools/x86/i586-poky-linux-uclibc/usr/include/c++/i586-poky-linux-uclibc"
cxx.flags = conf.cc.flags.dup
cxx.defines = conf.cc.defines.dup
cxx.compile_options = conf.cc.compile_options.dup
end
conf.archiver do |archiver|
archiver.command = "#{GALILEO_BIN_PATH}/i586-poky-linux-uclibc-ar"
archiver.archive_options = 'rcs %{outfile} %{objs}'
end
conf.linker do |linker|
linker.command = "#{GALILEO_BIN_PATH}/i586-poky-linux-uclibc-g++"
linker.flags = %w(-m32 -march=i586)
linker.flags << "--sysroot=#{GALILEO_SYSROOT}"
linker.flags << %w(-Os -Wl,--gc-sections)
linker.libraries = %w(m pthread)
end
#no executables
conf.bins = []
#do not build executable test
conf.build_mrbtest_lib_only
#official mrbgems
conf.gem :core => "mruby-sprintf"
conf.gem :core => "mruby-print"
conf.gem :core => "mruby-math"
conf.gem :core => "mruby-time"
conf.gem :core => "mruby-struct"
conf.gem :core => "mruby-enum-ext"
conf.gem :core => "mruby-string-ext"
conf.gem :core => "mruby-numeric-ext"
conf.gem :core => "mruby-array-ext"
conf.gem :core => "mruby-hash-ext"
conf.gem :core => "mruby-range-ext"
conf.gem :core => "mruby-proc-ext"
conf.gem :core => "mruby-symbol-ext"
conf.gem :core => "mruby-random"
conf.gem :core => "mruby-object-ext"
conf.gem :core => "mruby-objectspace"
conf.gem :core => "mruby-fiber"
conf.gem :core => "mruby-toplevel-ext"
#lightweigh regular expression
conf.gem :github => "masamitsu-murase/mruby-hs-regexp", :branch => "master"
#Arduino API
#conf.gem :github =>"kyab/mruby-arduino", :branch => "master" do |g|
# g.cxx.include_paths << "#{GALILEO_X86_PATH}/libraries/Wire"
# g.cxx.include_paths << "#{GALILEO_X86_PATH}/libraries/Servo"
#enable unsupported Servo class
# g.cxx.defines << "MRUBY_ARDUINO_GALILEO_ENABLE_SERVO"
#end
end
+81
View File
@@ -0,0 +1,81 @@
MRuby::Build.new do |conf|
# Gets set by the VS command prompts.
if ENV['VisualStudioVersion'] || ENV['VSINSTALLDIR']
toolchain :visualcpp
else
toolchain :gcc
end
enable_debug
# include the default GEMs
conf.gembox 'default'
end
# Cross Compiling configuration for RX630
# http://gadget.renesas.com/
#
# Requires gnurx_v14.03
MRuby::CrossBuild.new("RX630") do |conf|
toolchain :gcc
# Linux
BIN_PATH = "/usr/share/gnurx_v14.03_elf-1/bin"
conf.cc do |cc|
cc.command = "#{BIN_PATH}/rx-elf-gcc"
cc.flags = "-Wall -g -O2 -flto -mcpu=rx600 -m64bit-doubles"
cc.compile_options = "%{flags} -o %{outfile} -c %{infile}"
#configuration for low memory environment
cc.defines << %w(MRB_USE_FLOAT)
cc.defines << %w(MRB_HEAP_PAGE_SIZE=64)
cc.defines << %w(KHASH_DEFAULT_SIZE=8)
cc.defines << %w(MRB_STR_BUF_MIN_SIZE=20)
cc.defines << %w(MRB_GC_STRESS)
cc.defines << %w(MRB_DISABLE_STDIO) #if you dont need stdio.
#cc.defines << %w(POOL_PAGE_SIZE=1000) #effective only for use with mruby-eval
end
conf.cxx do |cxx|
cxx.command = conf.cc.command.dup
cxx.include_paths = conf.cc.include_paths.dup
cxx.flags = conf.cc.flags.dup
cxx.defines = conf.cc.defines.dup
cxx.compile_options = conf.cc.compile_options.dup
end
conf.linker do |linker|
linker.command="#{BIN_PATH}/rx-elf-ld"
end
conf.archiver do |archiver|
archiver.command = "#{BIN_PATH}/rx-elf-ar"
archiver.archive_options = 'rcs %{outfile} %{objs}'
end
#no executables
conf.bins = []
#do not build executable test
conf.build_mrbtest_lib_only
#disable C++ exception
conf.disable_cxx_exception
#gems from core
conf.gem :core => "mruby-sprintf"
conf.gem :core => "mruby-print"
conf.gem :core => "mruby-math"
conf.gem :core => "mruby-enum-ext"
conf.gem :core => "mruby-numeric-ext"
#light-weight regular expression
#conf.gem :github => "masamitsu-murase/mruby-hs-regexp", :branch => "master"
#Arduino API
#conf.gem :github =>"kyab/mruby-arduino", :branch => "master"
end
@@ -0,0 +1,26 @@
MRuby::Build.new do |conf|
# Gets set by the VS command prompts.
if ENV['VisualStudioVersion'] || ENV['VSINSTALLDIR']
toolchain :visualcpp
else
toolchain :gcc
end
enable_debug
# include the default GEMs
conf.gembox 'default'
end
# Requires Android NDK r13 or later.
MRuby::CrossBuild.new('android-arm64-v8a') do |conf|
params = {
:arch => 'arm64-v8a',
:platform => 'android-24',
:toolchain => :clang,
}
toolchain :android, params
conf.gembox 'default'
end
@@ -0,0 +1,26 @@
MRuby::Build.new do |conf|
# Gets set by the VS command prompts.
if ENV['VisualStudioVersion'] || ENV['VSINSTALLDIR']
toolchain :visualcpp
else
toolchain :gcc
end
enable_debug
# include the default GEMs
conf.gembox 'default'
end
# Requires Android NDK r13 or later.
MRuby::CrossBuild.new('android-armeabi') do |conf|
params = {
:arch => 'armeabi',
:platform => 'android-24',
:toolchain => :clang,
}
toolchain :android, params
conf.gembox 'default'
end
@@ -0,0 +1,28 @@
MRuby::Build.new do |conf|
# Gets set by the VS command prompts.
if ENV['VisualStudioVersion'] || ENV['VSINSTALLDIR']
toolchain :visualcpp
else
toolchain :gcc
end
enable_debug
# include the default GEMs
conf.gembox 'default'
end
# Requires Android NDK r13 or later.
MRuby::CrossBuild.new('android-armeabi-v7a-neon-hard') do |conf|
params = {
:arch => 'armeabi-v7a',
:mfpu => 'neon',
:mfloat_abi => 'hard',
:platform => 'android-24',
:toolchain => :clang,
}
toolchain :android, params
conf.gembox 'default'
end
@@ -1,3 +1,19 @@
MRuby::Build.new do |conf|
# Gets set by the VS command prompts.
if ENV['VisualStudioVersion'] || ENV['VSINSTALLDIR']
toolchain :visualcpp
else
toolchain :gcc
end
enable_debug
# include the default GEMs
conf.gembox 'default'
end
# Cross Compiling configuration for Digilent chipKIT Max32
# http://www.digilentinc.com/Products/Detail.cfm?Prod=CHIPKIT-MAX32
#
@@ -5,7 +21,7 @@
#
# This configuration is based on @kyab's version
# http://d.hatena.ne.jp/kyab/20130201
MRuby::CrossBuild.new("chipKitMax32") do |conf|
MRuby::CrossBuild.new("chipKITMax32") do |conf|
toolchain :gcc
# Mac OS X
@@ -13,25 +29,24 @@ MRuby::CrossBuild.new("chipKitMax32") do |conf|
# GNU Linux
MPIDE_PATH = '/opt/mpide-0023-linux-20120903'
PIC32_PATH = "#{MPIDE_PATH}/hardware/pic32"
PIC32_PATH = "#{MPIDE_PATH}/hardware/pic32"
conf.cc do |cc|
cc.command = "#{PIC32_PATH}/compiler/pic32-tools/bin/pic32-gcc"
cc.include_paths << ["#{PIC32_PATH}/cores/pic32",
"#{PIC32_PATH}/variants/Max32",
"#{PIC32_PATH}/libraries"]
cc.flags = %w(-O2 -mno-smart-io -w -ffunction-sections -fdata-sections -g -mdebugger -Wcast-align
-fno-short-double -mprocessor=32MX795F512L -DF_CPU=80000000L -DARDUINO=23 -D_BOARD_MEGA_
cc.flags = %w(-O2 -mno-smart-io -w -ffunction-sections -fdata-sections -g -mdebugger -Wcast-align
-fno-short-double -mprocessor=32MX795F512L -DF_CPU=80000000L -DARDUINO=23 -D_BOARD_MEGA_
-DMPIDEVER=0x01000202 -DMPIDE=23)
cc.compile_options = "%{flags} -o %{outfile} -c %{infile}"
#configuration for low memory environment
cc.defines << %w(MRB_HEAP_PAGE_SIZE=64)
cc.defines << %w(MRB_USE_IV_SEGLIST)
cc.defines << %w(KHASH_DEFAULT_SIZE=8)
cc.defines << %w(MRB_STR_BUF_MIN_SIZE=20)
cc.defines << %w(MRB_GC_STRESS)
#cc.defines << %w(DISABLE_STDIO) #if you dont need stdio.
#cc.defines << %w(MRB_DISABLE_STDIO) #if you dont need stdio.
#cc.defines << %w(POOL_PAGE_SIZE=1000) #effective only for use with mruby-eval
end
@@ -51,16 +66,19 @@ MRuby::CrossBuild.new("chipKitMax32") do |conf|
#no executables
conf.bins = []
#do not build test executable
#do not build test executable
conf.build_mrbtest_lib_only
#disable C++ exception
conf.disable_cxx_exception
#gems from core
conf.gem :core => "mruby-print"
conf.gem :core => "mruby-print"
conf.gem :core => "mruby-math"
conf.gem :core => "mruby-enum-ext"
#light-weight regular expression
conf.gem :github => "masamitsu-murase/mruby-hs-regexp", :branch => "master"
conf.gem :github => "masamitsu-murase/mruby-hs-regexp", :branch => "master"
#Arduino API
#conf.gem :github =>"kyab/mruby-arduino", :branch => "master"
+147 -22
View File
@@ -7,24 +7,80 @@
#ifndef MRUBYCONF_H
#define MRUBYCONF_H
#include <limits.h>
#include <stdint.h>
/* architecture selection: */
/* specify -DMRB_32BIT or -DMRB_64BIT to override */
#if !defined(MRB_32BIT) && !defined(MRB_64BIT)
#if UINT64_MAX == SIZE_MAX
#define MRB_64BIT
#else
#define MRB_32BIT
#endif
#endif
#if defined(MRB_32BIT) && defined(MRB_64BIT)
#error Cannot build for 32 and 64 bit architecture at the same time
#endif
/* configuration options: */
/* add -DMRB_USE_FLOAT to use float instead of double for floating point numbers */
//#define MRB_USE_FLOAT
/* add -DMRB_INT16 to use 16bit integer for mrb_int; conflict with MRB_INT64 */
/* exclude floating point numbers */
//#define MRB_WITHOUT_FLOAT
/* add -DMRB_METHOD_CACHE to use method cache to improve performance */
//#define MRB_METHOD_CACHE
/* size of the method cache (need to be the power of 2) */
//#define MRB_METHOD_CACHE_SIZE (1<<7)
/* add -DMRB_METHOD_T_STRUCT on machines that use higher bits of pointers */
/* no MRB_METHOD_T_STRUCT requires highest 2 bits of function pointers to be zero */
//#define MRB_METHOD_T_STRUCT
/* add -DMRB_INT16 to use 16bit integer for mrb_int; conflict with MRB_INT32 and MRB_INT64 */
//#define MRB_INT16
/* add -DMRB_INT64 to use 64bit integer for mrb_int; conflict with MRB_INT16 */
/* add -DMRB_INT32 to use 32bit integer for mrb_int; conflict with MRB_INT16 and MRB_INT64;
Default for 32-bit CPU mode. */
//#define MRB_INT32
/* add -DMRB_INT64 to use 64bit integer for mrb_int; conflict with MRB_INT16 and MRB_INT32;
Default for 64-bit CPU mode. */
//#define MRB_INT64
/* represent mrb_value in boxed double; conflict with MRB_USE_FLOAT */
/* if no specific integer type is chosen */
#if !defined(MRB_INT16) && !defined(MRB_INT32) && !defined(MRB_INT64)
# if defined(MRB_64BIT) && !defined(MRB_NAN_BOXING)
/* Use 64bit integers on 64bit architecture (without MRB_NAN_BOXING) */
# define MRB_INT64
# else
/* Otherwise use 32bit integers */
# define MRB_INT32
# endif
#endif
#define MRB_COMPLEX_NUMBERS
#define MRB_RATIONAL_NUMBERS
/* define on big endian machines; used by MRB_NAN_BOXING, etc. */
#ifndef MRB_ENDIAN_BIG
# if (defined(BYTE_ORDER) && defined(BIG_ENDIAN) && BYTE_ORDER == BIG_ENDIAN) || \
(defined(__BYTE_ORDER__) && defined(__ORDER_BIG_ENDIAN__) && __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__)
# define MRB_ENDIAN_BIG
# endif
#endif
/* represent mrb_value in boxed double; conflict with MRB_USE_FLOAT and MRB_WITHOUT_FLOAT */
//#define MRB_NAN_BOXING
/* define on big endian machines; used by MRB_NAN_BOXING */
//#define MRB_ENDIAN_BIG
/* represent mrb_value as a word (natural unit of data for the processor) */
// #define MRB_WORD_BOXING
//#define MRB_WORD_BOXING
/* string class to handle UTF-8 encoding */
//#define MRB_UTF8_STRING
/* argv max size in mrb_funcall */
//#define MRB_FUNCALL_ARGC_MAX 16
@@ -32,11 +88,13 @@
/* number of object per heap page */
//#define MRB_HEAP_PAGE_SIZE 1024
/* use segmented list for IV table */
//#define MRB_USE_IV_SEGLIST
/* if __ehdr_start is available, mruby can reduce memory used by symbols */
//#define MRB_USE_LINK_TIME_RO_DATA_P
/* initial size for IV khash; ignored when MRB_USE_IV_SEGLIST is set */
//#define MRB_IVHASH_INIT_SIZE 8
/* if MRB_USE_LINK_TIME_RO_DATA_P does not work,
you can try mrb_ro_data_p() that you have implemented yourself in any file;
prototype is `mrb_bool mrb_ro_data_p(const char *ptr)` */
//#define MRB_USE_CUSTOM_RO_DATA_P
/* turn off generational GC by default */
//#define MRB_GC_TURN_OFF_GENERATIONAL
@@ -59,23 +117,32 @@
/* fixed size GC arena */
//#define MRB_GC_FIXED_ARENA
/* -DDISABLE_XXXX to drop following features */
//#define DISABLE_STDIO /* use of stdio */
/* state atexit stack size */
//#define MRB_FIXED_STATE_ATEXIT_STACK_SIZE 5
/* -DENABLE_XXXX to enable following features */
//#define ENABLE_DEBUG /* hooks for debugger */
/* fixed size state atexit stack */
//#define MRB_FIXED_STATE_ATEXIT_STACK
/* -DMRB_DISABLE_XXXX to drop following features */
//#define MRB_DISABLE_STDIO /* use of stdio */
/* -DMRB_ENABLE_XXXX to enable following features */
//#define MRB_ENABLE_DEBUG_HOOK /* hooks for debugger */
//#define MRB_ENABLE_ALL_SYMBOLS /* Symbols.all_symbols */
/* end of configuration */
/* define ENABLE_XXXX from DISABLE_XXX */
#ifndef DISABLE_STDIO
#define ENABLE_STDIO
#endif
#ifndef ENABLE_DEBUG
#define DISABLE_DEBUG
/* define MRB_DISABLE_XXXX from DISABLE_XXX (for compatibility) */
#ifdef DISABLE_STDIO
#define MRB_DISABLE_STDIO
#endif
#ifdef ENABLE_STDIO
/* define MRB_ENABLE_XXXX from ENABLE_XXX (for compatibility) */
#ifdef ENABLE_DEBUG
#define MRB_ENABLE_DEBUG_HOOK
#endif
#ifndef MRB_DISABLE_STDIO
# include <stdio.h>
#endif
@@ -87,4 +154,62 @@
# define TRUE 1
#endif
/*
** mruby tuning profiles
**/
/* A profile for micro controllers */
#if defined(MRB_CONSTRAINED_BASELINE_PROFILE)
# ifndef KHASH_DEFAULT_SIZE
# define KHASH_DEFAULT_SIZE 16
# endif
# ifndef MRB_STR_BUF_MIN_SIZE
# define MRB_STR_BUF_MIN_SIZE 32
# endif
# ifndef MRB_HEAP_PAGE_SIZE
# define MRB_HEAP_PAGE_SIZE 256
# endif
/* A profile for default mruby */
#elif defined(MRB_BASELINE_PROFILE)
/* A profile for desktop computers or workstations; rich memory! */
#elif defined(MRB_MAIN_PROFILE)
# ifndef MRB_METHOD_CACHE
# define MRB_METHOD_CACHE
# endif
# ifndef MRB_METHOD_CACHE_SIZE
# define MRB_METHOD_CACHE_SIZE (1<<10)
# endif
# ifndef MRB_IV_SEGMENT_SIZE
# define MRB_IV_SEGMENT_SIZE 32
# endif
# ifndef MRB_HEAP_PAGE_SIZE
# define MRB_HEAP_PAGE_SIZE 4096
# endif
/* A profile for server; mruby vm is long life */
#elif defined(MRB_HIGH_PROFILE)
# ifndef MRB_METHOD_CACHE
# define MRB_METHOD_CACHE
# endif
# ifndef MRB_METHOD_CACHE_SIZE
# define MRB_METHOD_CACHE_SIZE (1<<12)
# endif
# ifndef MRB_IV_SEGMENT_SIZE
# define MRB_IV_SEGMENT_SIZE 64
# endif
# ifndef MRB_HEAP_PAGE_SIZE
# define MRB_HEAP_PAGE_SIZE 4096
# endif
#endif
#endif /* MRUBYCONF_H */
+1249 -256
View File
File diff suppressed because it is too large Load Diff
+268 -36
View File
@@ -1,5 +1,5 @@
/*
** mruby/array.h - Array class
/**
** @file mruby/array.h - Array class
**
** See Copyright Notice in mruby.h
*/
@@ -7,58 +7,290 @@
#ifndef MRUBY_ARRAY_H
#define MRUBY_ARRAY_H
#if defined(__cplusplus)
extern "C" {
#endif
#include "common.h"
/*
* Array class
*/
MRB_BEGIN_DECL
typedef struct mrb_shared_array {
int refcnt;
mrb_value *ptr;
mrb_int len;
mrb_value *ptr;
} mrb_shared_array;
#define MRB_ARY_EMBED_LEN_MAX ((mrb_int)(sizeof(void*)*3/sizeof(mrb_value)))
struct RArray {
MRB_OBJECT_HEADER;
mrb_int len;
union {
mrb_int capa;
mrb_shared_array *shared;
} aux;
mrb_value *ptr;
struct {
mrb_int len;
union {
mrb_int capa;
mrb_shared_array *shared;
} aux;
mrb_value *ptr;
} heap;
void *ary[3];
} as;
};
#define mrb_ary_ptr(v) ((struct RArray*)(mrb_ptr(v)))
#define mrb_ary_value(p) mrb_obj_value((void*)(p))
#define RARRAY(v) ((struct RArray*)(mrb_ptr(v)))
#define RARRAY_LEN(a) (RARRAY(a)->len)
#define RARRAY_PTR(a) (RARRAY(a)->ptr)
#define MRB_ARY_EMBED_MASK 7
#define ARY_EMBED_P(a) ((a)->flags & MRB_ARY_EMBED_MASK)
#define ARY_UNSET_EMBED_FLAG(a) ((a)->flags &= ~(MRB_ARY_EMBED_MASK))
#define ARY_EMBED_LEN(a) ((mrb_int)(((a)->flags & MRB_ARY_EMBED_MASK) - 1))
#define ARY_SET_EMBED_LEN(a,len) ((a)->flags = ((a)->flags&~MRB_ARY_EMBED_MASK) | ((uint32_t)(len) + 1))
#define ARY_EMBED_PTR(a) ((mrb_value*)(&(a)->as.ary))
#define ARY_LEN(a) (ARY_EMBED_P(a)?ARY_EMBED_LEN(a):(a)->as.heap.len)
#define ARY_PTR(a) (ARY_EMBED_P(a)?ARY_EMBED_PTR(a):(a)->as.heap.ptr)
#define RARRAY_LEN(a) ARY_LEN(RARRAY(a))
#define RARRAY_PTR(a) ARY_PTR(RARRAY(a))
#define ARY_SET_LEN(a,n) do {\
if (ARY_EMBED_P(a)) {\
mrb_assert((n) <= MRB_ARY_EMBED_LEN_MAX); \
ARY_SET_EMBED_LEN(a,n);\
}\
else\
(a)->as.heap.len = (n);\
} while (0)
#define ARY_CAPA(a) (ARY_EMBED_P(a)?MRB_ARY_EMBED_LEN_MAX:(a)->as.heap.aux.capa)
#define MRB_ARY_SHARED 256
#define ARY_SHARED_P(a) ((a)->flags & MRB_ARY_SHARED)
#define ARY_SET_SHARED_FLAG(a) ((a)->flags |= MRB_ARY_SHARED)
#define ARY_UNSET_SHARED_FLAG(a) ((a)->flags &= ~MRB_ARY_SHARED)
void mrb_ary_modify(mrb_state*, struct RArray*);
void mrb_ary_decref(mrb_state*, mrb_shared_array*);
mrb_value mrb_ary_new_capa(mrb_state*, mrb_int);
mrb_value mrb_ary_new(mrb_state *mrb);
mrb_value mrb_ary_new_from_values(mrb_state *mrb, mrb_int size, const mrb_value *vals);
void mrb_ary_concat(mrb_state*, mrb_value, mrb_value);
mrb_value mrb_ary_splat(mrb_state*, mrb_value);
void mrb_ary_push(mrb_state*, mrb_value, mrb_value);
mrb_value mrb_ary_pop(mrb_state *mrb, mrb_value ary);
mrb_value mrb_ary_aget(mrb_state *mrb, mrb_value self);
mrb_value mrb_ary_ref(mrb_state *mrb, mrb_value ary, mrb_int n);
void mrb_ary_set(mrb_state *mrb, mrb_value ary, mrb_int n, mrb_value val);
mrb_int mrb_ary_len(mrb_state *mrb, mrb_value ary);
void mrb_ary_replace(mrb_state *mrb, mrb_value a, mrb_value b);
mrb_value mrb_check_array_type(mrb_state *mrb, mrb_value self);
mrb_value mrb_ary_unshift(mrb_state *mrb, mrb_value self, mrb_value item);
mrb_value mrb_assoc_new(mrb_state *mrb, mrb_value car, mrb_value cdr);
mrb_value mrb_ary_entry(mrb_value ary, mrb_int offset);
mrb_value mrb_ary_shift(mrb_state *mrb, mrb_value self);
mrb_value mrb_ary_clear(mrb_state *mrb, mrb_value self);
mrb_value mrb_ary_join(mrb_state *mrb, mrb_value ary, mrb_value sep);
MRB_API void mrb_ary_modify(mrb_state*, struct RArray*);
MRB_API mrb_value mrb_ary_new_capa(mrb_state*, mrb_int);
#if defined(__cplusplus)
} /* extern "C" { */
#endif
/*
* Initializes a new array.
*
* Equivalent to:
*
* Array.new
*
* @param mrb The mruby state reference.
* @return The initialized array.
*/
MRB_API mrb_value mrb_ary_new(mrb_state *mrb);
/*
* Initializes a new array with initial values
*
* Equivalent to:
*
* Array[value1, value2, ...]
*
* @param mrb The mruby state reference.
* @param size The numer of values.
* @param vals The actual values.
* @return The initialized array.
*/
MRB_API mrb_value mrb_ary_new_from_values(mrb_state *mrb, mrb_int size, const mrb_value *vals);
/*
* Initializes a new array with two initial values
*
* Equivalent to:
*
* Array[car, cdr]
*
* @param mrb The mruby state reference.
* @param car The first value.
* @param cdr The second value.
* @return The initialized array.
*/
MRB_API mrb_value mrb_assoc_new(mrb_state *mrb, mrb_value car, mrb_value cdr);
/*
* Concatenate two arrays. The target array will be modified
*
* Equivalent to:
* ary.concat(other)
*
* @param mrb The mruby state reference.
* @param self The target array.
* @param other The array that will be concatenated to self.
*/
MRB_API void mrb_ary_concat(mrb_state *mrb, mrb_value self, mrb_value other);
/*
* Create an array from the input. It tries calling to_a on the
* value. If value does not respond to that, it creates a new
* array with just this value.
*
* @param mrb The mruby state reference.
* @param value The value to change into an array.
* @return An array representation of value.
*/
MRB_API mrb_value mrb_ary_splat(mrb_state *mrb, mrb_value value);
/*
* Pushes value into array.
*
* Equivalent to:
*
* ary << value
*
* @param mrb The mruby state reference.
* @param ary The array in which the value will be pushed
* @param value The value to be pushed into array
*/
MRB_API void mrb_ary_push(mrb_state *mrb, mrb_value array, mrb_value value);
/*
* Pops the last element from the array.
*
* Equivalent to:
*
* ary.pop
*
* @param mrb The mruby state reference.
* @param ary The array from which the value will be popped.
* @return The popped value.
*/
MRB_API mrb_value mrb_ary_pop(mrb_state *mrb, mrb_value ary);
/*
* Returns a reference to an element of the array on the given index.
*
* Equivalent to:
*
* ary[n]
*
* @param mrb The mruby state reference.
* @param ary The target array.
* @param n The array index being referenced
* @return The referenced value.
*/
MRB_API mrb_value mrb_ary_ref(mrb_state *mrb, mrb_value ary, mrb_int n);
/*
* Sets a value on an array at the given index
*
* Equivalent to:
*
* ary[n] = val
*
* @param mrb The mruby state reference.
* @param ary The target array.
* @param n The array index being referenced.
* @param val The value being setted.
*/
MRB_API void mrb_ary_set(mrb_state *mrb, mrb_value ary, mrb_int n, mrb_value val);
/*
* Replace the array with another array
*
* Equivalent to:
*
* ary.replace(other)
*
* @param mrb The mruby state reference
* @param self The target array.
* @param other The array to replace it with.
*/
MRB_API void mrb_ary_replace(mrb_state *mrb, mrb_value self, mrb_value other);
MRB_API mrb_value mrb_ensure_array_type(mrb_state *mrb, mrb_value self);
MRB_API mrb_value mrb_check_array_type(mrb_state *mrb, mrb_value self);
/*
* Unshift an element into the array
*
* Equivalent to:
*
* ary.unshift(item)
*
* @param mrb The mruby state reference.
* @param self The target array.
* @param item The item to unshift.
*/
MRB_API mrb_value mrb_ary_unshift(mrb_state *mrb, mrb_value self, mrb_value item);
/*
* Get nth element in the array
*
* Equivalent to:
*
* ary[offset]
*
* @param ary The target array.
* @param offset The element position (negative counts from the tail).
*/
MRB_API mrb_value mrb_ary_entry(mrb_value ary, mrb_int offset);
/*
* Replace subsequence of an array.
*
* Equivalent to:
*
* ary.shift
*
* @param mrb The mruby state reference.
* @param self The array from which the value will be shifted.
* @param head Beginning position of a replacement subsequence.
* @param len Length of a replacement subsequence.
* @param rpl The array of replacement elements.
* @return The receiver array.
*/
MRB_API mrb_value mrb_ary_splice(mrb_state *mrb, mrb_value self, mrb_int head, mrb_int len, mrb_value rpl);
/*
* Shifts the first element from the array.
*
* Equivalent to:
*
* ary.shift
*
* @param mrb The mruby state reference.
* @param self The array from which the value will be shifted.
* @return The shifted value.
*/
MRB_API mrb_value mrb_ary_shift(mrb_state *mrb, mrb_value self);
/*
* Removes all elements from the array
*
* Equivalent to:
*
* ary.clear
*
* @param mrb The mruby state reference.
* @param self The target array.
* @return self
*/
MRB_API mrb_value mrb_ary_clear(mrb_state *mrb, mrb_value self);
/*
* Join the array elements together in a string
*
* Equivalent to:
*
* ary.join(sep="")
*
* @param mrb The mruby state reference.
* @param ary The target array
* @param sep The separater, can be NULL
*/
MRB_API mrb_value mrb_ary_join(mrb_state *mrb, mrb_value ary, mrb_value sep);
/*
* Update the capacity of the array
*
* @param mrb The mruby state reference.
* @param ary The target array.
* @param new_len The new capacity of the array
*/
MRB_API mrb_value mrb_ary_resize(mrb_state *mrb, mrb_value ary, mrb_int new_len);
MRB_END_DECL
#endif /* MRUBY_ARRAY_H */
+95
View File
@@ -0,0 +1,95 @@
/**
** @file mruby/boxing_nan.h - nan boxing mrb_value definition
**
** See Copyright Notice in mruby.h
*/
#ifndef MRUBY_BOXING_NAN_H
#define MRUBY_BOXING_NAN_H
#ifdef MRB_USE_FLOAT
# error ---->> MRB_NAN_BOXING and MRB_USE_FLOAT conflict <<----
#endif
#ifdef MRB_WITHOUT_FLOAT
# error ---->> MRB_NAN_BOXING and MRB_WITHOUT_FLOAT conflict <<----
#endif
#ifdef MRB_INT64
# error ---->> MRB_NAN_BOXING and MRB_INT64 conflict <<----
#endif
#define MRB_FIXNUM_SHIFT 0
/* value representation by nan-boxing:
* float : FFFFFFFFFFFFFFFF FFFFFFFFFFFFFFFF FFFFFFFFFFFFFFFF FFFFFFFFFFFFFFFF
* object: 111111111111TTTT TTPPPPPPPPPPPPPP PPPPPPPPPPPPPPPP PPPPPPPPPPPPPPPP
* int : 1111111111110001 0000000000000000 IIIIIIIIIIIIIIII IIIIIIIIIIIIIIII
* sym : 1111111111110001 0100000000000000 SSSSSSSSSSSSSSSS SSSSSSSSSSSSSSSS
* In order to get enough bit size to save TT, all pointers are shifted 2 bits
* in the right direction. Also, TTTTTT is the mrb_vtype + 1;
*/
typedef struct mrb_value {
union {
mrb_float f;
union {
void *p;
struct {
MRB_ENDIAN_LOHI(
uint32_t ttt;
,union {
mrb_int i;
mrb_sym sym;
};
)
};
} value;
};
} mrb_value;
#define mrb_float_pool(mrb,f) mrb_float_value(mrb,f)
#define mrb_tt(o) ((enum mrb_vtype)(((o).value.ttt & 0xfc000)>>14)-1)
#define mrb_type(o) (enum mrb_vtype)((uint32_t)0xfff00000 < (o).value.ttt ? mrb_tt(o) : MRB_TT_FLOAT)
#define mrb_ptr(o) ((void*)((((uintptr_t)0x3fffffffffff)&((uintptr_t)((o).value.p)))<<2))
#define mrb_float(o) (o).f
#define mrb_cptr(o) mrb_ptr(o)
#define mrb_fixnum(o) (o).value.i
#define mrb_symbol(o) (o).value.sym
#ifdef MRB_64BIT
#define BOXNAN_SHIFT_LONG_POINTER(v) (((uintptr_t)(v)>>34)&0x3fff)
#else
#define BOXNAN_SHIFT_LONG_POINTER(v) 0
#endif
#define BOXNAN_SET_VALUE(o, tt, attr, v) do {\
(o).attr = (v);\
(o).value.ttt = 0xfff00000 | (((tt)+1)<<14);\
} while (0)
#define BOXNAN_SET_OBJ_VALUE(o, tt, v) do {\
(o).value.p = (void*)((uintptr_t)(v)>>2);\
(o).value.ttt = (0xfff00000|(((tt)+1)<<14)|BOXNAN_SHIFT_LONG_POINTER(v));\
} while (0)
#define SET_FLOAT_VALUE(mrb,r,v) do { \
if ((v) != (v)) { \
(r).value.ttt = 0x7ff80000; \
(r).value.i = 0; \
} \
else { \
(r).f = v; \
}} while(0)
#define SET_NIL_VALUE(r) BOXNAN_SET_VALUE(r, MRB_TT_FALSE, value.i, 0)
#define SET_FALSE_VALUE(r) BOXNAN_SET_VALUE(r, MRB_TT_FALSE, value.i, 1)
#define SET_TRUE_VALUE(r) BOXNAN_SET_VALUE(r, MRB_TT_TRUE, value.i, 1)
#define SET_BOOL_VALUE(r,b) BOXNAN_SET_VALUE(r, b ? MRB_TT_TRUE : MRB_TT_FALSE, value.i, 1)
#define SET_INT_VALUE(r,n) BOXNAN_SET_VALUE(r, MRB_TT_FIXNUM, value.i, (n))
#define SET_SYM_VALUE(r,v) BOXNAN_SET_VALUE(r, MRB_TT_SYMBOL, value.sym, (v))
#define SET_OBJ_VALUE(r,v) BOXNAN_SET_OBJ_VALUE(r, (((struct RObject*)(v))->tt), (v))
#define SET_CPTR_VALUE(mrb,r,v) BOXNAN_SET_OBJ_VALUE(r, MRB_TT_CPTR, v)
#define SET_UNDEF_VALUE(r) BOXNAN_SET_VALUE(r, MRB_TT_UNDEF, value.i, 0)
#endif /* MRUBY_BOXING_NAN_H */
+57
View File
@@ -0,0 +1,57 @@
/**
** @file mruby/boxing_no.h - unboxed mrb_value definition
**
** See Copyright Notice in mruby.h
*/
#ifndef MRUBY_BOXING_NO_H
#define MRUBY_BOXING_NO_H
#define MRB_FIXNUM_SHIFT 0
union mrb_value_union {
#ifndef MRB_WITHOUT_FLOAT
mrb_float f;
#endif
void *p;
mrb_int i;
mrb_sym sym;
};
typedef struct mrb_value {
union mrb_value_union value;
enum mrb_vtype tt;
} mrb_value;
#ifndef MRB_WITHOUT_FLOAT
#define mrb_float_pool(mrb,f) mrb_float_value(mrb,f)
#endif
#define mrb_ptr(o) (o).value.p
#define mrb_cptr(o) mrb_ptr(o)
#ifndef MRB_WITHOUT_FLOAT
#define mrb_float(o) (o).value.f
#endif
#define mrb_fixnum(o) (o).value.i
#define mrb_symbol(o) (o).value.sym
#define mrb_type(o) (o).tt
#define BOXNIX_SET_VALUE(o, ttt, attr, v) do {\
(o).tt = ttt;\
(o).attr = v;\
} while (0)
#define SET_NIL_VALUE(r) BOXNIX_SET_VALUE(r, MRB_TT_FALSE, value.i, 0)
#define SET_FALSE_VALUE(r) BOXNIX_SET_VALUE(r, MRB_TT_FALSE, value.i, 1)
#define SET_TRUE_VALUE(r) BOXNIX_SET_VALUE(r, MRB_TT_TRUE, value.i, 1)
#define SET_BOOL_VALUE(r,b) BOXNIX_SET_VALUE(r, b ? MRB_TT_TRUE : MRB_TT_FALSE, value.i, 1)
#define SET_INT_VALUE(r,n) BOXNIX_SET_VALUE(r, MRB_TT_FIXNUM, value.i, (n))
#ifndef MRB_WITHOUT_FLOAT
#define SET_FLOAT_VALUE(mrb,r,v) BOXNIX_SET_VALUE(r, MRB_TT_FLOAT, value.f, (v))
#endif
#define SET_SYM_VALUE(r,v) BOXNIX_SET_VALUE(r, MRB_TT_SYMBOL, value.sym, (v))
#define SET_OBJ_VALUE(r,v) BOXNIX_SET_VALUE(r, (((struct RObject*)(v))->tt), value.p, (v))
#define SET_CPTR_VALUE(mrb,r,v) BOXNIX_SET_VALUE(r, MRB_TT_CPTR, value.p, v)
#define SET_UNDEF_VALUE(r) BOXNIX_SET_VALUE(r, MRB_TT_UNDEF, value.i, 0)
#endif /* MRUBY_BOXING_NO_H */
+179
View File
@@ -0,0 +1,179 @@
/**
** @file mruby/boxing_word.h - word boxing mrb_value definition
**
** See Copyright Notice in mruby.h
*/
#ifndef MRUBY_BOXING_WORD_H
#define MRUBY_BOXING_WORD_H
#if defined(MRB_INT16)
# error MRB_INT16 is too small for MRB_WORD_BOXING.
#endif
#if defined(MRB_INT64) && !defined(MRB_64BIT)
#error MRB_INT64 cannot be used with MRB_WORD_BOXING in 32-bit mode.
#endif
#ifndef MRB_WITHOUT_FLOAT
struct RFloat {
MRB_OBJECT_HEADER;
mrb_float f;
};
#endif
struct RCptr {
MRB_OBJECT_HEADER;
void *p;
};
enum mrb_special_consts {
MRB_Qnil = 0,
MRB_Qfalse = 4,
MRB_Qtrue = 12,
MRB_Qundef = 20,
};
#define MRB_FIXNUM_SHIFT 1
#define MRB_SYMBOL_SHIFT 2
#define MRB_FIXNUM_FLAG (1 << (MRB_FIXNUM_SHIFT - 1))
#define MRB_SYMBOL_FLAG (1 << (MRB_SYMBOL_SHIFT - 1))
#define MRB_FIXNUM_MASK ((1 << MRB_FIXNUM_SHIFT) - 1)
#define MRB_SYMBOL_MASK ((1 << MRB_SYMBOL_SHIFT) - 1)
#define MRB_IMMEDIATE_MASK 0x07
#ifdef MRB_64BIT
#define MRB_SYMBOL_BITSIZE (sizeof(mrb_sym) * CHAR_BIT)
#define MRB_SYMBOL_MAX UINT32_MAX
#else
#define MRB_SYMBOL_BITSIZE (sizeof(mrb_sym) * CHAR_BIT - MRB_SYMBOL_SHIFT)
#define MRB_SYMBOL_MAX (UINT32_MAX >> MRB_SYMBOL_SHIFT)
#endif
#define BOXWORD_SHIFT_VALUE(o,n,t) \
((((t)(o).w)) >> MRB_##n##_SHIFT)
#define BOXWORD_SET_SHIFT_VALUE(o,n,v) \
((o).w = (((unsigned long)(v)) << MRB_##n##_SHIFT) | MRB_##n##_FLAG)
#define BOXWORD_SHIFT_VALUE_P(o,n) \
(((o).w & MRB_##n##_MASK) == MRB_##n##_FLAG)
#define BOXWORD_OBJ_TYPE_P(o,n) \
(!mrb_immediate_p(o) && (o).value.bp->tt == MRB_TT_##n)
/*
* mrb_value representation:
*
* nil : ...0000 0000 (all bits are zero)
* false : ...0000 0100
* true : ...0000 1100
* undef : ...0001 0100
* fixnum: ...IIII III1
* symbol: ...SSSS SS10 (high-order 32-bit are symbol value in 64-bit mode)
* object: ...PPPP P000
*/
typedef union mrb_value {
union {
void *p;
#ifdef MRB_64BIT
/* use struct to avoid bit shift. */
struct {
MRB_ENDIAN_LOHI(
mrb_sym sym;
,uint32_t sym_flag;
)
};
#endif
struct RBasic *bp;
#ifndef MRB_WITHOUT_FLOAT
struct RFloat *fp;
#endif
struct RCptr *vp;
} value;
unsigned long w;
} mrb_value;
MRB_API mrb_value mrb_word_boxing_cptr_value(struct mrb_state*, void*);
#ifndef MRB_WITHOUT_FLOAT
MRB_API mrb_value mrb_word_boxing_float_value(struct mrb_state*, mrb_float);
MRB_API mrb_value mrb_word_boxing_float_pool(struct mrb_state*, mrb_float);
#endif
#ifndef MRB_WITHOUT_FLOAT
#define mrb_float_pool(mrb,f) mrb_word_boxing_float_pool(mrb,f)
#endif
#define mrb_ptr(o) (o).value.p
#define mrb_cptr(o) (o).value.vp->p
#ifndef MRB_WITHOUT_FLOAT
#define mrb_float(o) (o).value.fp->f
#endif
#define mrb_fixnum(o) BOXWORD_SHIFT_VALUE(o, FIXNUM, mrb_int)
#ifdef MRB_64BIT
#define mrb_symbol(o) (o).value.sym
#else
#define mrb_symbol(o) BOXWORD_SHIFT_VALUE(o, SYMBOL, mrb_sym)
#endif
#define mrb_bool(o) (((o).w & ~(unsigned long)MRB_Qfalse) != 0)
#define mrb_immediate_p(o) ((o).w & MRB_IMMEDIATE_MASK || (o).w == MRB_Qnil)
#define mrb_fixnum_p(o) BOXWORD_SHIFT_VALUE_P(o, FIXNUM)
#ifdef MRB_64BIT
#define mrb_symbol_p(o) ((o).value.sym_flag == MRB_SYMBOL_FLAG)
#else
#define mrb_symbol_p(o) BOXWORD_SHIFT_VALUE_P(o, SYMBOL)
#endif
#define mrb_undef_p(o) ((o).w == MRB_Qundef)
#define mrb_nil_p(o) ((o).w == MRB_Qnil)
#define mrb_false_p(o) ((o).w == MRB_Qfalse)
#define mrb_true_p(o) ((o).w == MRB_Qtrue)
#ifndef MRB_WITHOUT_FLOAT
#define mrb_float_p(o) BOXWORD_OBJ_TYPE_P(o, FLOAT)
#endif
#define mrb_array_p(o) BOXWORD_OBJ_TYPE_P(o, ARRAY)
#define mrb_string_p(o) BOXWORD_OBJ_TYPE_P(o, STRING)
#define mrb_hash_p(o) BOXWORD_OBJ_TYPE_P(o, HASH)
#define mrb_cptr_p(o) BOXWORD_OBJ_TYPE_P(o, CPTR)
#define mrb_exception_p(o) BOXWORD_OBJ_TYPE_P(o, EXCEPTION)
#define mrb_free_p(o) BOXWORD_OBJ_TYPE_P(o, FREE)
#define mrb_object_p(o) BOXWORD_OBJ_TYPE_P(o, OBJECT)
#define mrb_class_p(o) BOXWORD_OBJ_TYPE_P(o, CLASS)
#define mrb_module_p(o) BOXWORD_OBJ_TYPE_P(o, MODULE)
#define mrb_iclass_p(o) BOXWORD_OBJ_TYPE_P(o, ICLASS)
#define mrb_sclass_p(o) BOXWORD_OBJ_TYPE_P(o, SCLASS)
#define mrb_proc_p(o) BOXWORD_OBJ_TYPE_P(o, PROC)
#define mrb_range_p(o) BOXWORD_OBJ_TYPE_P(o, RANGE)
#define mrb_file_p(o) BOXWORD_OBJ_TYPE_P(o, FILE)
#define mrb_env_p(o) BOXWORD_OBJ_TYPE_P(o, ENV)
#define mrb_data_p(o) BOXWORD_OBJ_TYPE_P(o, DATA)
#define mrb_fiber_p(o) BOXWORD_OBJ_TYPE_P(o, FIBER)
#define mrb_istruct_p(o) BOXWORD_OBJ_TYPE_P(o, ISTRUCT)
#define mrb_break_p(o) BOXWORD_OBJ_TYPE_P(o, BREAK)
#ifndef MRB_WITHOUT_FLOAT
#define SET_FLOAT_VALUE(mrb,r,v) ((r) = mrb_word_boxing_float_value(mrb, v))
#endif
#define SET_CPTR_VALUE(mrb,r,v) ((r) = mrb_word_boxing_cptr_value(mrb, v))
#define SET_UNDEF_VALUE(r) ((r).w = MRB_Qundef)
#define SET_NIL_VALUE(r) ((r).w = MRB_Qnil)
#define SET_FALSE_VALUE(r) ((r).w = MRB_Qfalse)
#define SET_TRUE_VALUE(r) ((r).w = MRB_Qtrue)
#define SET_BOOL_VALUE(r,b) ((b) ? SET_TRUE_VALUE(r) : SET_FALSE_VALUE(r))
#define SET_INT_VALUE(r,n) BOXWORD_SET_SHIFT_VALUE(r, FIXNUM, n)
#ifdef MRB_64BIT
#define SET_SYM_VALUE(r,v) ((r).value.sym = v, (r).value.sym_flag = MRB_SYMBOL_FLAG)
#else
#define SET_SYM_VALUE(r,n) BOXWORD_SET_SHIFT_VALUE(r, SYMBOL, n)
#endif
#define SET_OBJ_VALUE(r,v) ((r).value.p = v)
MRB_INLINE enum mrb_vtype
mrb_type(mrb_value o)
{
return !mrb_bool(o) ? MRB_TT_FALSE :
mrb_true_p(o) ? MRB_TT_TRUE :
mrb_fixnum_p(o) ? MRB_TT_FIXNUM :
mrb_symbol_p(o) ? MRB_TT_SYMBOL :
mrb_undef_p(o) ? MRB_TT_UNDEF :
o.value.bp->tt;
}
#endif /* MRUBY_BOXING_WORD_H */
+49 -25
View File
@@ -1,5 +1,5 @@
/*
** mruby/class.h - Class class
/**
** @file mruby/class.h - Class class
**
** See Copyright Notice in mruby.h
*/
@@ -7,9 +7,12 @@
#ifndef MRUBY_CLASS_H
#define MRUBY_CLASS_H
#if defined(__cplusplus)
extern "C" {
#endif
#include "common.h"
/**
* Class class
*/
MRB_BEGIN_DECL
struct RClass {
MRB_OBJECT_HEADER;
@@ -19,16 +22,13 @@ struct RClass {
};
#define mrb_class_ptr(v) ((struct RClass*)(mrb_ptr(v)))
#define RCLASS_SUPER(v) (((struct RClass*)(mrb_ptr(v)))->super)
#define RCLASS_IV_TBL(v) (((struct RClass*)(mrb_ptr(v)))->iv)
#define RCLASS_M_TBL(v) (((struct RClass*)(mrb_ptr(v)))->mt)
static inline struct RClass*
MRB_INLINE struct RClass*
mrb_class(mrb_state *mrb, mrb_value v)
{
switch (mrb_type(v)) {
case MRB_TT_FALSE:
if (v.value.i)
if (mrb_fixnum(v))
return mrb->false_class;
return mrb->nil_class;
case MRB_TT_TRUE:
@@ -37,39 +37,63 @@ mrb_class(mrb_state *mrb, mrb_value v)
return mrb->symbol_class;
case MRB_TT_FIXNUM:
return mrb->fixnum_class;
#ifndef MRB_WITHOUT_FLOAT
case MRB_TT_FLOAT:
return mrb->float_class;
#endif
case MRB_TT_CPTR:
return mrb->object_class;
case MRB_TT_ENV:
return NULL;
default:
return mrb_obj_ptr(v)->c;
}
}
#define MRB_SET_INSTANCE_TT(c, tt) c->flags = ((c->flags & ~0xff) | (char)tt)
#define MRB_INSTANCE_TT(c) (enum mrb_vtype)(c->flags & 0xff)
/* flags:
20: frozen
19: is_prepended
18: is_origin
17: is_inherited (used by method cache)
16: unused
0-15: instance type
*/
#define MRB_FL_CLASS_IS_PREPENDED (1 << 19)
#define MRB_FL_CLASS_IS_ORIGIN (1 << 18)
#define MRB_CLASS_ORIGIN(c) do {\
if ((c)->flags & MRB_FL_CLASS_IS_PREPENDED) {\
(c) = (c)->super;\
while (!((c)->flags & MRB_FL_CLASS_IS_ORIGIN)) {\
(c) = (c)->super;\
}\
}\
} while (0)
#define MRB_FL_CLASS_IS_INHERITED (1 << 17)
#define MRB_INSTANCE_TT_MASK (0xFF)
#define MRB_SET_INSTANCE_TT(c, tt) ((c)->flags = (((c)->flags & ~MRB_INSTANCE_TT_MASK) | (char)(tt)))
#define MRB_INSTANCE_TT(c) (enum mrb_vtype)((c)->flags & MRB_INSTANCE_TT_MASK)
struct RClass* mrb_define_class_id(mrb_state*, mrb_sym, struct RClass*);
struct RClass* mrb_define_module_id(mrb_state*, mrb_sym);
MRB_API struct RClass* mrb_define_class_id(mrb_state*, mrb_sym, struct RClass*);
MRB_API struct RClass* mrb_define_module_id(mrb_state*, mrb_sym);
struct RClass *mrb_vm_define_class(mrb_state*, mrb_value, mrb_value, mrb_sym);
struct RClass *mrb_vm_define_module(mrb_state*, mrb_value, mrb_sym);
void mrb_define_method_vm(mrb_state*, struct RClass*, mrb_sym, mrb_value);
void mrb_define_method_raw(mrb_state*, struct RClass*, mrb_sym, struct RProc *);
void mrb_define_method_id(mrb_state *mrb, struct RClass *c, mrb_sym mid, mrb_func_t func, mrb_aspec aspec);
void mrb_alias_method(mrb_state *mrb, struct RClass *c, mrb_sym a, mrb_sym b);
MRB_API void mrb_define_method_raw(mrb_state*, struct RClass*, mrb_sym, mrb_method_t);
MRB_API void mrb_define_method_id(mrb_state *mrb, struct RClass *c, mrb_sym mid, mrb_func_t func, mrb_aspec aspec);
MRB_API void mrb_alias_method(mrb_state*, struct RClass *c, mrb_sym a, mrb_sym b);
struct RClass *mrb_class_outer_module(mrb_state*, struct RClass *);
struct RProc *mrb_method_search_vm(mrb_state*, struct RClass**, mrb_sym);
struct RProc *mrb_method_search(mrb_state*, struct RClass*, mrb_sym);
MRB_API mrb_method_t mrb_method_search_vm(mrb_state*, struct RClass**, mrb_sym);
MRB_API mrb_method_t mrb_method_search(mrb_state*, struct RClass*, mrb_sym);
struct RClass* mrb_class_real(struct RClass* cl);
MRB_API struct RClass* mrb_class_real(struct RClass* cl);
mrb_value mrb_instance_new(mrb_state *mrb, mrb_value cv);
void mrb_class_name_class(mrb_state*, struct RClass*, struct RClass*, mrb_sym);
mrb_bool mrb_const_name_p(mrb_state*, const char*, mrb_int);
mrb_value mrb_class_find_path(mrb_state*, struct RClass*);
void mrb_gc_mark_mt(mrb_state*, struct RClass*);
size_t mrb_gc_mark_mt_size(mrb_state*, struct RClass*);
void mrb_gc_free_mt(mrb_state*, struct RClass*);
#if defined(__cplusplus)
} /* extern "C" { */
#endif
MRB_END_DECL
#endif /* MRUBY_CLASS_H */
+79
View File
@@ -0,0 +1,79 @@
/**
** @file common.h - mruby common platform definition"
**
** See Copyright Notice in mruby.h
*/
#ifndef MRUBY_COMMON_H
#define MRUBY_COMMON_H
#ifdef __APPLE__
#ifndef __TARGETCONDITIONALS__
#include "TargetConditionals.h"
#endif
#endif
#ifdef __cplusplus
#ifdef MRB_ENABLE_CXX_ABI
#define MRB_BEGIN_DECL
#define MRB_END_DECL
#else
# define MRB_BEGIN_DECL extern "C" {
# define MRB_END_DECL }
#endif
#else
/** Start declarations in C mode */
# define MRB_BEGIN_DECL
/** End declarations in C mode */
# define MRB_END_DECL
#endif
/**
* Shared compiler macros
*/
MRB_BEGIN_DECL
/** Declare a function that never returns. */
#if defined __STDC_VERSION__ && __STDC_VERSION__ >= 201112L
# define mrb_noreturn _Noreturn
#elif defined __GNUC__ && !defined __STRICT_ANSI__
# define mrb_noreturn __attribute__((noreturn))
#elif defined _MSC_VER
# define mrb_noreturn __declspec(noreturn)
#else
# define mrb_noreturn
#endif
/** Mark a function as deprecated. */
#if defined __GNUC__ && !defined __STRICT_ANSI__
# define mrb_deprecated __attribute__((deprecated))
#elif defined _MSC_VER
# define mrb_deprecated __declspec(deprecated)
#else
# define mrb_deprecated
#endif
/** Declare a function as always inlined. */
#if defined _MSC_VER && _MSC_VER < 1900
# ifndef __cplusplus
# define inline __inline
# endif
#endif
#define MRB_INLINE static inline
/** Declare a public MRuby API function. */
#ifndef MRB_API
#if defined(MRB_BUILD_AS_DLL)
#if defined(MRB_CORE) || defined(MRB_LIB)
# define MRB_API __declspec(dllexport)
#else
# define MRB_API __declspec(dllimport)
#endif
#else
# define MRB_API extern
#endif
#endif
MRB_END_DECL
#endif /* MRUBY_COMMON_H */
+73 -61
View File
@@ -1,18 +1,22 @@
/*
** mruby/compile.h - mruby parser
/**
** @file mruby/compile.h - mruby parser
**
** See Copyright Notice in mruby.h
*/
#ifndef MRUBY_COMPILE_H
#define MRUBY_COMPILE_H 1
#define MRUBY_COMPILE_H
#if defined(__cplusplus)
extern "C" {
#endif
#include "common.h"
#include "mruby.h"
#include <setjmp.h>
/**
* MRuby Compiler
*/
MRB_BEGIN_DECL
#include <mruby.h>
struct mrb_jmpbuf;
struct mrb_parser_state;
/* load context */
@@ -20,19 +24,24 @@ typedef struct mrbc_context {
mrb_sym *syms;
int slen;
char *filename;
short lineno;
uint16_t lineno;
int (*partial_hook)(struct mrb_parser_state*);
void *partial_data;
struct RClass *target_class;
mrb_bool capture_errors:1;
mrb_bool dump_result:1;
mrb_bool no_exec:1;
mrb_bool keep_lv:1;
mrb_bool no_optimize:1;
mrb_bool on_eval:1;
size_t parser_nerr;
} mrbc_context;
mrbc_context* mrbc_context_new(mrb_state *mrb);
void mrbc_context_free(mrb_state *mrb, mrbc_context *cxt);
const char *mrbc_filename(mrb_state *mrb, mrbc_context *c, const char *s);
void mrbc_partial_hook(mrb_state *mrb, mrbc_context *c, int (*partial_hook)(struct mrb_parser_state*), void*data);
MRB_API mrbc_context* mrbc_context_new(mrb_state *mrb);
MRB_API void mrbc_context_free(mrb_state *mrb, mrbc_context *cxt);
MRB_API const char *mrbc_filename(mrb_state *mrb, mrbc_context *c, const char *s);
MRB_API void mrbc_partial_hook(mrb_state *mrb, mrbc_context *c, int (*partial_hook)(struct mrb_parser_state*), void*data);
/* AST node structure */
typedef struct mrb_ast_node {
@@ -42,23 +51,23 @@ typedef struct mrb_ast_node {
/* lexer states */
enum mrb_lex_state_enum {
EXPR_BEG, /* ignore newline, +/- is a sign. */
EXPR_END, /* newline significant, +/- is an operator. */
EXPR_ENDARG, /* ditto, and unbound braces. */
EXPR_ENDFN, /* ditto, and unbound braces. */
EXPR_ARG, /* newline significant, +/- is an operator. */
EXPR_CMDARG, /* newline significant, +/- is an operator. */
EXPR_MID, /* newline significant, +/- is an operator. */
EXPR_FNAME, /* ignore newline, no reserved words. */
EXPR_DOT, /* right after `.' or `::', no reserved words. */
EXPR_CLASS, /* immediate after `class', no here document. */
EXPR_VALUE, /* alike EXPR_BEG but label is disallowed. */
EXPR_MAX_STATE
EXPR_BEG, /* ignore newline, +/- is a sign. */
EXPR_END, /* newline significant, +/- is an operator. */
EXPR_ENDARG, /* ditto, and unbound braces. */
EXPR_ENDFN, /* ditto, and unbound braces. */
EXPR_ARG, /* newline significant, +/- is an operator. */
EXPR_CMDARG, /* newline significant, +/- is an operator. */
EXPR_MID, /* newline significant, +/- is an operator. */
EXPR_FNAME, /* ignore newline, no reserved words. */
EXPR_DOT, /* right after '.' or '::', no reserved words. */
EXPR_CLASS, /* immediate after 'class', no here document. */
EXPR_VALUE, /* alike EXPR_BEG but label is disallowed. */
EXPR_MAX_STATE
};
/* saved error message */
struct mrb_parser_message {
int lineno;
uint16_t lineno;
int column;
char* message;
};
@@ -96,7 +105,8 @@ struct mrb_parser_heredoc_info {
mrb_ast_node *doc;
};
#define MRB_PARSER_BUF_SIZE 1024
#define MRB_PARSER_TOKBUF_MAX (UINT16_MAX-1)
#define MRB_PARSER_TOKBUF_SIZE 256
/* parser structure */
struct mrb_parser_state {
@@ -104,12 +114,12 @@ struct mrb_parser_state {
struct mrb_pool *pool;
mrb_ast_node *cells;
const char *s, *send;
#ifdef ENABLE_STDIO
#ifndef MRB_DISABLE_STDIO
FILE *f;
#endif
mrbc_context *cxt;
char const *filename;
int lineno;
mrb_sym filename_sym;
uint16_t lineno;
int column;
enum mrb_lex_state_enum lstate;
@@ -119,18 +129,20 @@ struct mrb_parser_state {
unsigned int cmdarg_stack;
int paren_nest;
int lpar_beg;
int in_def, in_single, cmd_start;
int in_def, in_single;
mrb_bool cmd_start:1;
mrb_ast_node *locals;
mrb_ast_node *pb;
char buf[MRB_PARSER_BUF_SIZE];
int bidx;
char *tokbuf;
char buf[MRB_PARSER_TOKBUF_SIZE];
int tidx;
int tsiz;
mrb_ast_node *all_heredocs; /* list of mrb_parser_heredoc_info* */
mrb_ast_node *all_heredocs; /* list of mrb_parser_heredoc_info* */
mrb_ast_node *heredocs_from_nextline;
mrb_ast_node *parsing_heredoc;
mrb_ast_node *lex_strterm_before_heredoc;
mrb_bool heredoc_end_now:1; /* for mirb */
void *ylval;
@@ -138,46 +150,46 @@ struct mrb_parser_state {
size_t nwarn;
mrb_ast_node *tree;
int capture_errors;
mrb_bool no_optimize:1;
mrb_bool on_eval:1;
mrb_bool capture_errors:1;
struct mrb_parser_message error_buffer[10];
struct mrb_parser_message warn_buffer[10];
mrb_sym* filename_table;
size_t filename_table_length;
int current_filename_index;
uint16_t filename_table_length;
uint16_t current_filename_index;
jmp_buf jmp;
struct mrb_jmpbuf* jmp;
};
struct mrb_parser_state* mrb_parser_new(mrb_state*);
void mrb_parser_free(struct mrb_parser_state*);
void mrb_parser_parse(struct mrb_parser_state*,mrbc_context*);
MRB_API struct mrb_parser_state* mrb_parser_new(mrb_state*);
MRB_API void mrb_parser_free(struct mrb_parser_state*);
MRB_API void mrb_parser_parse(struct mrb_parser_state*,mrbc_context*);
void mrb_parser_set_filename(struct mrb_parser_state*, char const*);
char const* mrb_parser_get_filename(struct mrb_parser_state*, uint16_t idx);
MRB_API void mrb_parser_set_filename(struct mrb_parser_state*, char const*);
MRB_API mrb_sym mrb_parser_get_filename(struct mrb_parser_state*, uint16_t idx);
/* utility functions */
#ifdef ENABLE_STDIO
struct mrb_parser_state* mrb_parse_file(mrb_state*,FILE*,mrbc_context*);
#ifndef MRB_DISABLE_STDIO
MRB_API struct mrb_parser_state* mrb_parse_file(mrb_state*,FILE*,mrbc_context*);
#endif
struct mrb_parser_state* mrb_parse_string(mrb_state*,const char*,mrbc_context*);
struct mrb_parser_state* mrb_parse_nstring(mrb_state*,const char*,int,mrbc_context*);
struct RProc* mrb_generate_code(mrb_state*, struct mrb_parser_state*);
MRB_API struct mrb_parser_state* mrb_parse_string(mrb_state*,const char*,mrbc_context*);
MRB_API struct mrb_parser_state* mrb_parse_nstring(mrb_state*,const char*,size_t,mrbc_context*);
MRB_API struct RProc* mrb_generate_code(mrb_state*, struct mrb_parser_state*);
MRB_API mrb_value mrb_load_exec(mrb_state *mrb, struct mrb_parser_state *p, mrbc_context *c);
/* program load functions */
#ifdef ENABLE_STDIO
mrb_value mrb_load_file(mrb_state*,FILE*);
#ifndef MRB_DISABLE_STDIO
MRB_API mrb_value mrb_load_file(mrb_state*,FILE*);
MRB_API mrb_value mrb_load_file_cxt(mrb_state*,FILE*, mrbc_context *cxt);
#endif
mrb_value mrb_load_string(mrb_state *mrb, const char *s);
mrb_value mrb_load_nstring(mrb_state *mrb, const char *s, int len);
#ifdef ENABLE_STDIO
mrb_value mrb_load_file_cxt(mrb_state*,FILE*, mrbc_context *cxt);
#endif
mrb_value mrb_load_string_cxt(mrb_state *mrb, const char *s, mrbc_context *cxt);
mrb_value mrb_load_nstring_cxt(mrb_state *mrb, const char *s, int len, mrbc_context *cxt);
MRB_API mrb_value mrb_load_string(mrb_state *mrb, const char *s);
MRB_API mrb_value mrb_load_nstring(mrb_state *mrb, const char *s, size_t len);
MRB_API mrb_value mrb_load_string_cxt(mrb_state *mrb, const char *s, mrbc_context *cxt);
MRB_API mrb_value mrb_load_nstring_cxt(mrb_state *mrb, const char *s, size_t len, mrbc_context *cxt);
#if defined(__cplusplus)
} /* extern "C" { */
#endif
/** @} */
MRB_END_DECL
#endif /* MRUBY_COMPILE_H */
+35 -17
View File
@@ -1,18 +1,29 @@
/*
** mruby/data.h - Data class
/**
** @file mruby/data.h - Data class
**
** See Copyright Notice in mruby.h
*/
#ifndef MRUBY_DATA_H
#define MRUBY_DATA_H 1
#define MRUBY_DATA_H
#if defined(__cplusplus)
extern "C" {
#endif
#include "common.h"
/**
* Custom C wrapped data.
*
* Defining Ruby wrappers around native objects.
*/
MRB_BEGIN_DECL
/**
* Custom data type description.
*/
typedef struct mrb_data_type {
/** data type name */
const char *struct_name;
/** data type release function pointer */
void (*dfree)(mrb_state *mrb, void*);
} mrb_data_type;
@@ -23,24 +34,25 @@ struct RData {
void *data;
};
struct RData *mrb_data_object_alloc(mrb_state *mrb, struct RClass* klass, void *datap, const mrb_data_type *type);
MRB_API struct RData *mrb_data_object_alloc(mrb_state *mrb, struct RClass* klass, void *datap, const mrb_data_type *type);
#define Data_Wrap_Struct(mrb,klass,type,ptr)\
mrb_data_object_alloc(mrb,klass,ptr,type)
#define Data_Make_Struct(mrb,klass,strct,type,sval,data) do { \
sval = mrb_malloc(mrb, sizeof(strct)); \
{ static const strct zero = { 0 }; *sval = zero; };\
data = Data_Wrap_Struct(mrb,klass,type,sval);\
#define Data_Make_Struct(mrb,klass,strct,type,sval,data_obj) do { \
(data_obj) = Data_Wrap_Struct(mrb,klass,type,NULL);\
(sval) = (strct *)mrb_malloc(mrb, sizeof(strct)); \
{ static const strct zero = { 0 }; *(sval) = zero; };\
(data_obj)->data = (sval);\
} while (0)
#define RDATA(obj) ((struct RData *)(mrb_ptr(obj)))
#define DATA_PTR(d) (RDATA(d)->data)
#define DATA_TYPE(d) (RDATA(d)->type)
void mrb_data_check_type(mrb_state *mrb, mrb_value, const mrb_data_type*);
void *mrb_data_get_ptr(mrb_state *mrb, mrb_value, const mrb_data_type*);
MRB_API void mrb_data_check_type(mrb_state *mrb, mrb_value, const mrb_data_type*);
MRB_API void *mrb_data_get_ptr(mrb_state *mrb, mrb_value, const mrb_data_type*);
#define DATA_GET_PTR(mrb,obj,dtype,type) (type*)mrb_data_get_ptr(mrb,obj,dtype)
void *mrb_data_check_get_ptr(mrb_state *mrb, mrb_value, const mrb_data_type*);
MRB_API void *mrb_data_check_get_ptr(mrb_state *mrb, mrb_value, const mrb_data_type*);
#define DATA_CHECK_GET_PTR(mrb,obj,dtype,type) (type*)mrb_data_check_get_ptr(mrb,obj,dtype)
/* obsolete functions and macros */
@@ -51,8 +63,14 @@ void *mrb_data_check_get_ptr(mrb_state *mrb, mrb_value, const mrb_data_type*);
*(void**)&sval = mrb_data_get_ptr(mrb, obj, type); \
} while (0)
#if defined(__cplusplus)
} /* extern "C" { */
#endif
MRB_INLINE void
mrb_data_init(mrb_value v, void *ptr, const mrb_data_type *type)
{
mrb_assert(mrb_data_p(v));
DATA_PTR(v) = ptr;
DATA_TYPE(v) = type;
}
MRB_END_DECL
#endif /* MRUBY_DATA_H */
+20 -19
View File
@@ -1,5 +1,5 @@
/*
** mruby/debug.h - mruby debug info
/**
** @file mruby/debug.h - mruby debug info
**
** See Copyright Notice in mruby.h
*/
@@ -7,9 +7,12 @@
#ifndef MRUBY_DEBUG_H
#define MRUBY_DEBUG_H
#if defined(__cplusplus)
extern "C" {
#endif
#include "common.h"
/**
* MRuby Debugging.
*/
MRB_BEGIN_DECL
typedef enum mrb_debug_line_type {
mrb_debug_line_ary = 0,
@@ -23,15 +26,14 @@ typedef struct mrb_irep_debug_info_line {
typedef struct mrb_irep_debug_info_file {
uint32_t start_pos;
const char *filename;
mrb_sym filename_sym;
uint32_t line_entry_count;
mrb_debug_line_type line_type;
union {
void *line_ptr;
mrb_irep_debug_info_line *line_flat_map;
uint16_t *line_ary;
};
void *ptr;
mrb_irep_debug_info_line *flat_map;
uint16_t *ary;
} lines;
} mrb_irep_debug_info_file;
typedef struct mrb_irep_debug_info {
@@ -44,22 +46,21 @@ typedef struct mrb_irep_debug_info {
* get line from irep's debug info and program counter
* @return returns NULL if not found
*/
const char *mrb_debug_get_filename(mrb_irep *irep, uint32_t pc);
MRB_API const char *mrb_debug_get_filename(mrb_state *mrb, mrb_irep *irep, ptrdiff_t pc);
/*
* get line from irep's debug info and program counter
* @return returns -1 if not found
*/
int32_t mrb_debug_get_line(mrb_irep *irep, uint32_t pc);
MRB_API int32_t mrb_debug_get_line(mrb_state *mrb, mrb_irep *irep, ptrdiff_t pc);
mrb_irep_debug_info_file *mrb_debug_info_append_file(
mrb_state *mrb, mrb_irep *irep,
MRB_API mrb_irep_debug_info *mrb_debug_info_alloc(mrb_state *mrb, mrb_irep *irep);
MRB_API mrb_irep_debug_info_file *mrb_debug_info_append_file(
mrb_state *mrb, mrb_irep_debug_info *info,
const char *filename, uint16_t *lines,
uint32_t start_pos, uint32_t end_pos);
mrb_irep_debug_info *mrb_debug_info_alloc(mrb_state *mrb, mrb_irep *irep);
void mrb_debug_info_free(mrb_state *mrb, mrb_irep_debug_info *d);
MRB_API void mrb_debug_info_free(mrb_state *mrb, mrb_irep_debug_info *d);
#if defined(__cplusplus)
} /* extern "C" { */
#endif
MRB_END_DECL
#endif /* MRUBY_DEBUG_H */
+88 -46
View File
@@ -1,5 +1,5 @@
/*
** mruby/dump.h - mruby binary dumper (mrbc binary format)
/**
** @file mruby/dump.h - mruby binary dumper (mrbc binary format)
**
** See Copyright Notice in mruby.h
*/
@@ -7,67 +7,79 @@
#ifndef MRUBY_DUMP_H
#define MRUBY_DUMP_H
#if defined(__cplusplus)
extern "C" {
#endif
#include <mruby.h>
#include <mruby/irep.h>
#include "common.h"
#include "mruby.h"
#include "mruby/irep.h"
/**
* Dumping compiled mruby script.
*/
MRB_BEGIN_DECL
#ifdef ENABLE_STDIO
int mrb_dump_irep_binary(mrb_state*, mrb_irep*, int, FILE*);
int mrb_dump_irep_cfunc(mrb_state *mrb, mrb_irep*, int, FILE *f, const char *initname);
#define DUMP_DEBUG_INFO 1
#define DUMP_ENDIAN_BIG 2
#define DUMP_ENDIAN_LIL 4
#define DUMP_ENDIAN_NAT 6
#define DUMP_ENDIAN_MASK 6
int mrb_dump_irep(mrb_state *mrb, mrb_irep *irep, uint8_t flags, uint8_t **bin, size_t *bin_size);
#ifndef MRB_DISABLE_STDIO
int mrb_dump_irep_binary(mrb_state*, mrb_irep*, uint8_t, FILE*);
int mrb_dump_irep_cfunc(mrb_state *mrb, mrb_irep*, uint8_t flags, FILE *f, const char *initname);
mrb_irep *mrb_read_irep_file(mrb_state*, FILE*);
mrb_value mrb_load_irep_file(mrb_state*,FILE*);
mrb_value mrb_load_irep_file_cxt(mrb_state*, FILE*, mrbc_context*);
MRB_API mrb_value mrb_load_irep_file(mrb_state*,FILE*);
MRB_API mrb_value mrb_load_irep_file_cxt(mrb_state*, FILE*, mrbc_context*);
#endif
mrb_irep *mrb_read_irep(mrb_state*, const uint8_t*);
MRB_API mrb_irep *mrb_read_irep(mrb_state*, const uint8_t*);
MRB_API mrb_irep *mrb_read_irep_buf(mrb_state*, const void*, size_t);
/* dump/load error code
*
* NOTE: MRB_DUMP_GENERAL_FAILURE is caused by
* unspecified issues like malloc failed.
*/
#define MRB_DUMP_OK 0
#define MRB_DUMP_GENERAL_FAILURE -1
#define MRB_DUMP_WRITE_FAULT -2
#define MRB_DUMP_READ_FAULT -3
#define MRB_DUMP_CRC_ERROR -4
#define MRB_DUMP_INVALID_FILE_HEADER -5
#define MRB_DUMP_INVALID_IREP -6
#define MRB_DUMP_INVALID_ARGUMENT -7
#define MRB_DUMP_OK 0
#define MRB_DUMP_GENERAL_FAILURE (-1)
#define MRB_DUMP_WRITE_FAULT (-2)
#define MRB_DUMP_READ_FAULT (-3)
#define MRB_DUMP_CRC_ERROR (-4)
#define MRB_DUMP_INVALID_FILE_HEADER (-5)
#define MRB_DUMP_INVALID_IREP (-6)
#define MRB_DUMP_INVALID_ARGUMENT (-7)
/* null symbol length */
#define MRB_DUMP_NULL_SYM_LEN 0xFFFF
/* Rite Binary File header */
#define RITE_BINARY_IDENTIFIER "RITE"
#define RITE_BINARY_FORMAT_VER "0002"
#define RITE_BINARY_IDENT "RITE"
#define RITE_BINARY_IDENT_LIL "ETIR"
#define RITE_BINARY_FORMAT_VER "0006"
#define RITE_COMPILER_NAME "MATZ"
#define RITE_COMPILER_VERSION "0000"
#define RITE_VM_VER "0000"
#define RITE_VM_VER "0002"
#define RITE_BINARY_EOF "END\0"
#define RITE_SECTION_IREP_IDENTIFIER "IREP"
#define RITE_SECTION_LINENO_IDENTIFIER "LINE"
#define RITE_SECTION_DEBUG_IDENTIFIER "DBG\0"
#define RITE_SECTION_IREP_IDENT "IREP"
#define RITE_SECTION_DEBUG_IDENT "DBG\0"
#define RITE_SECTION_LV_IDENT "LVAR"
#define MRB_DUMP_DEFAULT_STR_LEN 128
#define MRB_DUMP_ALIGNMENT sizeof(uint32_t)
// binary header
/* binary header */
struct rite_binary_header {
uint8_t binary_identify[4]; // Binary Identifier
uint8_t binary_version[4]; // Binary Format Version
uint8_t binary_crc[2]; // Binary CRC
uint8_t binary_size[4]; // Binary Size
uint8_t compiler_name[4]; // Compiler name
uint8_t binary_ident[4]; /* Binary Identifier */
uint8_t binary_version[4]; /* Binary Format Version */
uint8_t binary_crc[2]; /* Binary CRC */
uint8_t binary_size[4]; /* Binary Size */
uint8_t compiler_name[4]; /* Compiler name */
uint8_t compiler_version[4];
};
// section header
/* section header */
#define RITE_SECTION_HEADER \
uint8_t section_identify[4]; \
uint8_t section_ident[4]; \
uint8_t section_size[4]
struct rite_section_header {
@@ -77,29 +89,42 @@ struct rite_section_header {
struct rite_section_irep_header {
RITE_SECTION_HEADER;
uint8_t rite_version[4]; // Rite Instruction Specification Version
};
struct rite_section_lineno_header {
RITE_SECTION_HEADER;
uint8_t rite_version[4]; /* Rite Instruction Specification Version */
};
struct rite_section_debug_header {
RITE_SECTION_HEADER;
};
struct rite_section_lv_header {
RITE_SECTION_HEADER;
};
#define RITE_LV_NULL_MARK UINT16_MAX
struct rite_binary_footer {
RITE_SECTION_HEADER;
};
static inline int
bigendian_p()
{
int i;
char *p;
i = 1;
p = (char*)&i;
return p[0]?0:1;
}
static inline size_t
uint8_to_bin(uint8_t s, uint8_t *bin)
{
*bin = s;
return sizeof(uint8_t);
}
static inline int
static inline size_t
uint16_to_bin(uint16_t s, uint8_t *bin)
{
*bin++ = (s >> 8) & 0xff;
@@ -107,7 +132,7 @@ uint16_to_bin(uint16_t s, uint8_t *bin)
return sizeof(uint16_t);
}
static inline int
static inline size_t
uint32_to_bin(uint32_t l, uint8_t *bin)
{
*bin++ = (l >> 24) & 0xff;
@@ -117,6 +142,16 @@ uint32_to_bin(uint32_t l, uint8_t *bin)
return sizeof(uint32_t);
}
static inline size_t
uint32l_to_bin(uint32_t l, uint8_t *bin)
{
bin[3] = (l >> 24) & 0xff;
bin[2] = (l >> 16) & 0xff;
bin[1] = (l >> 8) & 0xff;
bin[0] = l & 0xff;
return sizeof(uint32_t);
}
static inline uint32_t
bin_to_uint32(const uint8_t *bin)
{
@@ -126,6 +161,15 @@ bin_to_uint32(const uint8_t *bin)
(uint32_t)bin[3];
}
static inline uint32_t
bin_to_uint32l(const uint8_t *bin)
{
return (uint32_t)bin[3] << 24 |
(uint32_t)bin[2] << 16 |
(uint32_t)bin[1] << 8 |
(uint32_t)bin[0];
}
static inline uint16_t
bin_to_uint16(const uint8_t *bin)
{
@@ -139,11 +183,9 @@ bin_to_uint8(const uint8_t *bin)
return (uint8_t)bin[0];
}
#if defined(__cplusplus)
} /* extern "C" { */
#endif
MRB_END_DECL
/* crc.c */
/** @internal crc.c */
uint16_t
calc_crc_16_ccitt(const uint8_t *src, size_t nbytes, uint16_t crc);
+103
View File
@@ -0,0 +1,103 @@
/**
** @file mruby/error.h - Exception class
**
** See Copyright Notice in mruby.h
*/
#ifndef MRUBY_ERROR_H
#define MRUBY_ERROR_H
#include "common.h"
/**
* MRuby error handling.
*/
MRB_BEGIN_DECL
struct RException {
MRB_OBJECT_HEADER;
struct iv_tbl *iv;
};
#define mrb_exc_ptr(v) ((struct RException*)mrb_ptr(v))
MRB_API void mrb_sys_fail(mrb_state *mrb, const char *mesg);
MRB_API mrb_value mrb_exc_new_str(mrb_state *mrb, struct RClass* c, mrb_value str);
#define mrb_exc_new_str_lit(mrb, c, lit) mrb_exc_new_str(mrb, c, mrb_str_new_lit(mrb, lit))
MRB_API mrb_value mrb_make_exception(mrb_state *mrb, mrb_int argc, const mrb_value *argv);
MRB_API mrb_value mrb_exc_backtrace(mrb_state *mrb, mrb_value exc);
MRB_API mrb_value mrb_get_backtrace(mrb_state *mrb);
MRB_API mrb_noreturn void mrb_no_method_error(mrb_state *mrb, mrb_sym id, mrb_value args, const char *fmt, ...);
/* declaration for `fail` method */
MRB_API mrb_value mrb_f_raise(mrb_state*, mrb_value);
#if defined(MRB_64BIT) || defined(MRB_USE_FLOAT) || defined(MRB_NAN_BOXING) || defined(MRB_WORD_BOXING)
struct RBreak {
MRB_OBJECT_HEADER;
struct RProc *proc;
mrb_value val;
};
#define mrb_break_value_get(brk) ((brk)->val)
#define mrb_break_value_set(brk, v) ((brk)->val = v)
#else
struct RBreak {
MRB_OBJECT_HEADER;
struct RProc *proc;
union mrb_value_union value;
};
#define RBREAK_VALUE_TT_MASK ((1 << 8) - 1)
static inline mrb_value
mrb_break_value_get(struct RBreak *brk)
{
mrb_value val;
val.value = brk->value;
val.tt = brk->flags & RBREAK_VALUE_TT_MASK;
return val;
}
static inline void
mrb_break_value_set(struct RBreak *brk, mrb_value val)
{
brk->value = val.value;
brk->flags &= ~RBREAK_VALUE_TT_MASK;
brk->flags |= val.tt;
}
#endif /* MRB_64BIT || MRB_USE_FLOAT || MRB_NAN_BOXING || MRB_WORD_BOXING */
#define mrb_break_proc_get(brk) ((brk)->proc)
#define mrb_break_proc_set(brk, p) ((brk)->proc = p)
/**
* Protect
*
* Implemented in the mruby-error mrbgem
*/
MRB_API mrb_value mrb_protect(mrb_state *mrb, mrb_func_t body, mrb_value data, mrb_bool *state);
/**
* Ensure
*
* Implemented in the mruby-error mrbgem
*/
MRB_API mrb_value mrb_ensure(mrb_state *mrb, mrb_func_t body, mrb_value b_data,
mrb_func_t ensure, mrb_value e_data);
/**
* Rescue
*
* Implemented in the mruby-error mrbgem
*/
MRB_API mrb_value mrb_rescue(mrb_state *mrb, mrb_func_t body, mrb_value b_data,
mrb_func_t rescue, mrb_value r_data);
/**
* Rescue exception
*
* Implemented in the mruby-error mrbgem
*/
MRB_API mrb_value mrb_rescue_exceptions(mrb_state *mrb, mrb_func_t body, mrb_value b_data,
mrb_func_t rescue, mrb_value r_data,
mrb_int len, struct RClass **classes);
MRB_END_DECL
#endif /* MRUBY_ERROR_H */
+81 -7
View File
@@ -1,5 +1,5 @@
/*
** gc.h - garbage collector for mruby
/**
** @file mruby/gc.h - garbage collector for mruby
**
** See Copyright Notice in mruby.h
*/
@@ -7,11 +7,85 @@
#ifndef MRUBY_GC_H
#define MRUBY_GC_H
#include "mruby.h"
#include "mruby/value.h"
#include "common.h"
typedef void (each_object_callback)(mrb_state *mrb, struct RBasic* obj, void *data);
void mrb_objspace_each_objects(mrb_state *mrb, each_object_callback* callback, void *data);
void mrb_free_context(mrb_state *mrb, struct mrb_context *c);
/**
* Uncommon memory management stuffs.
*/
MRB_BEGIN_DECL
struct mrb_state;
#define MRB_EACH_OBJ_OK 0
#define MRB_EACH_OBJ_BREAK 1
typedef int (mrb_each_object_callback)(struct mrb_state *mrb, struct RBasic *obj, void *data);
void mrb_objspace_each_objects(struct mrb_state *mrb, mrb_each_object_callback *callback, void *data);
MRB_API void mrb_free_context(struct mrb_state *mrb, struct mrb_context *c);
#ifndef MRB_GC_ARENA_SIZE
#define MRB_GC_ARENA_SIZE 100
#endif
typedef enum {
MRB_GC_STATE_ROOT = 0,
MRB_GC_STATE_MARK,
MRB_GC_STATE_SWEEP
} mrb_gc_state;
/* Disable MSVC warning "C4200: nonstandard extension used: zero-sized array
* in struct/union" when in C++ mode */
#ifdef _MSC_VER
#pragma warning(push)
#pragma warning(disable : 4200)
#endif
typedef struct mrb_heap_page {
struct RBasic *freelist;
struct mrb_heap_page *prev;
struct mrb_heap_page *next;
struct mrb_heap_page *free_next;
struct mrb_heap_page *free_prev;
mrb_bool old:1;
void *objects[];
} mrb_heap_page;
#ifdef _MSC_VER
#pragma warning(pop)
#endif
typedef struct mrb_gc {
mrb_heap_page *heaps; /* heaps for GC */
mrb_heap_page *sweeps;
mrb_heap_page *free_heaps;
size_t live; /* count of live objects */
#ifdef MRB_GC_FIXED_ARENA
struct RBasic *arena[MRB_GC_ARENA_SIZE]; /* GC protection array */
#else
struct RBasic **arena; /* GC protection array */
int arena_capa;
#endif
int arena_idx;
mrb_gc_state state; /* state of gc */
int current_white_part; /* make white object by white_part */
struct RBasic *gray_list; /* list of gray objects to be traversed incrementally */
struct RBasic *atomic_gray_list; /* list of objects to be traversed atomically */
size_t live_after_mark;
size_t threshold;
int interval_ratio;
int step_ratio;
mrb_bool iterating :1;
mrb_bool disabled :1;
mrb_bool full :1;
mrb_bool generational :1;
mrb_bool out_of_memory :1;
size_t majorgc_old_threshold;
} mrb_gc;
MRB_API mrb_bool
mrb_object_dead_p(struct mrb_state *mrb, struct RBasic *object);
MRB_END_DECL
#endif /* MRUBY_GC_H */
+189 -21
View File
@@ -1,5 +1,5 @@
/*
** mruby/hash.h - Hash class
/**
** @file mruby/hash.h - Hash class
**
** See Copyright Notice in mruby.h
*/
@@ -7,39 +7,205 @@
#ifndef MRUBY_HASH_H
#define MRUBY_HASH_H
#if defined(__cplusplus)
extern "C" {
#endif
#include "common.h"
/**
* Hash class
*/
MRB_BEGIN_DECL
struct RHash {
MRB_OBJECT_HEADER;
struct iv_tbl *iv;
struct kh_ht *ht;
struct htable *ht;
};
#define mrb_hash_ptr(v) ((struct RHash*)(mrb_ptr(v)))
#define mrb_hash_value(p) mrb_obj_value((void*)(p))
mrb_value mrb_hash_new_capa(mrb_state*, int);
mrb_value mrb_hash_new(mrb_state *mrb);
MRB_API mrb_value mrb_hash_new_capa(mrb_state *mrb, mrb_int capa);
MRB_API mrb_value mrb_ensure_hash_type(mrb_state *mrb, mrb_value hash);
MRB_API mrb_value mrb_check_hash_type(mrb_state *mrb, mrb_value hash);
void mrb_hash_set(mrb_state *mrb, mrb_value hash, mrb_value key, mrb_value val);
mrb_value mrb_hash_get(mrb_state *mrb, mrb_value hash, mrb_value key);
mrb_value mrb_hash_fetch(mrb_state *mrb, mrb_value hash, mrb_value key, mrb_value def);
mrb_value mrb_hash_delete_key(mrb_state *mrb, mrb_value hash, mrb_value key);
mrb_value mrb_hash_keys(mrb_state *mrb, mrb_value hash);
mrb_value mrb_check_hash_type(mrb_state *mrb, mrb_value hash);
mrb_value mrb_hash_empty_p(mrb_state *mrb, mrb_value self);
mrb_value mrb_hash_clear(mrb_state *mrb, mrb_value hash);
/*
* Initializes a new hash.
*
* Equivalent to:
*
* Hash.new
*
* @param mrb The mruby state reference.
* @return The initialized hash.
*/
MRB_API mrb_value mrb_hash_new(mrb_state *mrb);
/*
* Sets a keys and values to hashes.
*
* Equivalent to:
*
* hash[key] = val
*
* @param mrb The mruby state reference.
* @param hash The target hash.
* @param key The key to set.
* @param val The value to set.
* @return The value.
*/
MRB_API void mrb_hash_set(mrb_state *mrb, mrb_value hash, mrb_value key, mrb_value val);
/*
* Gets a value from a key. If the key is not found, the default of the
* hash is used.
*
* Equivalent to:
*
* hash[key]
*
* @param mrb The mruby state reference.
* @param hash The target hash.
* @param key The key to get.
* @return The found value.
*/
MRB_API mrb_value mrb_hash_get(mrb_state *mrb, mrb_value hash, mrb_value key);
/*
* Gets a value from a key. If the key is not found, the default parameter is
* used.
*
* Equivalent to:
*
* hash.key?(key) ? hash[key] : def
*
* @param mrb The mruby state reference.
* @param hash The target hash.
* @param key The key to get.
* @param def The default value.
* @return The found value.
*/
MRB_API mrb_value mrb_hash_fetch(mrb_state *mrb, mrb_value hash, mrb_value key, mrb_value def);
/*
* Deletes hash key and value pair.
*
* Equivalent to:
*
* hash.delete(key)
*
* @param mrb The mruby state reference.
* @param hash The target hash.
* @param key The key to delete.
* @return The deleted value. This value is not protected from GC. Use `mrb_gc_protect()` if necessary.
*/
MRB_API mrb_value mrb_hash_delete_key(mrb_state *mrb, mrb_value hash, mrb_value key);
/*
* Gets an array of keys.
*
* Equivalent to:
*
* hash.keys
*
* @param mrb The mruby state reference.
* @param hash The target hash.
* @return An array with the keys of the hash.
*/
MRB_API mrb_value mrb_hash_keys(mrb_state *mrb, mrb_value hash);
/*
* Check if the hash has the key.
*
* Equivalent to:
*
* hash.key?(key)
*
* @param mrb The mruby state reference.
* @param hash The target hash.
* @param key The key to check existence.
* @return True if the hash has the key
*/
MRB_API mrb_bool mrb_hash_key_p(mrb_state *mrb, mrb_value hash, mrb_value key);
/*
* Check if the hash is empty
*
* Equivalent to:
*
* hash.empty?
*
* @param mrb The mruby state reference.
* @param self The target hash.
* @return True if the hash is empty, false otherwise.
*/
MRB_API mrb_bool mrb_hash_empty_p(mrb_state *mrb, mrb_value self);
/*
* Gets an array of values.
*
* Equivalent to:
*
* hash.values
*
* @param mrb The mruby state reference.
* @param hash The target hash.
* @return An array with the values of the hash.
*/
MRB_API mrb_value mrb_hash_values(mrb_state *mrb, mrb_value hash);
/*
* Clears the hash.
*
* Equivalent to:
*
* hash.clear
*
* @param mrb The mruby state reference.
* @param hash The target hash.
* @return The hash
*/
MRB_API mrb_value mrb_hash_clear(mrb_state *mrb, mrb_value hash);
/*
* Get hash size.
*
* Equivalent to:
*
* hash.size
*
* @param mrb The mruby state reference.
* @param hash The target hash.
* @return The hash size.
*/
MRB_API mrb_int mrb_hash_size(mrb_state *mrb, mrb_value hash);
/*
* Copies the hash.
*
*
* @param mrb The mruby state reference.
* @param hash The target hash.
* @return The copy of the hash
*/
MRB_API mrb_value mrb_hash_dup(mrb_state *mrb, mrb_value hash);
/*
* Merges two hashes. The first hash will be modified by the
* second hash.
*
* @param mrb The mruby state reference.
* @param hash1 The target hash.
* @param hash2 Updating hash
*/
MRB_API void mrb_hash_merge(mrb_state *mrb, mrb_value hash1, mrb_value hash2);
/* RHASH_TBL allocates st_table if not available. */
#define RHASH(obj) ((struct RHash*)(mrb_ptr(obj)))
#define RHASH_TBL(h) (RHASH(h)->ht)
#define RHASH_IFNONE(h) mrb_iv_get(mrb, (h), mrb_intern_lit(mrb, "ifnone"))
#define RHASH_PROCDEFAULT(h) RHASH_IFNONE(h)
struct kh_ht * mrb_hash_tbl(mrb_state *mrb, mrb_value hash);
#define MRB_HASH_PROC_DEFAULT 256
#define MRB_HASH_DEFAULT 1
#define MRB_HASH_PROC_DEFAULT 2
#define MRB_RHASH_DEFAULT_P(h) (RHASH(h)->flags & MRB_HASH_DEFAULT)
#define MRB_RHASH_PROCDEFAULT_P(h) (RHASH(h)->flags & MRB_HASH_PROC_DEFAULT)
/* GC functions */
@@ -47,8 +213,10 @@ void mrb_gc_mark_hash(mrb_state*, struct RHash*);
size_t mrb_gc_mark_hash_size(mrb_state*, struct RHash*);
void mrb_gc_free_hash(mrb_state*, struct RHash*);
#if defined(__cplusplus)
} /* extern "C" { */
#endif
/* return non zero to break the loop */
typedef int (mrb_hash_foreach_func)(mrb_state *mrb, mrb_value key, mrb_value val, void *data);
MRB_API void mrb_hash_foreach(mrb_state *mrb, struct RHash *hash, mrb_hash_foreach_func *func, void *p);
MRB_END_DECL
#endif /* MRUBY_HASH_H */
+49 -16
View File
@@ -1,5 +1,5 @@
/*
** mruby/irep.h - mrb_irep structure
/**
** @file mruby/irep.h - mrb_irep structure
**
** See Copyright Notice in mruby.h
*/
@@ -7,11 +7,13 @@
#ifndef MRUBY_IREP_H
#define MRUBY_IREP_H
#if defined(__cplusplus)
extern "C" {
#endif
#include "common.h"
#include <mruby/compile.h>
#include "mruby/compile.h"
/**
* Compiled mruby scripts.
*/
MRB_BEGIN_DECL
enum irep_pool_type {
IREP_TT_STRING,
@@ -19,36 +21,67 @@ enum irep_pool_type {
IREP_TT_FLOAT,
};
struct mrb_locals {
mrb_sym name;
uint16_t r;
};
/* Program data array struct */
typedef struct mrb_irep {
uint16_t nlocals; /* Number of local variables */
uint16_t nregs; /* Number of register variables */
uint8_t flags;
mrb_code *iseq;
const mrb_code *iseq;
mrb_value *pool;
mrb_sym *syms;
struct mrb_irep **reps;
struct mrb_locals *lv;
/* debug info */
const char *filename;
uint16_t *lines;
struct mrb_irep_debug_info* debug_info;
size_t ilen, plen, slen, rlen, refcnt;
uint16_t ilen, plen, slen, rlen;
uint32_t refcnt;
} mrb_irep;
#define MRB_ISEQ_NO_FREE 1
mrb_irep *mrb_add_irep(mrb_state *mrb);
mrb_value mrb_load_irep(mrb_state*, const uint8_t*);
mrb_value mrb_load_irep_cxt(mrb_state*, const uint8_t*, mrbc_context*);
MRB_API mrb_irep *mrb_add_irep(mrb_state *mrb);
/* @param [const uint8_t*] irep code, expected as a literal */
MRB_API mrb_value mrb_load_irep(mrb_state*, const uint8_t*);
/*
* @param [const void*] irep code
* @param [size_t] size of irep buffer. If -1 is given, it is considered unrestricted.
*/
MRB_API mrb_value mrb_load_irep_buf(mrb_state*, const void*, size_t);
/* @param [const uint8_t*] irep code, expected as a literal */
MRB_API mrb_value mrb_load_irep_cxt(mrb_state*, const uint8_t*, mrbc_context*);
/*
* @param [const void*] irep code
* @param [size_t] size of irep buffer. If -1 is given, it is considered unrestricted.
*/
MRB_API mrb_value mrb_load_irep_buf_cxt(mrb_state*, const void*, size_t, mrbc_context*);
void mrb_irep_free(mrb_state*, struct mrb_irep*);
void mrb_irep_incref(mrb_state*, struct mrb_irep*);
void mrb_irep_decref(mrb_state*, struct mrb_irep*);
void mrb_irep_cutref(mrb_state*, struct mrb_irep*);
void mrb_irep_remove_lv(mrb_state *mrb, mrb_irep *irep);
#if defined(__cplusplus)
} /* extern "C" { */
#endif
struct mrb_insn_data {
uint8_t insn;
uint16_t a;
uint16_t b;
uint8_t c;
};
struct mrb_insn_data mrb_decode_insn(const mrb_code *pc);
MRB_END_DECL
#endif /* MRUBY_IREP_H */
+47
View File
@@ -0,0 +1,47 @@
/**
** @file mruby/istruct.h - Inline structures
**
** See Copyright Notice in mruby.h
*/
#ifndef MRUBY_ISTRUCT_H
#define MRUBY_ISTRUCT_H
#include "common.h"
#include <string.h>
/**
* Inline structures that fit in RVALUE
*
* They cannot have finalizer, and cannot have instance variables.
*/
MRB_BEGIN_DECL
#define ISTRUCT_DATA_SIZE (sizeof(void*) * 3)
struct RIStruct {
MRB_OBJECT_HEADER;
char inline_data[ISTRUCT_DATA_SIZE];
};
#define RISTRUCT(obj) ((struct RIStruct*)(mrb_ptr(obj)))
#define ISTRUCT_PTR(obj) (RISTRUCT(obj)->inline_data)
MRB_INLINE mrb_int mrb_istruct_size()
{
return ISTRUCT_DATA_SIZE;
}
MRB_INLINE void* mrb_istruct_ptr(mrb_value object)
{
return ISTRUCT_PTR(object);
}
MRB_INLINE void mrb_istruct_copy(mrb_value dest, mrb_value src)
{
memcpy(ISTRUCT_PTR(dest), ISTRUCT_PTR(src), ISTRUCT_DATA_SIZE);
}
MRB_END_DECL
#endif /* MRUBY_ISTRUCT_H */
+69 -51
View File
@@ -1,19 +1,22 @@
/*
** mruby/khash.c - Hash for mruby
/**
** @file mruby/khash.h - Hash for mruby
**
** See Copyright Notice in mruby.h
*/
#ifndef KHASH_H
#define KHASH_H
#ifndef MRUBY_KHASH_H
#define MRUBY_KHASH_H
#if defined(__cplusplus)
extern "C" {
#endif
#include "mruby.h"
#include <string.h>
#include <mruby.h>
#include "common.h"
/**
* khash definitions used in mruby's hash table.
*/
MRB_BEGIN_DECL
typedef uint32_t khint_t;
typedef khint_t khiter_t;
@@ -24,12 +27,12 @@ typedef khint_t khiter_t;
#define UPPER_BOUND(x) ((x)>>2|(x)>>1)
//extern uint8_t __m[];
/* extern uint8_t __m[]; */
/* mask for flags */
static const uint8_t __m_empty[8] = {0x02, 0x08, 0x20, 0x80};
static const uint8_t __m_del[8] = {0x01, 0x04, 0x10, 0x40};
static const uint8_t __m_either[8] = {0x03, 0x0c, 0x30, 0xc0};
static const uint8_t __m_empty[] = {0x02, 0x08, 0x20, 0x80};
static const uint8_t __m_del[] = {0x01, 0x04, 0x10, 0x40};
static const uint8_t __m_either[] = {0x03, 0x0c, 0x30, 0xc0};
#define __ac_isempty(ed_flag, i) (ed_flag[(i)/4]&__m_empty[(i)%4])
@@ -44,6 +47,8 @@ static const uint8_t __m_either[8] = {0x03, 0x0c, 0x30, 0xc0};
v |= v >> 16;\
v++;\
} while (0)
#define khash_mask(h) ((h)->n_buckets-1)
#define khash_upper_bound(h) (UPPER_BOUND((h)->n_buckets))
/* declare struct kh_xxx and kh_xxx_funcs
@@ -57,12 +62,9 @@ static const uint8_t __m_either[8] = {0x03, 0x0c, 0x30, 0xc0};
khint_t n_buckets; \
khint_t size; \
khint_t n_occupied; \
khint_t upper_bound; \
uint8_t *ed_flags; \
khkey_t *keys; \
khval_t *vals; \
khint_t mask; \
khint_t inc; \
} kh_##name##_t; \
void kh_alloc_##name(mrb_state *mrb, kh_##name##_t *h); \
kh_##name##_t *kh_init_##name##_size(mrb_state *mrb, khint_t size); \
@@ -70,7 +72,7 @@ static const uint8_t __m_either[8] = {0x03, 0x0c, 0x30, 0xc0};
void kh_destroy_##name(mrb_state *mrb, kh_##name##_t *h); \
void kh_clear_##name(mrb_state *mrb, kh_##name##_t *h); \
khint_t kh_get_##name(mrb_state *mrb, kh_##name##_t *h, khkey_t key); \
khint_t kh_put_##name(mrb_state *mrb, kh_##name##_t *h, khkey_t key); \
khint_t kh_put_##name(mrb_state *mrb, kh_##name##_t *h, khkey_t key, int *ret); \
void kh_resize_##name(mrb_state *mrb, kh_##name##_t *h, khint_t new_n_buckets); \
void kh_del_##name(mrb_state *mrb, kh_##name##_t *h, khint_t x); \
kh_##name##_t *kh_copy_##name(mrb_state *mrb, kh_##name##_t *h);
@@ -96,16 +98,13 @@ kh_fill_flags(uint8_t *p, uint8_t c, size_t len)
void kh_alloc_##name(mrb_state *mrb, kh_##name##_t *h) \
{ \
khint_t sz = h->n_buckets; \
int len = sizeof(khkey_t) + (kh_is_map ? sizeof(khval_t) : 0); \
uint8_t *p = mrb_malloc(mrb, sizeof(uint8_t)*sz/4+len*sz); \
size_t len = sizeof(khkey_t) + (kh_is_map ? sizeof(khval_t) : 0); \
uint8_t *p = (uint8_t*)mrb_malloc(mrb, sizeof(uint8_t)*sz/4+len*sz); \
h->size = h->n_occupied = 0; \
h->upper_bound = UPPER_BOUND(sz); \
h->keys = (khkey_t *)p; \
h->vals = kh_is_map ? (khval_t *)(p+sizeof(khkey_t)*sz) : NULL; \
h->ed_flags = p+len*sz; \
kh_fill_flags(h->ed_flags, 0xaa, sz/4); \
h->mask = sz-1; \
h->inc = sz/2-1; \
} \
kh_##name##_t *kh_init_##name##_size(mrb_state *mrb, khint_t size) { \
kh_##name##_t *h = (kh_##name##_t*)mrb_calloc(mrb, 1, sizeof(kh_##name##_t)); \
@@ -116,7 +115,7 @@ kh_fill_flags(uint8_t *p, uint8_t c, size_t len)
kh_alloc_##name(mrb, h); \
return h; \
} \
kh_##name##_t *kh_init_##name(mrb_state *mrb){ \
kh_##name##_t *kh_init_##name(mrb_state *mrb) { \
return kh_init_##name##_size(mrb, KHASH_DEFAULT_SIZE); \
} \
void kh_destroy_##name(mrb_state *mrb, kh_##name##_t *h) \
@@ -128,6 +127,7 @@ kh_fill_flags(uint8_t *p, uint8_t c, size_t len)
} \
void kh_clear_##name(mrb_state *mrb, kh_##name##_t *h) \
{ \
(void)mrb; \
if (h && h->ed_flags) { \
kh_fill_flags(h->ed_flags, 0xaa, h->n_buckets/4); \
h->size = h->n_occupied = 0; \
@@ -135,14 +135,15 @@ kh_fill_flags(uint8_t *p, uint8_t c, size_t len)
} \
khint_t kh_get_##name(mrb_state *mrb, kh_##name##_t *h, khkey_t key) \
{ \
khint_t k = __hash_func(mrb,key) & (h->mask); \
khint_t k = __hash_func(mrb,key) & khash_mask(h), step = 0; \
(void)mrb; \
while (!__ac_isempty(h->ed_flags, k)) { \
if (!__ac_isdel(h->ed_flags, k)) { \
if (__hash_equal(mrb,h->keys[k], key)) return k; \
} \
k = (k+h->inc) & (h->mask); \
k = (k+(++step)) & khash_mask(h); \
} \
return h->n_buckets; \
return kh_end(h); \
} \
void kh_resize_##name(mrb_state *mrb, kh_##name##_t *h, khint_t new_n_buckets) \
{ \
@@ -150,50 +151,68 @@ kh_fill_flags(uint8_t *p, uint8_t c, size_t len)
new_n_buckets = KHASH_MIN_SIZE; \
khash_power2(new_n_buckets); \
{ \
kh_##name##_t hh; \
uint8_t *old_ed_flags = h->ed_flags; \
khkey_t *old_keys = h->keys; \
khval_t *old_vals = h->vals; \
khint_t old_n_buckets = h->n_buckets; \
khint_t i; \
h->n_buckets = new_n_buckets; \
kh_alloc_##name(mrb, h); \
hh.n_buckets = new_n_buckets; \
kh_alloc_##name(mrb, &hh); \
/* relocate */ \
for (i=0 ; i<old_n_buckets ; i++) { \
if (!__ac_iseither(old_ed_flags, i)) { \
khint_t k = kh_put_##name(mrb, h, old_keys[i]); \
if (kh_is_map) kh_value(h,k) = old_vals[i]; \
khint_t k = kh_put_##name(mrb, &hh, old_keys[i], NULL); \
if (kh_is_map) kh_value(&hh,k) = old_vals[i]; \
} \
} \
/* copy hh to h */ \
*h = hh; \
mrb_free(mrb, old_keys); \
} \
} \
khint_t kh_put_##name(mrb_state *mrb, kh_##name##_t *h, khkey_t key) \
khint_t kh_put_##name(mrb_state *mrb, kh_##name##_t *h, khkey_t key, int *ret) \
{ \
khint_t k; \
if (h->n_occupied >= h->upper_bound) { \
khint_t k, del_k, step = 0; \
if (h->n_occupied >= khash_upper_bound(h)) { \
kh_resize_##name(mrb, h, h->n_buckets*2); \
} \
k = __hash_func(mrb,key) & (h->mask); \
while (!__ac_iseither(h->ed_flags, k)) { \
if (__hash_equal(mrb,h->keys[k], key)) break; \
k = (k+h->inc) & (h->mask); \
k = __hash_func(mrb,key) & khash_mask(h); \
del_k = kh_end(h); \
while (!__ac_isempty(h->ed_flags, k)) { \
if (!__ac_isdel(h->ed_flags, k)) { \
if (__hash_equal(mrb,h->keys[k], key)) { \
if (ret) *ret = 0; \
return k; \
} \
} \
else if (del_k == kh_end(h)) { \
del_k = k; \
} \
k = (k+(++step)) & khash_mask(h); \
} \
if (__ac_isempty(h->ed_flags, k)) { \
if (del_k != kh_end(h)) { \
/* put at del */ \
h->keys[del_k] = key; \
h->ed_flags[del_k/4] &= ~__m_del[del_k%4]; \
h->size++; \
if (ret) *ret = 2; \
return del_k; \
} \
else { \
/* put at empty */ \
h->keys[k] = key; \
h->ed_flags[k/4] &= ~__m_empty[k%4]; \
h->size++; \
h->n_occupied++; \
} else if (__ac_isdel(h->ed_flags, k)) { \
/* put at del */ \
h->keys[k] = key; \
h->ed_flags[k/4] &= ~__m_del[k%4]; \
h->size++; \
if (ret) *ret = 1; \
return k; \
} \
return k; \
} \
void kh_del_##name(mrb_state *mrb, kh_##name##_t *h, khint_t x) \
{ \
(void)mrb; \
mrb_assert(x != h->n_buckets && !__ac_iseither(h->ed_flags, x)); \
h->ed_flags[x/4] |= __m_del[x%4]; \
h->size--; \
} \
@@ -205,8 +224,8 @@ kh_fill_flags(uint8_t *p, uint8_t c, size_t len)
h2 = kh_init_##name(mrb); \
for (k = kh_begin(h); k != kh_end(h); k++) { \
if (kh_exist(h, k)) { \
k2 = kh_put_##name(mrb, h2, kh_key(h, k)); \
if(kh_is_map) kh_value(h2, k2) = kh_value(h, k); \
k2 = kh_put_##name(mrb, h2, kh_key(h, k), NULL); \
if (kh_is_map) kh_value(h2, k2) = kh_value(h, k); \
} \
} \
return h2; \
@@ -220,7 +239,8 @@ kh_fill_flags(uint8_t *p, uint8_t c, size_t len)
#define kh_destroy(name, mrb, h) kh_destroy_##name(mrb, h)
#define kh_clear(name, mrb, h) kh_clear_##name(mrb, h)
#define kh_resize(name, mrb, h, s) kh_resize_##name(mrb, h, s)
#define kh_put(name, mrb, h, k) kh_put_##name(mrb, h, k)
#define kh_put(name, mrb, h, k) kh_put_##name(mrb, h, k, NULL)
#define kh_put2(name, mrb, h, k, r) kh_put_##name(mrb, h, k, r)
#define kh_get(name, mrb, h, k) kh_get_##name(mrb, h, k)
#define kh_del(name, mrb, h, k) kh_del_##name(mrb, h, k)
#define kh_copy(name, mrb, h) kh_copy_##name(mrb, h)
@@ -249,8 +269,6 @@ static inline khint_t __ac_X31_hash_string(const char *s)
typedef const char *kh_cstr_t;
#if defined(__cplusplus)
} /* extern "C" { */
#endif
MRB_END_DECL
#endif /* KHASH_H */
#endif /* MRUBY_KHASH_H */
+183 -20
View File
@@ -1,5 +1,5 @@
/*
** mruby/numeric.h - Numeric, Integer, Float, Fixnum class
/**
** @file mruby/numeric.h - Numeric, Integer, Float, Fixnum class
**
** See Copyright Notice in mruby.h
*/
@@ -7,26 +7,189 @@
#ifndef MRUBY_NUMERIC_H
#define MRUBY_NUMERIC_H
#if defined(__cplusplus)
extern "C" {
#include "common.h"
/**
* Numeric class and it's sub-classes.
*
* Integer, Float and Fixnum
*/
MRB_BEGIN_DECL
#define TYPED_POSFIXABLE(f,t) ((f) <= (t)MRB_INT_MAX)
#define TYPED_NEGFIXABLE(f,t) ((f) >= (t)MRB_INT_MIN)
#define TYPED_FIXABLE(f,t) (TYPED_POSFIXABLE(f,t) && TYPED_NEGFIXABLE(f,t))
#define POSFIXABLE(f) TYPED_POSFIXABLE(f,mrb_int)
#define NEGFIXABLE(f) TYPED_NEGFIXABLE(f,mrb_int)
#define FIXABLE(f) TYPED_FIXABLE(f,mrb_int)
#ifndef MRB_WITHOUT_FLOAT
#ifdef MRB_INT64
#define FIXABLE_FLOAT(f) ((f)>=-9223372036854775808.0 && (f)<9223372036854775808.0)
#else
#define FIXABLE_FLOAT(f) TYPED_FIXABLE(f,mrb_float)
#endif
#endif
#define POSFIXABLE(f) ((f) <= MRB_INT_MAX)
#define NEGFIXABLE(f) ((f) >= MRB_INT_MIN)
#define FIXABLE(f) (POSFIXABLE(f) && NEGFIXABLE(f))
mrb_value mrb_flo_to_fixnum(mrb_state *mrb, mrb_value val);
mrb_value mrb_flo_to_str(mrb_state *mrb, mrb_value flo, int max_digit);
mrb_value mrb_fixnum_to_str(mrb_state *mrb, mrb_value x, int base);
mrb_value mrb_fixnum_plus(mrb_state *mrb, mrb_value x, mrb_value y);
mrb_value mrb_fixnum_minus(mrb_state *mrb, mrb_value x, mrb_value y);
mrb_value mrb_fixnum_mul(mrb_state *mrb, mrb_value x, mrb_value y);
mrb_value mrb_num_div(mrb_state *mrb, mrb_value x, mrb_value y);
#if defined(__cplusplus)
} /* extern "C" { */
#ifndef MRB_WITHOUT_FLOAT
MRB_API mrb_value mrb_flo_to_fixnum(mrb_state *mrb, mrb_value val);
#endif
MRB_API mrb_value mrb_fixnum_to_str(mrb_state *mrb, mrb_value x, mrb_int base);
/* ArgumentError if format string doesn't match /%(\.[0-9]+)?[aAeEfFgG]/ */
#ifndef MRB_WITHOUT_FLOAT
MRB_API mrb_value mrb_float_to_str(mrb_state *mrb, mrb_value x, const char *fmt);
MRB_API mrb_float mrb_to_flo(mrb_state *mrb, mrb_value x);
MRB_API mrb_value mrb_int_value(mrb_state *mrb, mrb_float f);
#endif
MRB_API mrb_value mrb_num_plus(mrb_state *mrb, mrb_value x, mrb_value y);
MRB_API mrb_value mrb_num_minus(mrb_state *mrb, mrb_value x, mrb_value y);
MRB_API mrb_value mrb_num_mul(mrb_state *mrb, mrb_value x, mrb_value y);
#ifndef __has_builtin
#define __has_builtin(x) 0
#endif
#if (defined(__GNUC__) && __GNUC__ >= 5) || \
(__has_builtin(__builtin_add_overflow) && \
__has_builtin(__builtin_sub_overflow) && \
__has_builtin(__builtin_mul_overflow))
# define MRB_HAVE_TYPE_GENERIC_CHECKED_ARITHMETIC_BUILTINS
#endif
/*
// Clang 3.8 and 3.9 have problem compiling mruby in 32-bit mode, when MRB_INT64 is set
// because of missing __mulodi4 and similar functions in its runtime. We need to use custom
// implementation for them.
*/
#ifdef MRB_HAVE_TYPE_GENERIC_CHECKED_ARITHMETIC_BUILTINS
#if defined(__clang__) && (__clang_major__ == 3) && (__clang_minor__ >= 8) && \
defined(MRB_32BIT) && defined(MRB_INT64)
#undef MRB_HAVE_TYPE_GENERIC_CHECKED_ARITHMETIC_BUILTINS
#endif
#endif
#ifdef MRB_HAVE_TYPE_GENERIC_CHECKED_ARITHMETIC_BUILTINS
#ifndef MRB_WORD_BOXING
# define WBCHK(x) 0
#else
# define WBCHK(x) !FIXABLE(x)
#endif
static inline mrb_bool
mrb_int_add_overflow(mrb_int augend, mrb_int addend, mrb_int *sum)
{
return __builtin_add_overflow(augend, addend, sum) || WBCHK(*sum);
}
static inline mrb_bool
mrb_int_sub_overflow(mrb_int minuend, mrb_int subtrahend, mrb_int *difference)
{
return __builtin_sub_overflow(minuend, subtrahend, difference) || WBCHK(*difference);
}
static inline mrb_bool
mrb_int_mul_overflow(mrb_int multiplier, mrb_int multiplicand, mrb_int *product)
{
return __builtin_mul_overflow(multiplier, multiplicand, product) || WBCHK(*product);
}
#undef WBCHK
#else
#define MRB_UINT_MAKE2(n) uint ## n ## _t
#define MRB_UINT_MAKE(n) MRB_UINT_MAKE2(n)
#define mrb_uint MRB_UINT_MAKE(MRB_INT_BIT)
#define MRB_INT_OVERFLOW_MASK ((mrb_uint)1 << (MRB_INT_BIT - 1 - MRB_FIXNUM_SHIFT))
static inline mrb_bool
mrb_int_add_overflow(mrb_int augend, mrb_int addend, mrb_int *sum)
{
mrb_uint x = (mrb_uint)augend;
mrb_uint y = (mrb_uint)addend;
mrb_uint z = (mrb_uint)(x + y);
*sum = (mrb_int)z;
return !!(((x ^ z) & (y ^ z)) & MRB_INT_OVERFLOW_MASK);
}
static inline mrb_bool
mrb_int_sub_overflow(mrb_int minuend, mrb_int subtrahend, mrb_int *difference)
{
mrb_uint x = (mrb_uint)minuend;
mrb_uint y = (mrb_uint)subtrahend;
mrb_uint z = (mrb_uint)(x - y);
*difference = (mrb_int)z;
return !!(((x ^ z) & (~y ^ z)) & MRB_INT_OVERFLOW_MASK);
}
static inline mrb_bool
mrb_int_mul_overflow(mrb_int multiplier, mrb_int multiplicand, mrb_int *product)
{
#if MRB_INT_BIT == 32
int64_t n = (int64_t)multiplier * multiplicand;
*product = (mrb_int)n;
return !FIXABLE(n);
#else
if (multiplier > 0) {
if (multiplicand > 0) {
if (multiplier > MRB_INT_MAX / multiplicand) return TRUE;
}
else {
if (multiplicand < MRB_INT_MAX / multiplier) return TRUE;
}
}
else {
if (multiplicand > 0) {
if (multiplier < MRB_INT_MAX / multiplicand) return TRUE;
}
else {
if (multiplier != 0 && multiplicand < MRB_INT_MAX / multiplier) return TRUE;
}
}
*product = multiplier * multiplicand;
return FALSE;
#endif
}
#undef MRB_INT_OVERFLOW_MASK
#undef mrb_uint
#undef MRB_UINT_MAKE
#undef MRB_UINT_MAKE2
#endif
#ifndef MRB_WITHOUT_FLOAT
# include <stdint.h>
# include <float.h>
# define MRB_FLT_RADIX FLT_RADIX
# ifdef MRB_USE_FLOAT
# define MRB_FLT_MANT_DIG FLT_MANT_DIG
# define MRB_FLT_EPSILON FLT_EPSILON
# define MRB_FLT_DIG FLT_DIG
# define MRB_FLT_MIN_EXP FLT_MIN_EXP
# define MRB_FLT_MIN FLT_MIN
# define MRB_FLT_MIN_10_EXP FLT_MIN_10_EXP
# define MRB_FLT_MAX_EXP FLT_MAX_EXP
# define MRB_FLT_MAX FLT_MAX
# define MRB_FLT_MAX_10_EXP FLT_MAX_10_EXP
# else /* not MRB_USE_FLOAT */
# define MRB_FLT_MANT_DIG DBL_MANT_DIG
# define MRB_FLT_EPSILON DBL_EPSILON
# define MRB_FLT_DIG DBL_DIG
# define MRB_FLT_MIN_EXP DBL_MIN_EXP
# define MRB_FLT_MIN DBL_MIN
# define MRB_FLT_MIN_10_EXP DBL_MIN_10_EXP
# define MRB_FLT_MAX_EXP DBL_MAX_EXP
# define MRB_FLT_MAX DBL_MAX
# define MRB_FLT_MAX_10_EXP DBL_MAX_10_EXP
# endif /* MRB_USE_FLOAT */
#endif /* MRB_WITHOUT_FLOAT */
MRB_END_DECL
#endif /* MRUBY_NUMERIC_H */
+43
View File
@@ -0,0 +1,43 @@
/**
** @file mruby/object.h - mruby object definition
**
** See Copyright Notice in mruby.h
*/
#ifndef MRUBY_OBJECT_H
#define MRUBY_OBJECT_H
#define MRB_OBJECT_HEADER \
struct RClass *c; \
struct RBasic *gcnext; \
enum mrb_vtype tt:8; \
uint32_t color:3; \
uint32_t flags:21
#define MRB_FLAG_TEST(obj, flag) ((obj)->flags & (flag))
struct RBasic {
MRB_OBJECT_HEADER;
};
#define mrb_basic_ptr(v) ((struct RBasic*)(mrb_ptr(v)))
#define MRB_FL_OBJ_IS_FROZEN (1 << 20)
#define MRB_FROZEN_P(o) ((o)->flags & MRB_FL_OBJ_IS_FROZEN)
#define MRB_SET_FROZEN_FLAG(o) ((o)->flags |= MRB_FL_OBJ_IS_FROZEN)
#define MRB_UNSET_FROZEN_FLAG(o) ((o)->flags &= ~MRB_FL_OBJ_IS_FROZEN)
#define mrb_frozen_p(o) MRB_FROZEN_P(o)
struct RObject {
MRB_OBJECT_HEADER;
struct iv_tbl *iv;
};
#define mrb_obj_ptr(v) ((struct RObject*)(mrb_ptr(v)))
#define mrb_special_const_p(x) mrb_immediate_p(x)
struct RFiber {
MRB_OBJECT_HEADER;
struct mrb_context *cxt;
};
#endif /* MRUBY_OBJECT_H */
+69
View File
@@ -0,0 +1,69 @@
/**
** @file mruby/opcode.h - RiteVM operation codes
**
** See Copyright Notice in mruby.h
*/
#ifndef MRUBY_OPCODE_H
#define MRUBY_OPCODE_H
enum mrb_insn {
#define OPCODE(x,_) OP_ ## x,
#include "mruby/ops.h"
#undef OPCODE
};
#define OP_L_STRICT 1
#define OP_L_CAPTURE 2
#define OP_L_METHOD OP_L_STRICT
#define OP_L_LAMBDA (OP_L_STRICT|OP_L_CAPTURE)
#define OP_L_BLOCK OP_L_CAPTURE
#define OP_R_NORMAL 0
#define OP_R_BREAK 1
#define OP_R_RETURN 2
#define PEEK_B(pc) (*(pc))
#define PEEK_S(pc) ((pc)[0]<<8|(pc)[1])
#define PEEK_W(pc) ((pc)[0]<<16|(pc)[1]<<8|(pc)[2])
#define READ_B() PEEK_B(pc++)
#define READ_S() (pc+=2, PEEK_S(pc-2))
#define READ_W() (pc+=3, PEEK_W(pc-3))
#define FETCH_Z() /* nothing */
#define FETCH_B() do {a=READ_B();} while (0)
#define FETCH_BB() do {a=READ_B(); b=READ_B();} while (0)
#define FETCH_BBB() do {a=READ_B(); b=READ_B(); c=READ_B();} while (0)
#define FETCH_BS() do {a=READ_B(); b=READ_S();} while (0)
#define FETCH_S() do {a=READ_S();} while (0)
#define FETCH_W() do {a=READ_W();} while (0)
/* with OP_EXT1 (1st 16bit) */
#define FETCH_Z_1() FETCH_Z()
#define FETCH_B_1() FETCH_S()
#define FETCH_BB_1() do {a=READ_S(); b=READ_B();} while (0)
#define FETCH_BBB_1() do {a=READ_S(); b=READ_B(); c=READ_B();} while (0)
#define FETCH_BS_1() do {a=READ_S(); b=READ_S();} while (0)
#define FETCH_S_1() FETCH_S()
#define FETCH_W_1() FETCH_W()
/* with OP_EXT2 (2nd 16bit) */
#define FETCH_Z_2() FETCH_Z()
#define FETCH_B_2() FETCH_B()
#define FETCH_BB_2() do {a=READ_B(); b=READ_S();} while (0)
#define FETCH_BBB_2() do {a=READ_B(); b=READ_S(); c=READ_B();} while (0)
#define FETCH_BS_2() FETCH_BS()
#define FETCH_S_2() FETCH_S()
#define FETCH_W_2() FETCH_W()
/* with OP_EXT3 (1st & 2nd 16bit) */
#define FETCH_Z_3() FETCH_Z()
#define FETCH_B_3() FETCH_B()
#define FETCH_BB_3() do {a=READ_S(); b=READ_S();} while (0)
#define FETCH_BBB_3() do {a=READ_S(); b=READ_S(); c=READ_B();} while (0)
#define FETCH_BS_3() do {a=READ_S(); b=READ_S();} while (0)
#define FETCH_S_3() FETCH_S()
#define FETCH_W_3() FETCH_W()
#endif /* MRUBY_OPCODE_H */
+117
View File
@@ -0,0 +1,117 @@
/* operand types:
+ Z: no operand (Z,Z,Z,Z)
+ B: 8bit (B,S,B,B)
+ BB: 8+8bit (BB,SB,BS,SS)
+ BBB: 8+8+8bit (BBB,SBB,BSB,SSB)
+ BS: 8+16bit (BS,SS,BS,BS)
+ S: 16bit (S,S,S,S)
+ W: 24bit (W,W,W,W)
*/
/*-----------------------------------------------------------------------
operation code operands semantics
------------------------------------------------------------------------*/
OPCODE(NOP, Z) /* no operation */
OPCODE(MOVE, BB) /* R(a) = R(b) */
OPCODE(LOADL, BB) /* R(a) = Pool(b) */
OPCODE(LOADI, BB) /* R(a) = mrb_int(b) */
OPCODE(LOADINEG, BB) /* R(a) = mrb_int(-b) */
OPCODE(LOADI__1, B) /* R(a) = mrb_int(-1) */
OPCODE(LOADI_0, B) /* R(a) = mrb_int(0) */
OPCODE(LOADI_1, B) /* R(a) = mrb_int(1) */
OPCODE(LOADI_2, B) /* R(a) = mrb_int(2) */
OPCODE(LOADI_3, B) /* R(a) = mrb_int(3) */
OPCODE(LOADI_4, B) /* R(a) = mrb_int(4) */
OPCODE(LOADI_5, B) /* R(a) = mrb_int(5) */
OPCODE(LOADI_6, B) /* R(a) = mrb_int(6) */
OPCODE(LOADI_7, B) /* R(a) = mrb_int(7) */
OPCODE(LOADSYM, BB) /* R(a) = Syms(b) */
OPCODE(LOADNIL, B) /* R(a) = nil */
OPCODE(LOADSELF, B) /* R(a) = self */
OPCODE(LOADT, B) /* R(a) = true */
OPCODE(LOADF, B) /* R(a) = false */
OPCODE(GETGV, BB) /* R(a) = getglobal(Syms(b)) */
OPCODE(SETGV, BB) /* setglobal(Syms(b), R(a)) */
OPCODE(GETSV, BB) /* R(a) = Special[Syms(b)] */
OPCODE(SETSV, BB) /* Special[Syms(b)] = R(a) */
OPCODE(GETIV, BB) /* R(a) = ivget(Syms(b)) */
OPCODE(SETIV, BB) /* ivset(Syms(b),R(a)) */
OPCODE(GETCV, BB) /* R(a) = cvget(Syms(b)) */
OPCODE(SETCV, BB) /* cvset(Syms(b),R(a)) */
OPCODE(GETCONST, BB) /* R(a) = constget(Syms(b)) */
OPCODE(SETCONST, BB) /* constset(Syms(b),R(a)) */
OPCODE(GETMCNST, BB) /* R(a) = R(a)::Syms(b) */
OPCODE(SETMCNST, BB) /* R(a+1)::Syms(b) = R(a) */
OPCODE(GETUPVAR, BBB) /* R(a) = uvget(b,c) */
OPCODE(SETUPVAR, BBB) /* uvset(b,c,R(a)) */
OPCODE(JMP, S) /* pc=a */
OPCODE(JMPIF, BS) /* if R(a) pc=b */
OPCODE(JMPNOT, BS) /* if !R(a) pc=b */
OPCODE(JMPNIL, BS) /* if R(a)==nil pc=b */
OPCODE(ONERR, S) /* rescue_push(a) */
OPCODE(EXCEPT, B) /* R(a) = exc */
OPCODE(RESCUE, BB) /* R(b) = R(a).isa?(R(b)) */
OPCODE(POPERR, B) /* a.times{rescue_pop()} */
OPCODE(RAISE, B) /* raise(R(a)) */
OPCODE(EPUSH, B) /* ensure_push(SEQ[a]) */
OPCODE(EPOP, B) /* A.times{ensure_pop().call} */
OPCODE(SENDV, BB) /* R(a) = call(R(a),Syms(b),*R(a+1)) */
OPCODE(SENDVB, BB) /* R(a) = call(R(a),Syms(b),*R(a+1),&R(a+2)) */
OPCODE(SEND, BBB) /* R(a) = call(R(a),Syms(b),R(a+1),...,R(a+c)) */
OPCODE(SENDB, BBB) /* R(a) = call(R(a),Syms(b),R(a+1),...,R(a+c),&R(a+c+1)) */
OPCODE(CALL, Z) /* R(0) = self.call(frame.argc, frame.argv) */
OPCODE(SUPER, BB) /* R(a) = super(R(a+1),... ,R(a+b+1)) */
OPCODE(ARGARY, BS) /* R(a) = argument array (16=m5:r1:m5:d1:lv4) */
OPCODE(ENTER, W) /* arg setup according to flags (23=m5:o5:r1:m5:k5:d1:b1) */
OPCODE(KEY_P, BB) /* R(a) = kdict.key?(Syms(b)) # todo */
OPCODE(KEYEND, Z) /* raise unless kdict.empty? # todo */
OPCODE(KARG, BB) /* R(a) = kdict[Syms(b)]; kdict.delete(Syms(b)) # todo */
OPCODE(RETURN, B) /* return R(a) (normal) */
OPCODE(RETURN_BLK, B) /* return R(a) (in-block return) */
OPCODE(BREAK, B) /* break R(a) */
OPCODE(BLKPUSH, BS) /* R(a) = block (16=m5:r1:m5:d1:lv4) */
OPCODE(ADD, B) /* R(a) = R(a)+R(a+1) */
OPCODE(ADDI, BB) /* R(a) = R(a)+mrb_int(b) */
OPCODE(SUB, B) /* R(a) = R(a)-R(a+1) */
OPCODE(SUBI, BB) /* R(a) = R(a)-mrb_int(b) */
OPCODE(MUL, B) /* R(a) = R(a)*R(a+1) */
OPCODE(DIV, B) /* R(a) = R(a)/R(a+1) */
OPCODE(EQ, B) /* R(a) = R(a)==R(a+1) */
OPCODE(LT, B) /* R(a) = R(a)<R(a+1) */
OPCODE(LE, B) /* R(a) = R(a)<=R(a+1) */
OPCODE(GT, B) /* R(a) = R(a)>R(a+1) */
OPCODE(GE, B) /* R(a) = R(a)>=R(a+1) */
OPCODE(ARRAY, BB) /* R(a) = ary_new(R(a),R(a+1)..R(a+b)) */
OPCODE(ARRAY2, BBB) /* R(a) = ary_new(R(b),R(b+1)..R(b+c)) */
OPCODE(ARYCAT, B) /* ary_cat(R(a),R(a+1)) */
OPCODE(ARYPUSH, B) /* ary_push(R(a),R(a+1)) */
OPCODE(ARYDUP, B) /* R(a) = ary_dup(R(a)) */
OPCODE(AREF, BBB) /* R(a) = R(b)[c] */
OPCODE(ASET, BBB) /* R(a)[c] = R(b) */
OPCODE(APOST, BBB) /* *R(a),R(a+1)..R(a+c) = R(a)[b..] */
OPCODE(INTERN, B) /* R(a) = intern(R(a)) */
OPCODE(STRING, BB) /* R(a) = str_dup(Lit(b)) */
OPCODE(STRCAT, B) /* str_cat(R(a),R(a+1)) */
OPCODE(HASH, BB) /* R(a) = hash_new(R(a),R(a+1)..R(a+b)) */
OPCODE(HASHADD, BB) /* R(a) = hash_push(R(a),R(a+1)..R(a+b)) */
OPCODE(HASHCAT, B) /* R(a) = hash_cat(R(a),R(a+1)) */
OPCODE(LAMBDA, BB) /* R(a) = lambda(SEQ[b],L_LAMBDA) */
OPCODE(BLOCK, BB) /* R(a) = lambda(SEQ[b],L_BLOCK) */
OPCODE(METHOD, BB) /* R(a) = lambda(SEQ[b],L_METHOD) */
OPCODE(RANGE_INC, B) /* R(a) = range_new(R(a),R(a+1),FALSE) */
OPCODE(RANGE_EXC, B) /* R(a) = range_new(R(a),R(a+1),TRUE) */
OPCODE(OCLASS, B) /* R(a) = ::Object */
OPCODE(CLASS, BB) /* R(a) = newclass(R(a),Syms(b),R(a+1)) */
OPCODE(MODULE, BB) /* R(a) = newmodule(R(a),Syms(b)) */
OPCODE(EXEC, BB) /* R(a) = blockexec(R(a),SEQ[b]) */
OPCODE(DEF, BB) /* R(a).newmethod(Syms(b),R(a+1)) */
OPCODE(ALIAS, BB) /* alias_method(target_class,Syms(a),Syms(b)) */
OPCODE(UNDEF, B) /* undef_method(target_class,Syms(a)) */
OPCODE(SCLASS, B) /* R(a) = R(a).singleton_class */
OPCODE(TCLASS, B) /* R(a) = target_class */
OPCODE(DEBUG, BBB) /* print a,b,c */
OPCODE(ERR, B) /* raise(LocalJumpError, Lit(a)) */
OPCODE(EXT1, Z) /* make 1st operand 16bit */
OPCODE(EXT2, Z) /* make 2nd operand 16bit */
OPCODE(EXT3, Z) /* make 1st and 2nd operands 16bit */
OPCODE(STOP, Z) /* stop VM */
+94 -19
View File
@@ -1,5 +1,5 @@
/*
** mruby/proc.h - Proc class
/**
** @file mruby/proc.h - Proc class
**
** See Copyright Notice in mruby.h
*/
@@ -7,56 +7,131 @@
#ifndef MRUBY_PROC_H
#define MRUBY_PROC_H
#include "mruby/irep.h"
#include "common.h"
#include <mruby/irep.h>
#if defined(__cplusplus)
extern "C" {
#endif
/**
* Proc class
*/
MRB_BEGIN_DECL
struct REnv {
MRB_OBJECT_HEADER;
mrb_value *stack;
struct mrb_context *cxt;
mrb_sym mid;
int cioff;
};
/* flags (21bits): 1(shared flag):10(cioff/bidx):10(stack_len) */
#define MRB_ENV_SET_STACK_LEN(e,len) ((e)->flags = (((e)->flags & ~0x3ff)|((unsigned int)(len) & 0x3ff)))
#define MRB_ENV_STACK_LEN(e) ((mrb_int)((e)->flags & 0x3ff))
#define MRB_ENV_STACK_UNSHARED (1<<20)
#define MRB_ENV_UNSHARE_STACK(e) ((e)->flags |= MRB_ENV_STACK_UNSHARED)
#define MRB_ENV_STACK_SHARED_P(e) (((e)->flags & MRB_ENV_STACK_UNSHARED) == 0)
#define MRB_ENV_BIDX(e) (((e)->flags >> 10) & 0x3ff)
#define MRB_ENV_SET_BIDX(e,idx) ((e)->flags = (((e)->flags & ~(0x3ff<<10))|((unsigned int)(idx) & 0x3ff)<<10))
void mrb_env_unshare(mrb_state*, struct REnv*);
struct RProc {
MRB_OBJECT_HEADER;
union {
mrb_irep *irep;
mrb_func_t func;
} body;
struct RClass *target_class;
struct REnv *env;
struct RProc *upper;
union {
struct RClass *target_class;
struct REnv *env;
} e;
};
/* aspec access */
#define MRB_ASPEC_REQ(a) (((a) >> 18) & 0x1f)
#define MRB_ASPEC_OPT(a) (((a) >> 13) & 0x1f)
#define MRB_ASPEC_REST(a) ((a) & (1<<12))
#define MRB_ASPEC_REST(a) (((a) >> 12) & 0x1)
#define MRB_ASPEC_POST(a) (((a) >> 7) & 0x1f)
#define MRB_ASPEC_KEY(a) (((a) >> 2) & 0x1f)
#define MRB_ASPEC_KDICT(a) ((a) & (1<<1))
#define MRB_ASPEC_BLOCK(a) ((a) & 1)
#define MRB_PROC_CFUNC 128
#define MRB_PROC_CFUNC_P(p) (((p)->flags & MRB_PROC_CFUNC) != 0)
#define MRB_PROC_CFUNC_FL 128
#define MRB_PROC_CFUNC_P(p) (((p)->flags & MRB_PROC_CFUNC_FL) != 0)
#define MRB_PROC_CFUNC(p) (p)->body.func
#define MRB_PROC_STRICT 256
#define MRB_PROC_STRICT_P(p) (((p)->flags & MRB_PROC_STRICT) != 0)
#define MRB_PROC_ORPHAN 512
#define MRB_PROC_ORPHAN_P(p) (((p)->flags & MRB_PROC_ORPHAN) != 0)
#define MRB_PROC_ENVSET 1024
#define MRB_PROC_ENV_P(p) (((p)->flags & MRB_PROC_ENVSET) != 0)
#define MRB_PROC_ENV(p) (MRB_PROC_ENV_P(p) ? (p)->e.env : NULL)
#define MRB_PROC_TARGET_CLASS(p) (MRB_PROC_ENV_P(p) ? (p)->e.env->c : (p)->e.target_class)
#define MRB_PROC_SET_TARGET_CLASS(p,tc) do {\
if (MRB_PROC_ENV_P(p)) {\
(p)->e.env->c = (tc);\
mrb_field_write_barrier(mrb, (struct RBasic*)(p)->e.env, (struct RBasic*)(tc));\
}\
else {\
(p)->e.target_class = (tc);\
mrb_field_write_barrier(mrb, (struct RBasic*)p, (struct RBasic*)(tc));\
}\
} while (0)
#define MRB_PROC_SCOPE 2048
#define MRB_PROC_SCOPE_P(p) (((p)->flags & MRB_PROC_SCOPE) != 0)
#define mrb_proc_ptr(v) ((struct RProc*)(mrb_ptr(v)))
struct RProc *mrb_proc_new(mrb_state*, mrb_irep*);
struct RProc *mrb_proc_new_cfunc(mrb_state*, mrb_func_t);
struct RProc *mrb_closure_new(mrb_state*, mrb_irep*);
struct RProc *mrb_closure_new_cfunc(mrb_state *mrb, mrb_func_t func, int nlocals);
MRB_API struct RProc *mrb_proc_new_cfunc(mrb_state*, mrb_func_t);
MRB_API struct RProc *mrb_closure_new_cfunc(mrb_state *mrb, mrb_func_t func, int nlocals);
void mrb_proc_copy(struct RProc *a, struct RProc *b);
mrb_int mrb_proc_arity(const struct RProc *p);
#include "mruby/khash.h"
KHASH_DECLARE(mt, mrb_sym, struct RProc*, 1)
/* implementation of #send method */
mrb_value mrb_f_send(mrb_state *mrb, mrb_value self);
#if defined(__cplusplus)
} /* extern "C" { */
#endif
/* following functions are defined in mruby-proc-ext so please include it when using */
MRB_API struct RProc *mrb_proc_new_cfunc_with_env(mrb_state *mrb, mrb_func_t func, mrb_int argc, const mrb_value *argv);
MRB_API mrb_value mrb_proc_cfunc_env_get(mrb_state *mrb, mrb_int idx);
/* old name */
#define mrb_cfunc_env_get(mrb, idx) mrb_proc_cfunc_env_get(mrb, idx)
#define MRB_METHOD_FUNC_FL 1
#define MRB_METHOD_NOARG_FL 2
#ifndef MRB_METHOD_T_STRUCT
#define MRB_METHOD_FUNC_P(m) (((uintptr_t)(m))&MRB_METHOD_FUNC_FL)
#define MRB_METHOD_NOARG_P(m) (((uintptr_t)(m))&MRB_METHOD_NOARG_FL)
#define MRB_METHOD_NOARG_SET(m) ((m)=(mrb_method_t)(((uintptr_t)(m))|MRB_METHOD_NOARG_FL))
#define MRB_METHOD_FUNC(m) ((mrb_func_t)((uintptr_t)(m)>>2))
#define MRB_METHOD_FROM_FUNC(m,fn) ((m)=(mrb_method_t)((((uintptr_t)(fn))<<2)|MRB_METHOD_FUNC_FL))
#define MRB_METHOD_FROM_PROC(m,pr) ((m)=(mrb_method_t)(pr))
#define MRB_METHOD_PROC_P(m) (!MRB_METHOD_FUNC_P(m))
#define MRB_METHOD_PROC(m) ((struct RProc*)(m))
#define MRB_METHOD_UNDEF_P(m) ((m)==0)
#else
#define MRB_METHOD_FUNC_P(m) ((m).flags&MRB_METHOD_FUNC_FL)
#define MRB_METHOD_NOARG_P(m) ((m).flags&MRB_METHOD_NOARG_FL)
#define MRB_METHOD_FUNC(m) ((m).func)
#define MRB_METHOD_NOARG_SET(m) do{(m).flags|=MRB_METHOD_NOARG_FL;}while(0)
#define MRB_METHOD_FROM_FUNC(m,fn) do{(m).flags=MRB_METHOD_FUNC_FL;(m).func=(fn);}while(0)
#define MRB_METHOD_FROM_PROC(m,pr) do{(m).flags=0;(m).proc=(pr);}while(0)
#define MRB_METHOD_PROC_P(m) (!MRB_METHOD_FUNC_P(m))
#define MRB_METHOD_PROC(m) ((m).proc)
#define MRB_METHOD_UNDEF_P(m) ((m).proc==NULL)
#endif /* MRB_METHOD_T_STRUCT */
#define MRB_METHOD_CFUNC_P(m) (MRB_METHOD_FUNC_P(m)?TRUE:(MRB_METHOD_PROC(m)?(MRB_PROC_CFUNC_P(MRB_METHOD_PROC(m))):FALSE))
#define MRB_METHOD_CFUNC(m) (MRB_METHOD_FUNC_P(m)?MRB_METHOD_FUNC(m):((MRB_METHOD_PROC(m)&&MRB_PROC_CFUNC_P(MRB_METHOD_PROC(m)))?MRB_PROC_CFUNC(MRB_METHOD_PROC(m)):NULL))
#include <mruby/khash.h>
KHASH_DECLARE(mt, mrb_sym, mrb_method_t, TRUE)
MRB_END_DECL
#endif /* MRUBY_PROC_H */
+59 -15
View File
@@ -1,5 +1,5 @@
/*
** mruby/range.h - Range class
/**
** @file mruby/range.h - Range class
**
** See Copyright Notice in mruby.h
*/
@@ -7,29 +7,73 @@
#ifndef MRUBY_RANGE_H
#define MRUBY_RANGE_H
#if defined(__cplusplus)
extern "C" {
#include "common.h"
/**
* Range class
*/
MRB_BEGIN_DECL
#if defined(MRB_NAN_BOXING) && defined(MRB_64BIT) || defined(MRB_WORD_BOXING)
# define MRB_RANGE_EMBED
#endif
#ifdef MRB_RANGE_EMBED
struct RRange {
MRB_OBJECT_HEADER;
mrb_value beg;
mrb_value end;
mrb_bool excl;
};
# define mrb_gc_free_range(mrb, p) ((void)0)
# define RANGE_BEG(p) ((p)->beg)
# define RANGE_END(p) ((p)->end)
#else
typedef struct mrb_range_edges {
mrb_value beg;
mrb_value end;
} mrb_range_edges;
struct RRange {
MRB_OBJECT_HEADER;
mrb_range_edges *edges;
int excl;
mrb_bool excl;
};
#define mrb_range_ptr(v) ((struct RRange*)(mrb_ptr(v)))
#define mrb_range_value(p) mrb_obj_value((void*)(p))
mrb_value mrb_range_new(mrb_state*, mrb_value, mrb_value, int);
mrb_int mrb_range_beg_len(mrb_state *mrb, mrb_value range, mrb_int *begp, mrb_int *lenp, mrb_int len);
#if defined(__cplusplus)
} /* extern "C" { */
# define mrb_gc_free_range(mrb, p) mrb_free(mrb, (p)->edges)
# define RANGE_BEG(p) ((p)->edges->beg)
# define RANGE_END(p) ((p)->edges->end)
#endif
#define mrb_range_beg(mrb, r) RANGE_BEG(mrb_range_ptr(mrb, r))
#define mrb_range_end(mrb, r) RANGE_END(mrb_range_ptr(mrb, r))
#define mrb_range_excl_p(mrb, r) RANGE_EXCL(mrb_range_ptr(mrb, r))
#define mrb_range_raw_ptr(r) ((struct RRange*)mrb_ptr(r))
#define mrb_range_value(p) mrb_obj_value((void*)(p))
#define RANGE_EXCL(p) ((p)->excl)
MRB_API struct RRange* mrb_range_ptr(mrb_state *mrb, mrb_value range);
/*
* Initializes a Range.
*
* If the third parameter is FALSE then it includes the last value in the range.
* If the third parameter is TRUE then it excludes the last value in the range.
*
* @param start the beginning value.
* @param end the ending value.
* @param exclude represents the inclusion or exclusion of the last value.
*/
MRB_API mrb_value mrb_range_new(mrb_state *mrb, mrb_value start, mrb_value end, mrb_bool exclude);
enum mrb_range_beg_len {
MRB_RANGE_TYPE_MISMATCH = 0, /* (failure) not range */
MRB_RANGE_OK = 1, /* (success) range */
MRB_RANGE_OUT = 2 /* (failure) out of range */
};
MRB_API enum mrb_range_beg_len mrb_range_beg_len(mrb_state *mrb, mrb_value range, mrb_int *begp, mrb_int *lenp, mrb_int len, mrb_bool trunc);
mrb_value mrb_get_values_at(mrb_state *mrb, mrb_value obj, mrb_int olen, mrb_int argc, const mrb_value *argv, mrb_value (*func)(mrb_state*, mrb_value, mrb_int));
void mrb_gc_mark_range(mrb_state *mrb, struct RRange *r);
MRB_END_DECL
#endif /* MRUBY_RANGE_H */
+16
View File
@@ -0,0 +1,16 @@
/**
** @file mruby/re.h - Regexp class
**
** See Copyright Notice in mruby.h
*/
#ifndef MRUBY_RE_H
#define MRUBY_RE_H
MRB_BEGIN_DECL
#define REGEXP_CLASS "Regexp"
MRB_END_DECL
#endif /* RE_H */
+448 -58
View File
@@ -1,5 +1,5 @@
/*
** mruby/string.h - String class
/**
** @file mruby/string.h - String class
**
** See Copyright Notice in mruby.h
*/
@@ -7,77 +7,467 @@
#ifndef MRUBY_STRING_H
#define MRUBY_STRING_H
#if defined(__cplusplus)
extern "C" {
#endif
#include "common.h"
#define IS_EVSTR(p,e) ((p) < (e) && (*(p) == '$' || *(p) == '@' || *(p) == '{'))
/**
* String class
*/
MRB_BEGIN_DECL
extern const char mrb_digitmap[];
#define RSTRING_EMBED_LEN_MAX \
((mrb_int)(sizeof(void*) * 3 + sizeof(void*) - 32 / CHAR_BIT - 1))
struct RString {
MRB_OBJECT_HEADER;
mrb_int len;
union {
mrb_int capa;
struct mrb_shared_string *shared;
} aux;
char *ptr;
struct {
mrb_int len;
union {
mrb_int capa;
struct mrb_shared_string *shared;
struct RString *fshared;
} aux;
char *ptr;
} heap;
} as;
};
struct RStringEmbed {
MRB_OBJECT_HEADER;
char ary[];
};
#define mrb_str_ptr(s) ((struct RString*)(mrb_ptr(s)))
#define RSTRING(s) ((struct RString*)(mrb_ptr(s)))
#define RSTRING_PTR(s) (RSTRING(s)->ptr)
#define RSTRING_LEN(s) (RSTRING(s)->len)
#define RSTRING_CAPA(s) (RSTRING(s)->aux.capa)
#define RSTRING_END(s) (RSTRING(s)->ptr + RSTRING(s)->len)
#define RSTR_SET_TYPE_FLAG(s, type) (RSTR_UNSET_TYPE_FLAG(s), (s)->flags |= MRB_STR_##type)
#define RSTR_UNSET_TYPE_FLAG(s) ((s)->flags &= ~(MRB_STR_TYPE_MASK|MRB_STR_EMBED_LEN_MASK))
#define MRB_STR_SHARED 1
#define MRB_STR_NOFREE 2
#define RSTR_EMBED_P(s) ((s)->flags & MRB_STR_EMBED)
#define RSTR_SET_EMBED_FLAG(s) ((s)->flags |= MRB_STR_EMBED)
#define RSTR_UNSET_EMBED_FLAG(s) ((s)->flags &= ~(MRB_STR_EMBED|MRB_STR_EMBED_LEN_MASK))
#define RSTR_SET_EMBED_LEN(s, n) do {\
size_t tmp_n = (n);\
(s)->flags &= ~MRB_STR_EMBED_LEN_MASK;\
(s)->flags |= (tmp_n) << MRB_STR_EMBED_LEN_SHIFT;\
} while (0)
#define RSTR_SET_LEN(s, n) do {\
if (RSTR_EMBED_P(s)) {\
RSTR_SET_EMBED_LEN((s),(n));\
}\
else {\
(s)->as.heap.len = (mrb_int)(n);\
}\
} while (0)
#define RSTR_EMBED_PTR(s) (((struct RStringEmbed*)(s))->ary)
#define RSTR_EMBED_LEN(s)\
(mrb_int)(((s)->flags & MRB_STR_EMBED_LEN_MASK) >> MRB_STR_EMBED_LEN_SHIFT)
#define RSTR_EMBEDDABLE_P(len) ((len) <= RSTRING_EMBED_LEN_MAX)
void mrb_gc_free_str(mrb_state*, struct RString*);
void mrb_str_modify(mrb_state*, struct RString*);
mrb_value mrb_str_literal(mrb_state*, mrb_value);
void mrb_str_concat(mrb_state*, mrb_value, mrb_value);
mrb_value mrb_str_plus(mrb_state*, mrb_value, mrb_value);
mrb_value mrb_ptr_to_str(mrb_state *, void*);
mrb_value mrb_obj_as_string(mrb_state *mrb, mrb_value obj);
mrb_value mrb_str_resize(mrb_state *mrb, mrb_value str, mrb_int len);
mrb_value mrb_str_substr(mrb_state *mrb, mrb_value str, mrb_int beg, mrb_int len);
mrb_value mrb_string_type(mrb_state *mrb, mrb_value str);
mrb_value mrb_check_string_type(mrb_state *mrb, mrb_value str);
mrb_value mrb_str_buf_new(mrb_state *mrb, mrb_int capa);
mrb_value mrb_str_buf_cat(mrb_state *mrb, mrb_value str, const char *ptr, size_t len);
#define RSTR_PTR(s) ((RSTR_EMBED_P(s)) ? RSTR_EMBED_PTR(s) : (s)->as.heap.ptr)
#define RSTR_LEN(s) ((RSTR_EMBED_P(s)) ? RSTR_EMBED_LEN(s) : (s)->as.heap.len)
#define RSTR_CAPA(s) (RSTR_EMBED_P(s) ? RSTRING_EMBED_LEN_MAX : (s)->as.heap.aux.capa)
char *mrb_string_value_cstr(mrb_state *mrb, mrb_value *ptr);
char *mrb_string_value_ptr(mrb_state *mrb, mrb_value ptr);
int mrb_str_offset(mrb_state *mrb, mrb_value str, int pos);
mrb_value mrb_str_dup(mrb_state *mrb, mrb_value str);
mrb_value mrb_str_intern(mrb_state *mrb, mrb_value self);
mrb_value mrb_str_cat_cstr(mrb_state *, mrb_value, const char *);
mrb_value mrb_str_to_inum(mrb_state *mrb, mrb_value str, int base, int badcheck);
double mrb_str_to_dbl(mrb_state *mrb, mrb_value str, int badcheck);
mrb_value mrb_str_to_str(mrb_state *mrb, mrb_value str);
mrb_int mrb_str_hash(mrb_state *mrb, mrb_value str);
mrb_value mrb_str_buf_append(mrb_state *mrb, mrb_value str, mrb_value str2);
mrb_value mrb_str_inspect(mrb_state *mrb, mrb_value str);
mrb_bool mrb_str_equal(mrb_state *mrb, mrb_value str1, mrb_value str2);
mrb_value mrb_str_dump(mrb_state *mrb, mrb_value str);
mrb_value mrb_str_cat(mrb_state *mrb, mrb_value str, const char *ptr, size_t len);
mrb_value mrb_str_append(mrb_state *mrb, mrb_value str, mrb_value str2);
#define RSTR_SHARED_P(s) ((s)->flags & MRB_STR_SHARED)
#define RSTR_SET_SHARED_FLAG(s) ((s)->flags |= MRB_STR_SHARED)
#define RSTR_UNSET_SHARED_FLAG(s) ((s)->flags &= ~MRB_STR_SHARED)
int mrb_str_cmp(mrb_state *mrb, mrb_value str1, mrb_value str2);
char *mrb_str_to_cstr(mrb_state *mrb, mrb_value str);
mrb_value mrb_str_pool(mrb_state *mrb, mrb_value str);
#define RSTR_FSHARED_P(s) ((s)->flags & MRB_STR_FSHARED)
#define RSTR_SET_FSHARED_FLAG(s) ((s)->flags |= MRB_STR_FSHARED)
#define RSTR_UNSET_FSHARED_FLAG(s) ((s)->flags &= ~MRB_STR_FSHARED)
/* For backward compatibility */
static inline mrb_value
mrb_str_cat2(mrb_state *mrb, mrb_value str, const char *ptr) {
return mrb_str_cat_cstr(mrb, str, ptr);
}
#define RSTR_NOFREE_P(s) ((s)->flags & MRB_STR_NOFREE)
#define RSTR_SET_NOFREE_FLAG(s) ((s)->flags |= MRB_STR_NOFREE)
#define RSTR_UNSET_NOFREE_FLAG(s) ((s)->flags &= ~MRB_STR_NOFREE)
#if defined(__cplusplus)
} /* extern "C" { */
#ifdef MRB_UTF8_STRING
# define RSTR_ASCII_P(s) ((s)->flags & MRB_STR_ASCII)
# define RSTR_SET_ASCII_FLAG(s) ((s)->flags |= MRB_STR_ASCII)
# define RSTR_UNSET_ASCII_FLAG(s) ((s)->flags &= ~MRB_STR_ASCII)
# define RSTR_WRITE_ASCII_FLAG(s, v) (RSTR_UNSET_ASCII_FLAG(s), (s)->flags |= v)
# define RSTR_COPY_ASCII_FLAG(dst, src) RSTR_WRITE_ASCII_FLAG(dst, RSTR_ASCII_P(src))
#else
# define RSTR_ASCII_P(s) (void)0
# define RSTR_SET_ASCII_FLAG(s) (void)0
# define RSTR_UNSET_ASCII_FLAG(s) (void)0
# define RSTR_WRITE_ASCII_FLAG(s, v) (void)0
# define RSTR_COPY_ASCII_FLAG(dst, src) (void)0
#endif
#define RSTR_POOL_P(s) ((s)->flags & MRB_STR_POOL)
#define RSTR_SET_POOL_FLAG(s) ((s)->flags |= MRB_STR_POOL)
/**
* Returns a pointer from a Ruby string
*/
#define mrb_str_ptr(s) ((struct RString*)(mrb_ptr(s)))
#define RSTRING(s) mrb_str_ptr(s)
#define RSTRING_PTR(s) RSTR_PTR(RSTRING(s))
#define RSTRING_EMBED_LEN(s) RSTR_EMBED_LEN(RSTRING(s))
#define RSTRING_LEN(s) RSTR_LEN(RSTRING(s))
#define RSTRING_CAPA(s) RSTR_CAPA(RSTRING(s))
#define RSTRING_END(s) (RSTRING_PTR(s) + RSTRING_LEN(s))
MRB_API mrb_int mrb_str_strlen(mrb_state*, struct RString*);
#define RSTRING_CSTR(mrb,s) mrb_string_cstr(mrb, s)
#define MRB_STR_SHARED 1
#define MRB_STR_FSHARED 2
#define MRB_STR_NOFREE 4
#define MRB_STR_EMBED 8 /* type flags up to here */
#define MRB_STR_POOL 16 /* status flags from here */
#define MRB_STR_ASCII 32
#define MRB_STR_EMBED_LEN_SHIFT 6
#define MRB_STR_EMBED_LEN_BITSIZE 5
#define MRB_STR_EMBED_LEN_MASK (((1 << MRB_STR_EMBED_LEN_BITSIZE) - 1) << MRB_STR_EMBED_LEN_SHIFT)
#define MRB_STR_TYPE_MASK (MRB_STR_POOL - 1)
void mrb_gc_free_str(mrb_state*, struct RString*);
MRB_API void mrb_str_modify(mrb_state *mrb, struct RString *s);
/* mrb_str_modify() with keeping ASCII flag if set */
MRB_API void mrb_str_modify_keep_ascii(mrb_state *mrb, struct RString *s);
/**
* Finds the index of a substring in a string
*/
MRB_API mrb_int mrb_str_index(mrb_state *mrb, mrb_value str, const char *p, mrb_int len, mrb_int offset);
#define mrb_str_index_lit(mrb, str, lit, off) mrb_str_index(mrb, str, lit, mrb_strlen_lit(lit), off);
/**
* Appends self to other. Returns self as a concatenated string.
*
*
* Example:
*
* int
* main(int argc,
* char **argv)
* {
* // Variable declarations.
* mrb_value str1;
* mrb_value str2;
*
* mrb_state *mrb = mrb_open();
* if (!mrb)
* {
* // handle error
* }
*
* // Creates new Ruby strings.
* str1 = mrb_str_new_lit(mrb, "abc");
* str2 = mrb_str_new_lit(mrb, "def");
*
* // Concatenates str2 to str1.
* mrb_str_concat(mrb, str1, str2);
*
* // Prints new Concatenated Ruby string.
* mrb_p(mrb, str1);
*
* mrb_close(mrb);
* return 0;
* }
*
* Result:
*
* => "abcdef"
*
* @param mrb The current mruby state.
* @param self String to concatenate.
* @param other String to append to self.
* @return [mrb_value] Returns a new String appending other to self.
*/
MRB_API void mrb_str_concat(mrb_state *mrb, mrb_value self, mrb_value other);
/**
* Adds two strings together.
*
*
* Example:
*
* int
* main(int argc,
* char **argv)
* {
* // Variable declarations.
* mrb_value a;
* mrb_value b;
* mrb_value c;
*
* mrb_state *mrb = mrb_open();
* if (!mrb)
* {
* // handle error
* }
*
* // Creates two Ruby strings from the passed in C strings.
* a = mrb_str_new_lit(mrb, "abc");
* b = mrb_str_new_lit(mrb, "def");
*
* // Prints both C strings.
* mrb_p(mrb, a);
* mrb_p(mrb, b);
*
* // Concatenates both Ruby strings.
* c = mrb_str_plus(mrb, a, b);
*
* // Prints new Concatenated Ruby string.
* mrb_p(mrb, c);
*
* mrb_close(mrb);
* return 0;
* }
*
*
* Result:
*
* => "abc" # First string
* => "def" # Second string
* => "abcdef" # First & Second concatenated.
*
* @param mrb The current mruby state.
* @param a First string to concatenate.
* @param b Second string to concatenate.
* @return [mrb_value] Returns a new String containing a concatenated to b.
*/
MRB_API mrb_value mrb_str_plus(mrb_state *mrb, mrb_value a, mrb_value b);
/**
* Converts pointer into a Ruby string.
*
* @param mrb The current mruby state.
* @param p The pointer to convert to Ruby string.
* @return [mrb_value] Returns a new Ruby String.
*/
MRB_API mrb_value mrb_ptr_to_str(mrb_state *mrb, void *p);
/**
* Returns an object as a Ruby string.
*
* @param mrb The current mruby state.
* @param obj An object to return as a Ruby string.
* @return [mrb_value] An object as a Ruby string.
*/
MRB_API mrb_value mrb_obj_as_string(mrb_state *mrb, mrb_value obj);
/**
* Resizes the string's length. Returns the amount of characters
* in the specified by len.
*
* Example:
*
* int
* main(int argc,
* char **argv)
* {
* // Variable declaration.
* mrb_value str;
*
* mrb_state *mrb = mrb_open();
* if (!mrb)
* {
* // handle error
* }
* // Creates a new string.
* str = mrb_str_new_lit(mrb, "Hello, world!");
* // Returns 5 characters of
* mrb_str_resize(mrb, str, 5);
* mrb_p(mrb, str);
*
* mrb_close(mrb);
* return 0;
* }
*
* Result:
*
* => "Hello"
*
* @param mrb The current mruby state.
* @param str The Ruby string to resize.
* @param len The length.
* @return [mrb_value] An object as a Ruby string.
*/
MRB_API mrb_value mrb_str_resize(mrb_state *mrb, mrb_value str, mrb_int len);
/**
* Returns a sub string.
*
* Example:
*
* int
* main(int argc,
* char const **argv)
* {
* // Variable declarations.
* mrb_value str1;
* mrb_value str2;
*
* mrb_state *mrb = mrb_open();
* if (!mrb)
* {
* // handle error
* }
* // Creates new string.
* str1 = mrb_str_new_lit(mrb, "Hello, world!");
* // Returns a sub-string within the range of 0..2
* str2 = mrb_str_substr(mrb, str1, 0, 2);
*
* // Prints sub-string.
* mrb_p(mrb, str2);
*
* mrb_close(mrb);
* return 0;
* }
*
* Result:
*
* => "He"
*
* @param mrb The current mruby state.
* @param str Ruby string.
* @param beg The beginning point of the sub-string.
* @param len The end point of the sub-string.
* @return [mrb_value] An object as a Ruby sub-string.
*/
MRB_API mrb_value mrb_str_substr(mrb_state *mrb, mrb_value str, mrb_int beg, mrb_int len);
/**
* Returns a Ruby string type.
*
*
* @param mrb The current mruby state.
* @param str Ruby string.
* @return [mrb_value] A Ruby string.
*/
MRB_API mrb_value mrb_ensure_string_type(mrb_state *mrb, mrb_value str);
MRB_API mrb_value mrb_check_string_type(mrb_state *mrb, mrb_value str);
/* obsolete: use mrb_ensure_string_type() instead */
MRB_API mrb_value mrb_string_type(mrb_state *mrb, mrb_value str);
MRB_API mrb_value mrb_str_new_capa(mrb_state *mrb, size_t capa);
MRB_API mrb_value mrb_str_buf_new(mrb_state *mrb, size_t capa);
/* NULL terminated C string from mrb_value */
MRB_API const char *mrb_string_cstr(mrb_state *mrb, mrb_value str);
/* NULL terminated C string from mrb_value; `str` will be updated */
MRB_API const char *mrb_string_value_cstr(mrb_state *mrb, mrb_value *str);
/* obslete: use RSTRING_PTR() */
MRB_API const char *mrb_string_value_ptr(mrb_state *mrb, mrb_value str);
/* obslete: use RSTRING_LEN() */
MRB_API mrb_int mrb_string_value_len(mrb_state *mrb, mrb_value str);
/**
* Duplicates a string object.
*
*
* @param mrb The current mruby state.
* @param str Ruby string.
* @return [mrb_value] Duplicated Ruby string.
*/
MRB_API mrb_value mrb_str_dup(mrb_state *mrb, mrb_value str);
/**
* Returns a symbol from a passed in Ruby string.
*
* @param mrb The current mruby state.
* @param self Ruby string.
* @return [mrb_value] A symbol.
*/
MRB_API mrb_value mrb_str_intern(mrb_state *mrb, mrb_value self);
MRB_API mrb_value mrb_str_to_inum(mrb_state *mrb, mrb_value str, mrb_int base, mrb_bool badcheck);
MRB_API mrb_value mrb_cstr_to_inum(mrb_state *mrb, const char *s, mrb_int base, mrb_bool badcheck);
MRB_API double mrb_str_to_dbl(mrb_state *mrb, mrb_value str, mrb_bool badcheck);
MRB_API double mrb_cstr_to_dbl(mrb_state *mrb, const char *s, mrb_bool badcheck);
/**
* Returns a converted string type.
* For type checking, non converting `mrb_to_str` is recommended.
*/
MRB_API mrb_value mrb_str_to_str(mrb_state *mrb, mrb_value str);
/**
* Returns true if the strings match and false if the strings don't match.
*
* @param mrb The current mruby state.
* @param str1 Ruby string to compare.
* @param str2 Ruby string to compare.
* @return [mrb_value] boolean value.
*/
MRB_API mrb_bool mrb_str_equal(mrb_state *mrb, mrb_value str1, mrb_value str2);
/**
* Returns a concatenated string comprised of a Ruby string and a C string.
*
* @param mrb The current mruby state.
* @param str Ruby string.
* @param ptr A C string.
* @param len length of C string.
* @return [mrb_value] A Ruby string.
* @see mrb_str_cat_cstr
*/
MRB_API mrb_value mrb_str_cat(mrb_state *mrb, mrb_value str, const char *ptr, size_t len);
/**
* Returns a concatenated string comprised of a Ruby string and a C string.
*
* @param mrb The current mruby state.
* @param str Ruby string.
* @param ptr A C string.
* @return [mrb_value] A Ruby string.
* @see mrb_str_cat
*/
MRB_API mrb_value mrb_str_cat_cstr(mrb_state *mrb, mrb_value str, const char *ptr);
MRB_API mrb_value mrb_str_cat_str(mrb_state *mrb, mrb_value str, mrb_value str2);
#define mrb_str_cat_lit(mrb, str, lit) mrb_str_cat(mrb, str, lit, mrb_strlen_lit(lit))
/**
* Adds str2 to the end of str1.
*/
MRB_API mrb_value mrb_str_append(mrb_state *mrb, mrb_value str, mrb_value str2);
/**
* Returns 0 if both Ruby strings are equal. Returns a value < 0 if Ruby str1 is less than Ruby str2. Returns a value > 0 if Ruby str2 is greater than Ruby str1.
*/
MRB_API int mrb_str_cmp(mrb_state *mrb, mrb_value str1, mrb_value str2);
/**
* Returns a newly allocated C string from a Ruby string.
* This is an utility function to pass a Ruby string to C library functions.
*
* - Returned string does not contain any NUL characters (but terminator).
* - It raises an ArgumentError exception if Ruby string contains
* NUL characters.
* - Retured string will be freed automatically on next GC.
* - Caller can modify returned string without affecting Ruby string
* (e.g. it can be used for mkstemp(3)).
*
* @param mrb The current mruby state.
* @param str Ruby string. Must be an instance of String.
* @return [char *] A newly allocated C string.
*/
MRB_API char *mrb_str_to_cstr(mrb_state *mrb, mrb_value str);
mrb_value mrb_str_pool(mrb_state *mrb, mrb_value str);
uint32_t mrb_str_hash(mrb_state *mrb, mrb_value str);
mrb_value mrb_str_dump(mrb_state *mrb, mrb_value str);
/**
* Returns a printable version of str, surrounded by quote marks, with special characters escaped.
*/
mrb_value mrb_str_inspect(mrb_state *mrb, mrb_value str);
/* For backward compatibility */
#define mrb_str_cat2(mrb, str, ptr) mrb_str_cat_cstr(mrb, str, ptr)
#define mrb_str_buf_cat(mrb, str, ptr, len) mrb_str_cat(mrb, str, ptr, len)
#define mrb_str_buf_append(mrb, str, str2) mrb_str_cat_str(mrb, str, str2)
mrb_bool mrb_str_beg_len(mrb_int str_len, mrb_int *begp, mrb_int *lenp);
mrb_value mrb_str_byte_subseq(mrb_state *mrb, mrb_value str, mrb_int beg, mrb_int len);
#ifdef MRB_UTF8_STRING
mrb_int mrb_utf8_len(const char *str, mrb_int byte_len);
#endif
MRB_END_DECL
#endif /* MRUBY_STRING_H */
+55
View File
@@ -0,0 +1,55 @@
/**
** @file mruby/throw.h - mruby exception throwing handler
**
** See Copyright Notice in mruby.h
*/
#ifndef MRB_THROW_H
#define MRB_THROW_H
#if defined(MRB_ENABLE_CXX_ABI)
# if !defined(__cplusplus)
# error Trying to use C++ exception handling in C code
# endif
#endif
#if defined(MRB_ENABLE_CXX_EXCEPTION) && defined(__cplusplus)
#define MRB_TRY(buf) try {
#define MRB_CATCH(buf) } catch(mrb_jmpbuf_impl e) { if (e != (buf)->impl) { throw e; }
#define MRB_END_EXC(buf) }
#define MRB_THROW(buf) throw((buf)->impl)
typedef mrb_int mrb_jmpbuf_impl;
#else
#include <setjmp.h>
#if defined(__APPLE__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)
#define MRB_SETJMP _setjmp
#define MRB_LONGJMP _longjmp
#else
#define MRB_SETJMP setjmp
#define MRB_LONGJMP longjmp
#endif
#define MRB_TRY(buf) if (MRB_SETJMP((buf)->impl) == 0) {
#define MRB_CATCH(buf) } else {
#define MRB_END_EXC(buf) }
#define MRB_THROW(buf) MRB_LONGJMP((buf)->impl, 1);
#define mrb_jmpbuf_impl jmp_buf
#endif
struct mrb_jmpbuf {
mrb_jmpbuf_impl impl;
#if defined(MRB_ENABLE_CXX_EXCEPTION) && defined(__cplusplus)
static mrb_int jmpbuf_id;
mrb_jmpbuf() : impl(jmpbuf_id++) {}
#endif
};
#endif /* MRB_THROW_H */
+294 -412
View File
@@ -1,5 +1,5 @@
/*
** mruby/value.h - mrb_value definition
/**
** @file mruby/value.h - mruby value definitions
**
** See Copyright Notice in mruby.h
*/
@@ -7,195 +7,122 @@
#ifndef MRUBY_VALUE_H
#define MRUBY_VALUE_H
#ifdef MRB_USE_FLOAT
typedef float mrb_float;
# define mrb_float_to_str(buf, i) sprintf(buf, "%.7e", i)
# define str_to_mrb_float(buf) strtof(buf, NULL)
#else
typedef double mrb_float;
# define mrb_float_to_str(buf, i) sprintf(buf, "%.16e", i)
# define str_to_mrb_float(buf) strtod(buf, NULL)
#endif
#include "common.h"
/*
* MRuby Value definition functions and macros.
*/
MRB_BEGIN_DECL
/**
* mruby Symbol.
* @class mrb_sym
*
* You can create an mrb_sym by simply using mrb_str_intern() or mrb_intern_cstr()
*/
typedef uint32_t mrb_sym;
/**
* mruby Boolean.
* @class mrb_bool
*
*
* Used internally to represent boolean. Can be TRUE or FALSE.
* Not to be confused with Ruby's boolean classes, which can be
* obtained using mrb_false_value() and mrb_true_value()
*/
typedef uint8_t mrb_bool;
struct mrb_state;
#if defined(MRB_INT16) && defined(MRB_INT64)
# error "You can't define MRB_INT16 and MRB_INT64 at the same time."
#endif
#if defined(MRB_INT64)
# ifdef MRB_NAN_BOXING
# error Cannot use NaN boxing when mrb_int is 64bit
# else
typedef int64_t mrb_int;
# define MRB_INT_MIN INT64_MIN
# define MRB_INT_MAX INT64_MAX
# define PRIdMRB_INT PRId64
# define PRIiMRB_INT PRIi64
# define PRIoMRB_INT PRIo64
# define PRIxMRB_INT PRIx64
# define PRIXMRB_INT PRIX64
# endif
#elif defined(MRB_INT16)
typedef int16_t mrb_int;
# define MRB_INT_MIN INT16_MIN
# define MRB_INT_MAX INT16_MAX
#else
typedef int32_t mrb_int;
# define MRB_INT_MIN INT32_MIN
# define MRB_INT_MAX INT32_MAX
# define PRIdMRB_INT PRId32
# define PRIiMRB_INT PRIi32
# define PRIoMRB_INT PRIo32
# define PRIxMRB_INT PRIx32
# define PRIXMRB_INT PRIX32
#endif
typedef short mrb_sym;
#ifdef _MSC_VER
# ifndef __cplusplus
# define inline __inline
# endif
# define snprintf _snprintf
# if _MSC_VER < 1800
# include <float.h>
# define isnan _isnan
# define isinf(n) (!_finite(n) && !_isnan(n))
# define strtoll _strtoi64
# define strtof (float)strtod
# define PRId32 "I32d"
# define PRIi32 "I32i"
# define PRIo32 "I32o"
# define PRIx32 "I32x"
# define PRIX32 "I32X"
# define PRId64 "I64d"
# define PRIi64 "I64i"
# define PRIo64 "I64o"
# define PRIx64 "I64x"
# define PRIX64 "I64X"
# else
# include <inttypes.h>
# endif
#if defined _MSC_VER && _MSC_VER < 1800
# define PRIo64 "llo"
# define PRId64 "lld"
# define PRIu64 "llu"
# define PRIx64 "llx"
# define PRIo16 "ho"
# define PRId16 "hd"
# define PRIu16 "hu"
# define PRIx16 "hx"
# define PRIo32 "o"
# define PRId32 "d"
# define PRIu32 "u"
# define PRIx32 "x"
#else
# include <inttypes.h>
#endif
typedef uint8_t mrb_bool;
struct mrb_state;
#if defined(MRB_NAN_BOXING)
#ifdef MRB_USE_FLOAT
# error ---->> MRB_NAN_BOXING and MRB_USE_FLOAT conflict <<----
#if defined(MRB_INT64)
typedef int64_t mrb_int;
# define MRB_INT_BIT 64
# define MRB_INT_MIN (INT64_MIN>>MRB_FIXNUM_SHIFT)
# define MRB_INT_MAX (INT64_MAX>>MRB_FIXNUM_SHIFT)
# define MRB_PRIo PRIo64
# define MRB_PRId PRId64
# define MRB_PRIx PRIx64
#elif defined(MRB_INT16)
typedef int16_t mrb_int;
# define MRB_INT_BIT 16
# define MRB_INT_MIN (INT16_MIN>>MRB_FIXNUM_SHIFT)
# define MRB_INT_MAX (INT16_MAX>>MRB_FIXNUM_SHIFT)
# define MRB_PRIo PRIo16
# define MRB_PRId PRId16
# define MRB_PRIx PRIx16
#else
typedef int32_t mrb_int;
# define MRB_INT_BIT 32
# define MRB_INT_MIN (INT32_MIN>>MRB_FIXNUM_SHIFT)
# define MRB_INT_MAX (INT32_MAX>>MRB_FIXNUM_SHIFT)
# define MRB_PRIo PRIo32
# define MRB_PRId PRId32
# define MRB_PRIx PRIx32
#endif
#ifdef MRB_INT64
# error ---->> MRB_NAN_BOXING and MRB_INT64 conflict <<----
#endif
enum mrb_vtype {
MRB_TT_FALSE = 1, /* 1 */
MRB_TT_FREE, /* 2 */
MRB_TT_TRUE, /* 3 */
MRB_TT_FIXNUM, /* 4 */
MRB_TT_SYMBOL, /* 5 */
MRB_TT_UNDEF, /* 6 */
MRB_TT_FLOAT, /* 7 */
MRB_TT_CPTR, /* 8 */
MRB_TT_OBJECT, /* 9 */
MRB_TT_CLASS, /* 10 */
MRB_TT_MODULE, /* 11 */
MRB_TT_ICLASS, /* 12 */
MRB_TT_SCLASS, /* 13 */
MRB_TT_PROC, /* 14 */
MRB_TT_ARRAY, /* 15 */
MRB_TT_HASH, /* 16 */
MRB_TT_STRING, /* 17 */
MRB_TT_RANGE, /* 18 */
MRB_TT_EXCEPTION, /* 19 */
MRB_TT_FILE, /* 20 */
MRB_TT_ENV, /* 21 */
MRB_TT_DATA, /* 22 */
MRB_TT_FIBER, /* 23 */
MRB_TT_MAXDEFINE /* 24 */
};
#define MRB_TT_HAS_BASIC MRB_TT_OBJECT
#ifdef MRB_ENDIAN_BIG
#define MRB_ENDIAN_LOHI(a,b) a b
# define MRB_ENDIAN_LOHI(a,b) a b
#else
#define MRB_ENDIAN_LOHI(a,b) b a
# define MRB_ENDIAN_LOHI(a,b) b a
#endif
typedef struct mrb_value {
union {
mrb_float f;
union {
void *p;
struct {
MRB_ENDIAN_LOHI(
uint32_t ttt;
,union {
mrb_int i;
mrb_sym sym;
};
)
};
} value;
};
} mrb_value;
/* value representation by nan-boxing:
* float : FFFFFFFFFFFFFFFF FFFFFFFFFFFFFFFF FFFFFFFFFFFFFFFF FFFFFFFFFFFFFFFF
* object: 111111111111TTTT TTPPPPPPPPPPPPPP PPPPPPPPPPPPPPPP PPPPPPPPPPPPPPPP
* int : 1111111111110001 0000000000000000 IIIIIIIIIIIIIIII IIIIIIIIIIIIIIII
* sym : 1111111111110001 0100000000000000 SSSSSSSSSSSSSSSS SSSSSSSSSSSSSSSS
* In order to get enough bit size to save TT, all pointers are shifted 2 bits
* in the right direction.
*/
#define mrb_tt(o) (((o).value.ttt & 0xfc000)>>14)
#define mrb_mktt(tt) (0xfff00000|((tt)<<14))
#define mrb_type(o) ((uint32_t)0xfff00000 < (o).value.ttt ? mrb_tt(o) : MRB_TT_FLOAT)
#define mrb_ptr(o) ((void*)((((uintptr_t)0x3fffffffffff)&((uintptr_t)((o).value.p)))<<2))
#define mrb_float(o) (o).f
#define MRB_SET_VALUE(o, tt, attr, v) do {\
(o).value.ttt = mrb_mktt(tt);\
switch (tt) {\
case MRB_TT_FALSE:\
case MRB_TT_TRUE:\
case MRB_TT_UNDEF:\
case MRB_TT_FIXNUM:\
case MRB_TT_SYMBOL: (o).attr = (v); break;\
default: (o).value.i = 0; (o).value.p = (void*)((uintptr_t)(o).value.p | (((uintptr_t)(v))>>2)); break;\
}\
} while (0)
static inline mrb_value
mrb_float_value(struct mrb_state *mrb, mrb_float f)
{
mrb_value v;
if (f != f) {
v.value.ttt = 0x7ff80000;
v.value.i = 0;
} else {
v.f = f;
}
return v;
}
#define mrb_float_pool(mrb,f) mrb_float_value(mrb,f)
#ifndef MRB_WITHOUT_FLOAT
MRB_API double mrb_float_read(const char*, char**);
#ifdef MRB_USE_FLOAT
typedef float mrb_float;
#else
typedef double mrb_float;
#endif
#endif
#if defined _MSC_VER && _MSC_VER < 1900
# include <stdarg.h>
MRB_API int mrb_msvc_vsnprintf(char *s, size_t n, const char *format, va_list arg);
MRB_API int mrb_msvc_snprintf(char *s, size_t n, const char *format, ...);
# define vsnprintf(s, n, format, arg) mrb_msvc_vsnprintf(s, n, format, arg)
# define snprintf(s, n, format, ...) mrb_msvc_snprintf(s, n, format, __VA_ARGS__)
# if _MSC_VER < 1800 && !defined MRB_WITHOUT_FLOAT
# include <float.h>
# define isfinite(n) _finite(n)
# define isnan _isnan
# define isinf(n) (!_finite(n) && !_isnan(n))
# define signbit(n) (_copysign(1.0, (n)) < 0.0)
static const unsigned int IEEE754_INFINITY_BITS_SINGLE = 0x7F800000;
# define INFINITY (*(float *)&IEEE754_INFINITY_BITS_SINGLE)
# define NAN ((float)(INFINITY - INFINITY))
# endif
#endif
enum mrb_vtype {
MRB_TT_FALSE = 0, /* 0 */
MRB_TT_FREE, /* 1 */
MRB_TT_TRUE, /* 2 */
MRB_TT_TRUE, /* 1 */
MRB_TT_FLOAT, /* 2 */
MRB_TT_FIXNUM, /* 3 */
MRB_TT_SYMBOL, /* 4 */
MRB_TT_UNDEF, /* 5 */
MRB_TT_FLOAT, /* 6 */
MRB_TT_CPTR, /* 7 */
MRB_TT_CPTR, /* 6 */
MRB_TT_FREE, /* 7 */
MRB_TT_OBJECT, /* 8 */
MRB_TT_CLASS, /* 9 */
MRB_TT_MODULE, /* 10 */
@@ -211,301 +138,256 @@ enum mrb_vtype {
MRB_TT_ENV, /* 20 */
MRB_TT_DATA, /* 21 */
MRB_TT_FIBER, /* 22 */
MRB_TT_MAXDEFINE /* 23 */
MRB_TT_ISTRUCT, /* 23 */
MRB_TT_BREAK, /* 24 */
MRB_TT_MAXDEFINE /* 25 */
};
#if defined(MRB_WORD_BOXING)
#include <mruby/object.h>
#include <limits.h>
#define MRB_TT_HAS_BASIC MRB_TT_FLOAT
#ifdef MRB_DOCUMENTATION_BLOCK
enum mrb_special_consts {
MRB_Qnil = 0,
MRB_Qfalse = 2,
MRB_Qtrue = 4,
MRB_Qundef = 6,
};
#define MRB_FIXNUM_FLAG 0x01
#define MRB_FIXNUM_SHIFT 1
#define MRB_SYMBOL_FLAG 0x0e
#define MRB_SPECIAL_SHIFT 8
typedef union mrb_value {
union {
void *p;
struct {
unsigned int i_flag : MRB_FIXNUM_SHIFT;
mrb_int i : (sizeof(mrb_int) * CHAR_BIT - MRB_FIXNUM_SHIFT);
};
struct {
unsigned int sym_flag : MRB_SPECIAL_SHIFT;
int sym : (sizeof(mrb_sym) * CHAR_BIT);
};
struct RBasic *bp;
struct RFloat *fp;
struct RCptr *vp;
} value;
unsigned long w;
} mrb_value;
#define mrb_ptr(o) (o).value.p
#define mrb_float(o) (o).value.fp->f
#define MRB_SET_VALUE(o, ttt, attr, v) do {\
(o).w = 0;\
(o).attr = (v);\
switch (ttt) {\
case MRB_TT_FALSE: (o).w = (v) ? MRB_Qfalse : MRB_Qnil; break;\
case MRB_TT_TRUE: (o).w = MRB_Qtrue; break;\
case MRB_TT_UNDEF: (o).w = MRB_Qundef; break;\
case MRB_TT_FIXNUM: (o).value.i_flag = MRB_FIXNUM_FLAG; break;\
case MRB_TT_SYMBOL: (o).value.sym_flag = MRB_SYMBOL_FLAG; break;\
default: if ((o).value.bp) (o).value.bp->tt = ttt; break;\
}\
} while (0)
mrb_value mrb_float_value(struct mrb_state *mrb, mrb_float f);
mrb_value mrb_float_pool(struct mrb_state *mrb, mrb_float f);
#else /* No MRB_xxx_BOXING */
#define MRB_TT_HAS_BASIC MRB_TT_OBJECT
typedef struct mrb_value {
union {
mrb_float f;
void *p;
mrb_int i;
mrb_sym sym;
} value;
enum mrb_vtype tt;
} mrb_value;
#define mrb_type(o) (o).tt
#define mrb_ptr(o) (o).value.p
#define mrb_float(o) (o).value.f
#define MRB_SET_VALUE(o, ttt, attr, v) do {\
(o).tt = ttt;\
(o).attr = v;\
} while (0)
static inline mrb_value
mrb_float_value(struct mrb_state *mrb, mrb_float f)
{
mrb_value v;
(void) mrb;
MRB_SET_VALUE(v, MRB_TT_FLOAT, value.f, f);
return v;
}
#define mrb_float_pool(mrb,f) mrb_float_value(mrb,f)
#endif /* no boxing */
/**
* @abstract
* MRuby value boxing.
*
* Actual implementation depends on configured boxing type.
*
* @see mruby/boxing_no.h Default boxing representation
* @see mruby/boxing_word.h Word representation
* @see mruby/boxing_nan.h Boxed double representation
*/
typedef void mrb_value;
#endif
#ifdef MRB_WORD_BOXING
#define mrb_cptr(o) (o).value.vp->p
#define mrb_fixnum_p(o) ((o).value.i_flag == MRB_FIXNUM_FLAG)
#define mrb_undef_p(o) ((o).w == MRB_Qundef)
#define mrb_nil_p(o) ((o).w == MRB_Qnil)
#define mrb_bool(o) ((o).w != MRB_Qnil && (o).w != MRB_Qfalse)
#if defined(MRB_NAN_BOXING)
#include "boxing_nan.h"
#elif defined(MRB_WORD_BOXING)
#include "boxing_word.h"
#else
#include "boxing_no.h"
#endif
#define mrb_cptr(o) mrb_ptr(o)
#if !defined(MRB_SYMBOL_BITSIZE)
#define MRB_SYMBOL_BITSIZE (sizeof(mrb_sym) * CHAR_BIT)
#define MRB_SYMBOL_MAX UINT32_MAX
#endif
#ifndef mrb_immediate_p
#define mrb_immediate_p(o) (mrb_type(o) < MRB_TT_FREE)
#endif
#ifndef mrb_fixnum_p
#define mrb_fixnum_p(o) (mrb_type(o) == MRB_TT_FIXNUM)
#define mrb_undef_p(o) (mrb_type(o) == MRB_TT_UNDEF)
#define mrb_nil_p(o) (mrb_type(o) == MRB_TT_FALSE && !(o).value.i)
#define mrb_bool(o) (mrb_type(o) != MRB_TT_FALSE)
#endif /* no boxing */
#define mrb_fixnum(o) (o).value.i
#define mrb_symbol(o) (o).value.sym
#define mrb_float_p(o) (mrb_type(o) == MRB_TT_FLOAT)
#endif
#ifndef mrb_symbol_p
#define mrb_symbol_p(o) (mrb_type(o) == MRB_TT_SYMBOL)
#endif
#ifndef mrb_undef_p
#define mrb_undef_p(o) (mrb_type(o) == MRB_TT_UNDEF)
#endif
#ifndef mrb_nil_p
#define mrb_nil_p(o) (mrb_type(o) == MRB_TT_FALSE && !mrb_fixnum(o))
#endif
#ifndef mrb_false_p
#define mrb_false_p(o) (mrb_type(o) == MRB_TT_FALSE && !!mrb_fixnum(o))
#endif
#ifndef mrb_true_p
#define mrb_true_p(o) (mrb_type(o) == MRB_TT_TRUE)
#endif
#ifndef MRB_WITHOUT_FLOAT
#ifndef mrb_float_p
#define mrb_float_p(o) (mrb_type(o) == MRB_TT_FLOAT)
#endif
#endif
#ifndef mrb_array_p
#define mrb_array_p(o) (mrb_type(o) == MRB_TT_ARRAY)
#endif
#ifndef mrb_string_p
#define mrb_string_p(o) (mrb_type(o) == MRB_TT_STRING)
#endif
#ifndef mrb_hash_p
#define mrb_hash_p(o) (mrb_type(o) == MRB_TT_HASH)
#endif
#ifndef mrb_cptr_p
#define mrb_cptr_p(o) (mrb_type(o) == MRB_TT_CPTR)
#endif
#ifndef mrb_exception_p
#define mrb_exception_p(o) (mrb_type(o) == MRB_TT_EXCEPTION)
#endif
#ifndef mrb_free_p
#define mrb_free_p(o) (mrb_type(o) == MRB_TT_FREE)
#endif
#ifndef mrb_object_p
#define mrb_object_p(o) (mrb_type(o) == MRB_TT_OBJECT)
#endif
#ifndef mrb_class_p
#define mrb_class_p(o) (mrb_type(o) == MRB_TT_CLASS)
#endif
#ifndef mrb_module_p
#define mrb_module_p(o) (mrb_type(o) == MRB_TT_MODULE)
#endif
#ifndef mrb_iclass_p
#define mrb_iclass_p(o) (mrb_type(o) == MRB_TT_ICLASS)
#endif
#ifndef mrb_sclass_p
#define mrb_sclass_p(o) (mrb_type(o) == MRB_TT_SCLASS)
#endif
#ifndef mrb_proc_p
#define mrb_proc_p(o) (mrb_type(o) == MRB_TT_PROC)
#endif
#ifndef mrb_range_p
#define mrb_range_p(o) (mrb_type(o) == MRB_TT_RANGE)
#endif
#ifndef mrb_file_p
#define mrb_file_p(o) (mrb_type(o) == MRB_TT_FILE)
#endif
#ifndef mrb_env_p
#define mrb_env_p(o) (mrb_type(o) == MRB_TT_ENV)
#endif
#ifndef mrb_data_p
#define mrb_data_p(o) (mrb_type(o) == MRB_TT_DATA)
#endif
#ifndef mrb_fiber_p
#define mrb_fiber_p(o) (mrb_type(o) == MRB_TT_FIBER)
#endif
#ifndef mrb_istruct_p
#define mrb_istruct_p(o) (mrb_type(o) == MRB_TT_ISTRUCT)
#endif
#ifndef mrb_break_p
#define mrb_break_p(o) (mrb_type(o) == MRB_TT_BREAK)
#endif
#ifndef mrb_bool
#define mrb_bool(o) (mrb_type(o) != MRB_TT_FALSE)
#endif
#define mrb_test(o) mrb_bool(o)
#define MRB_OBJECT_HEADER \
enum mrb_vtype tt:8;\
uint32_t color:3;\
uint32_t flags:21;\
struct RClass *c;\
struct RBasic *gcnext
/* white: 011, black: 100, gray: 000 */
#define MRB_GC_GRAY 0
#define MRB_GC_WHITE_A 1
#define MRB_GC_WHITE_B (1 << 1)
#define MRB_GC_BLACK (1 << 2)
#define MRB_GC_WHITES (MRB_GC_WHITE_A | MRB_GC_WHITE_B)
#define MRB_GC_COLOR_MASK 7
#define paint_gray(o) ((o)->color = MRB_GC_GRAY)
#define paint_black(o) ((o)->color = MRB_GC_BLACK)
#define paint_white(o) ((o)->color = MRB_GC_WHITES)
#define paint_partial_white(s, o) ((o)->color = (s)->current_white_part)
#define is_gray(o) ((o)->color == MRB_GC_GRAY)
#define is_white(o) ((o)->color & MRB_GC_WHITES)
#define is_black(o) ((o)->color & MRB_GC_BLACK)
#define is_dead(s, o) (((o)->color & other_white_part(s) & MRB_GC_WHITES) || (o)->tt == MRB_TT_FREE)
#define flip_white_part(s) ((s)->current_white_part = other_white_part(s))
#define other_white_part(s) ((s)->current_white_part ^ MRB_GC_WHITES)
struct RBasic {
MRB_OBJECT_HEADER;
};
#define mrb_basic_ptr(v) ((struct RBasic*)(mrb_ptr(v)))
/* obsolete macro mrb_basic; will be removed soon */
#define mrb_basic(v) mrb_basic_ptr(v)
struct RObject {
MRB_OBJECT_HEADER;
struct iv_tbl *iv;
};
#define mrb_obj_ptr(v) ((struct RObject*)(mrb_ptr(v)))
/* obsolete macro mrb_object; will be removed soon */
#define mrb_object(o) mrb_obj_ptr(o)
#define mrb_immediate_p(x) (mrb_type(x) <= MRB_TT_CPTR)
#define mrb_special_const_p(x) mrb_immediate_p(x)
struct RFiber {
MRB_OBJECT_HEADER;
struct mrb_context *cxt;
};
#ifdef MRB_WORD_BOXING
struct RFloat {
MRB_OBJECT_HEADER;
mrb_float f;
};
struct RCptr {
MRB_OBJECT_HEADER;
void *p;
};
static inline enum mrb_vtype
mrb_type(mrb_value o)
{
switch (o.w) {
case MRB_Qfalse:
case MRB_Qnil:
return MRB_TT_FALSE;
case MRB_Qtrue:
return MRB_TT_TRUE;
case MRB_Qundef:
return MRB_TT_UNDEF;
}
if (o.value.i_flag == MRB_FIXNUM_FLAG) {
return MRB_TT_FIXNUM;
}
if (o.value.sym_flag == MRB_SYMBOL_FLAG) {
return MRB_TT_SYMBOL;
}
return o.value.bp->tt;
}
#endif /* MRB_WORD_BOXING */
static inline mrb_value
mrb_fixnum_value(mrb_int i)
/**
* Returns a float in Ruby.
*
* Takes a float and boxes it into an mrb_value
*/
#ifndef MRB_WITHOUT_FLOAT
MRB_INLINE mrb_value mrb_float_value(struct mrb_state *mrb, mrb_float f)
{
mrb_value v;
MRB_SET_VALUE(v, MRB_TT_FIXNUM, value.i, i);
(void) mrb;
SET_FLOAT_VALUE(mrb, v, f);
return v;
}
#endif
static inline mrb_value
mrb_symbol_value(mrb_sym i)
{
mrb_value v;
MRB_SET_VALUE(v, MRB_TT_SYMBOL, value.sym, i);
return v;
}
static inline mrb_value
mrb_obj_value(void *p)
{
mrb_value v;
struct RBasic *b = (struct RBasic*)p;
MRB_SET_VALUE(v, b->tt, value.p, p);
return v;
}
#ifdef MRB_WORD_BOXING
mrb_value
mrb_cptr_value(struct mrb_state *mrb, void *p);
#else
static inline mrb_value
MRB_INLINE mrb_value
mrb_cptr_value(struct mrb_state *mrb, void *p)
{
mrb_value v;
(void) mrb;
MRB_SET_VALUE(v, MRB_TT_CPTR, value.p, p);
SET_CPTR_VALUE(mrb,v,p);
return v;
}
#endif
/* obsolete macros; will be removed */
#define MRB_TT_VOIDP MRB_TT_CPTR
#define mrb_voidp_value(m,p) mrb_cptr_value((m),(p))
#define mrb_voidp(o) mrb_cptr(o)
#define mrb_voidp_p(o) mrb_cptr_p(o)
static inline mrb_value
mrb_false_value(void)
/**
* Returns a fixnum in Ruby.
*
* Takes an integer and boxes it into an mrb_value
*/
MRB_INLINE mrb_value mrb_fixnum_value(mrb_int i)
{
mrb_value v;
MRB_SET_VALUE(v, MRB_TT_FALSE, value.i, 1);
SET_INT_VALUE(v, i);
return v;
}
static inline mrb_value
mrb_nil_value(void)
MRB_INLINE mrb_value
mrb_symbol_value(mrb_sym i)
{
mrb_value v;
MRB_SET_VALUE(v, MRB_TT_FALSE, value.i, 0);
SET_SYM_VALUE(v, i);
return v;
}
static inline mrb_value
mrb_true_value(void)
MRB_INLINE mrb_value
mrb_obj_value(void *p)
{
mrb_value v;
MRB_SET_VALUE(v, MRB_TT_TRUE, value.i, 1);
SET_OBJ_VALUE(v, (struct RBasic*)p);
mrb_assert(p == mrb_ptr(v));
mrb_assert(((struct RBasic*)p)->tt == mrb_type(v));
return v;
}
static inline mrb_value
mrb_undef_value(void)
/**
* Get a nil mrb_value object.
*
* @return
* nil mrb_value object reference.
*/
MRB_INLINE mrb_value mrb_nil_value(void)
{
mrb_value v;
MRB_SET_VALUE(v, MRB_TT_UNDEF, value.i, 0);
SET_NIL_VALUE(v);
return v;
}
static inline mrb_value
/**
* Returns false in Ruby.
*/
MRB_INLINE mrb_value mrb_false_value(void)
{
mrb_value v;
SET_FALSE_VALUE(v);
return v;
}
/**
* Returns true in Ruby.
*/
MRB_INLINE mrb_value mrb_true_value(void)
{
mrb_value v;
SET_TRUE_VALUE(v);
return v;
}
MRB_INLINE mrb_value
mrb_bool_value(mrb_bool boolean)
{
mrb_value v;
MRB_SET_VALUE(v, boolean ? MRB_TT_TRUE : MRB_TT_FALSE, value.i, 1);
SET_BOOL_VALUE(v, boolean);
return v;
}
#endif /* MRUBY_OBJECT_H */
MRB_INLINE mrb_value
mrb_undef_value(void)
{
mrb_value v;
SET_UNDEF_VALUE(v);
return v;
}
#if defined(MRB_USE_ETEXT_EDATA) && !defined(MRB_USE_LINK_TIME_RO_DATA_P)
# ifdef __GNUC__
# warning MRB_USE_ETEXT_EDATA is deprecated. Define MRB_USE_LINK_TIME_RO_DATA_P instead.
# endif
# define MRB_USE_LINK_TIME_RO_DATA_P
#endif
#if defined(MRB_USE_CUSTOM_RO_DATA_P)
/* If you define `MRB_USE_CUSTOM_RO_DATA_P`, you must implement `mrb_ro_data_p()`. */
mrb_bool mrb_ro_data_p(const char *p);
#elif defined(MRB_USE_LINK_TIME_RO_DATA_P)
extern char __ehdr_start[];
extern char __init_array_start[];
static inline mrb_bool
mrb_ro_data_p(const char *p)
{
return __ehdr_start < p && p < __init_array_start;
}
#else
# define mrb_ro_data_p(p) FALSE
#endif
MRB_END_DECL
#endif /* MRUBY_VALUE_H */
+102 -42
View File
@@ -1,5 +1,5 @@
/*
** mruby/variable.h - mruby variables
/**
** @file mruby/variable.h - mruby variables
**
** See Copyright Notice in mruby.h
*/
@@ -7,63 +7,121 @@
#ifndef MRUBY_VARIABLE_H
#define MRUBY_VARIABLE_H
#if defined(__cplusplus)
extern "C" {
#endif
#include "common.h"
/**
* Functions to access mruby variables.
*/
MRB_BEGIN_DECL
typedef struct global_variable {
int counter;
mrb_value *data;
mrb_value (*getter)(void);
void (*setter)(void);
//void (*marker)();
//int block_trace;
//struct trace_var *trace;
int counter;
mrb_value *data;
mrb_value (*getter)(void);
void (*setter)(void);
/* void (*marker)(); */
/* int block_trace; */
/* struct trace_var *trace; */
} global_variable;
struct global_entry {
global_variable *var;
mrb_sym id;
global_variable *var;
mrb_sym id;
};
mrb_value mrb_vm_special_get(mrb_state*, mrb_sym);
void mrb_vm_special_set(mrb_state*, mrb_sym, mrb_value);
mrb_value mrb_vm_iv_get(mrb_state*, mrb_sym);
void mrb_vm_iv_set(mrb_state*, mrb_sym, mrb_value);
mrb_value mrb_vm_cv_get(mrb_state*, mrb_sym);
void mrb_vm_cv_set(mrb_state*, mrb_sym, mrb_value);
mrb_value mrb_vm_const_get(mrb_state*, mrb_sym);
void mrb_vm_const_set(mrb_state*, mrb_sym, mrb_value);
mrb_value mrb_const_get(mrb_state*, mrb_value, mrb_sym);
void mrb_const_set(mrb_state*, mrb_value, mrb_sym, mrb_value);
mrb_bool mrb_const_defined(mrb_state*, mrb_value, mrb_sym);
void mrb_const_remove(mrb_state*, mrb_value, mrb_sym);
MRB_API mrb_value mrb_const_get(mrb_state*, mrb_value, mrb_sym);
MRB_API void mrb_const_set(mrb_state*, mrb_value, mrb_sym, mrb_value);
MRB_API mrb_bool mrb_const_defined(mrb_state*, mrb_value, mrb_sym);
MRB_API void mrb_const_remove(mrb_state*, mrb_value, mrb_sym);
mrb_value mrb_obj_iv_get(mrb_state *mrb, struct RObject *obj, mrb_sym sym);
void mrb_obj_iv_set(mrb_state *mrb, struct RObject *obj, mrb_sym sym, mrb_value v);
mrb_bool mrb_obj_iv_defined(mrb_state *mrb, struct RObject *obj, mrb_sym sym);
void mrb_obj_iv_ifnone(mrb_state *mrb, struct RObject *obj, mrb_sym sym, mrb_value v);
mrb_value mrb_iv_get(mrb_state *mrb, mrb_value obj, mrb_sym sym);
void mrb_iv_set(mrb_state *mrb, mrb_value obj, mrb_sym sym, mrb_value v);
mrb_bool mrb_iv_defined(mrb_state*, mrb_value, mrb_sym);
mrb_value mrb_iv_remove(mrb_state *mrb, mrb_value obj, mrb_sym sym);
void mrb_iv_copy(mrb_state *mrb, mrb_value dst, mrb_value src);
int mrb_const_defined_at(mrb_state *mrb, struct RClass *klass, mrb_sym id);
MRB_API mrb_bool mrb_iv_name_sym_p(mrb_state *mrb, mrb_sym sym);
MRB_API void mrb_iv_name_sym_check(mrb_state *mrb, mrb_sym sym);
MRB_API mrb_value mrb_obj_iv_get(mrb_state *mrb, struct RObject *obj, mrb_sym sym);
MRB_API void mrb_obj_iv_set(mrb_state *mrb, struct RObject *obj, mrb_sym sym, mrb_value v);
MRB_API mrb_bool mrb_obj_iv_defined(mrb_state *mrb, struct RObject *obj, mrb_sym sym);
MRB_API mrb_value mrb_iv_get(mrb_state *mrb, mrb_value obj, mrb_sym sym);
MRB_API void mrb_iv_set(mrb_state *mrb, mrb_value obj, mrb_sym sym, mrb_value v);
MRB_API mrb_bool mrb_iv_defined(mrb_state*, mrb_value, mrb_sym);
MRB_API mrb_value mrb_iv_remove(mrb_state *mrb, mrb_value obj, mrb_sym sym);
MRB_API void mrb_iv_copy(mrb_state *mrb, mrb_value dst, mrb_value src);
MRB_API mrb_bool mrb_const_defined_at(mrb_state *mrb, mrb_value mod, mrb_sym id);
/**
* Get a global variable. Will return nil if the var does not exist
*
* Example:
*
* !!!ruby
* # Ruby style
* var = $value
*
* !!!c
* // C style
* mrb_sym sym = mrb_intern_lit(mrb, "$value");
* mrb_value var = mrb_gv_get(mrb, sym);
*
* @param mrb The mruby state reference
* @param sym The name of the global variable
* @return The value of that global variable. May be nil
*/
MRB_API mrb_value mrb_gv_get(mrb_state *mrb, mrb_sym sym);
/**
* Set a global variable
*
* Example:
*
* !!!ruby
* # Ruby style
* $value = "foo"
*
* !!!c
* // C style
* mrb_sym sym = mrb_intern_lit(mrb, "$value");
* mrb_gv_set(mrb, sym, mrb_str_new_lit("foo"));
*
* @param mrb The mruby state reference
* @param sym The name of the global variable
* @param val The value of the global variable
*/
MRB_API void mrb_gv_set(mrb_state *mrb, mrb_sym sym, mrb_value val);
/**
* Remove a global variable.
*
* Example:
*
* # Ruby style
* $value = nil
*
* // C style
* mrb_sym sym = mrb_intern_lit(mrb, "$value");
* mrb_gv_remove(mrb, sym);
*
* @param mrb The mruby state reference
* @param sym The name of the global variable
*/
MRB_API void mrb_gv_remove(mrb_state *mrb, mrb_sym sym);
MRB_API mrb_value mrb_cv_get(mrb_state *mrb, mrb_value mod, mrb_sym sym);
MRB_API void mrb_mod_cv_set(mrb_state *mrb, struct RClass * c, mrb_sym sym, mrb_value v);
MRB_API void mrb_cv_set(mrb_state *mrb, mrb_value mod, mrb_sym sym, mrb_value v);
MRB_API mrb_bool mrb_cv_defined(mrb_state *mrb, mrb_value mod, mrb_sym sym);
mrb_value mrb_obj_iv_inspect(mrb_state*, struct RObject*);
void mrb_obj_iv_set_force(mrb_state *mrb, struct RObject *obj, mrb_sym sym, mrb_value v);
mrb_value mrb_mod_constants(mrb_state *mrb, mrb_value mod);
mrb_value mrb_f_global_variables(mrb_state *mrb, mrb_value self);
mrb_value mrb_gv_get(mrb_state *mrb, mrb_sym sym);
void mrb_gv_set(mrb_state *mrb, mrb_sym sym, mrb_value val);
void mrb_gv_remove(mrb_state *mrb, mrb_sym sym);
mrb_value mrb_obj_instance_variables(mrb_state*, mrb_value);
mrb_value mrb_obj_iv_inspect(mrb_state*, struct RObject*);
mrb_sym mrb_class_sym(mrb_state *mrb, struct RClass *c, struct RClass *outer);
mrb_value mrb_mod_class_variables(mrb_state*, mrb_value);
mrb_value mrb_mod_cv_get(mrb_state *mrb, struct RClass * c, mrb_sym sym);
mrb_value mrb_cv_get(mrb_state *mrb, mrb_value mod, mrb_sym sym);
void mrb_mod_cv_set(mrb_state *mrb, struct RClass * c, mrb_sym sym, mrb_value v);
void mrb_cv_set(mrb_state *mrb, mrb_value mod, mrb_sym sym, mrb_value v);
mrb_bool mrb_mod_cv_defined(mrb_state *mrb, struct RClass * c, mrb_sym sym);
mrb_bool mrb_cv_defined(mrb_state *mrb, mrb_value mod, mrb_sym sym);
mrb_bool mrb_ident_p(const char *s, mrb_int len);
/* GC functions */
void mrb_gc_mark_gv(mrb_state*);
@@ -72,8 +130,10 @@ void mrb_gc_mark_iv(mrb_state*, struct RObject*);
size_t mrb_gc_mark_iv_size(mrb_state*, struct RObject*);
void mrb_gc_free_iv(mrb_state*, struct RObject*);
#if defined(__cplusplus)
} /* extern "C" { */
#endif
/* return non zero to break the loop */
typedef int (mrb_iv_foreach_func)(mrb_state*,mrb_sym,mrb_value,void*);
MRB_API void mrb_iv_foreach(mrb_state *mrb, mrb_value obj, mrb_iv_foreach_func *func, void *p);
MRB_END_DECL
#endif /* MRUBY_VARIABLE_H */
+124
View File
@@ -0,0 +1,124 @@
/**
** @file mruby/version.h - mruby version definition
**
** See Copyright Notice in mruby.h
*/
#ifndef MRUBY_VERSION_H
#define MRUBY_VERSION_H
#include "common.h"
/**
* mruby version definition macros
*/
MRB_BEGIN_DECL
/*
* A passed in expression.
*/
#define MRB_STRINGIZE0(expr) #expr
/*
* Passes in an expression to MRB_STRINGIZE0.
*/
#define MRB_STRINGIZE(expr) MRB_STRINGIZE0(expr)
/*
* The version of Ruby used by mruby.
*/
#define MRUBY_RUBY_VERSION "2.0"
/*
* Ruby engine.
*/
#define MRUBY_RUBY_ENGINE "mruby"
/*
* Major release version number.
*/
#define MRUBY_RELEASE_MAJOR 2
/*
* Minor release version number.
*/
#define MRUBY_RELEASE_MINOR 1
/*
* Tiny release version number.
*/
#define MRUBY_RELEASE_TEENY 0
/*
* The mruby version.
*/
#define MRUBY_VERSION MRB_STRINGIZE(MRUBY_RELEASE_MAJOR) "." MRB_STRINGIZE(MRUBY_RELEASE_MINOR) "." MRB_STRINGIZE(MRUBY_RELEASE_TEENY)
/*
* Release number.
*/
#define MRUBY_RELEASE_NO (MRUBY_RELEASE_MAJOR * 100 * 100 + MRUBY_RELEASE_MINOR * 100 + MRUBY_RELEASE_TEENY)
/*
* Release year.
*/
#define MRUBY_RELEASE_YEAR 2019
/*
* Release month.
*/
#define MRUBY_RELEASE_MONTH 10
/*
* Release day.
*/
#define MRUBY_RELEASE_DAY 18
/*
* Release date as a string.
*/
#define MRUBY_RELEASE_DATE \
MRUBY_RELEASE_YEAR_STR "-" \
MRUBY_RELEASE_MONTH_STR "-" \
MRUBY_RELEASE_DAY_STR
#define MRUBY_RELEASE_YEAR_STR MRB_STRINGIZE(MRUBY_RELEASE_YEAR)
#if MRUBY_RELEASE_MONTH < 10
#define MRUBY_RELEASE_MONTH_STR "0" MRB_STRINGIZE(MRUBY_RELEASE_MONTH)
#else
#define MRUBY_RELEASE_MONTH_STR MRB_STRINGIZE(MRUBY_RELEASE_MONTH)
#endif
#if MRUBY_RELEASE_DAY < 10
#define MRUBY_RELEASE_DAY_STR "0" MRB_STRINGIZE(MRUBY_RELEASE_DAY)
#else
#define MRUBY_RELEASE_DAY_STR MRB_STRINGIZE(MRUBY_RELEASE_DAY)
#endif
/*
* The year mruby was first created.
*/
#define MRUBY_BIRTH_YEAR 2010
/*
* MRuby's authors.
*/
#define MRUBY_AUTHOR "mruby developers"
/*
* mruby's version, and release date.
*/
#define MRUBY_DESCRIPTION \
"mruby " MRUBY_VERSION \
" (" MRUBY_RELEASE_DATE ")" \
/*
* mruby's copyright information.
*/
#define MRUBY_COPYRIGHT \
"mruby - Copyright (c) " \
MRB_STRINGIZE(MRUBY_BIRTH_YEAR)"-" \
MRB_STRINGIZE(MRUBY_RELEASE_YEAR)" " \
MRUBY_AUTHOR \
MRB_END_DECL
#endif /* MRUBY_VERSION_H */
+2 -24
View File
@@ -1,3 +1,5 @@
autoload :Pathname, 'pathname'
class Object
class << self
def attr_block(*syms)
@@ -16,30 +18,6 @@ class String
def relative_path
relative_path_from(Dir.pwd)
end
# Compatible with 1.9 on 1.8
def %(params)
if params.is_a?(Hash)
str = self.clone
params.each do |k, v|
str.gsub!("%{#{k}}", v)
end
str
else
if params.is_a?(Array)
sprintf(self, *params)
else
sprintf(self, params)
end
end
end
end
class Symbol
# Compatible with 1.9 on 1.8
def to_proc
proc { |obj, *args| obj.send(self, *args) }
end
end
$pp_show = true
+420
View File
@@ -0,0 +1,420 @@
require "mruby-core-ext"
require "mruby/build/load_gems"
require "mruby/build/command"
module MRuby
autoload :Gem, "mruby/gem"
autoload :Lockfile, "mruby/lockfile"
class << self
def targets
@targets ||= {}
end
def each_target(&block)
return to_enum(:each_target) if block.nil?
@targets.each do |key, target|
target.instance_eval(&block)
end
end
end
class Toolchain
class << self
attr_accessor :toolchains
end
def initialize(name, &block)
@name, @initializer = name.to_s, block
MRuby::Toolchain.toolchains[@name] = self
end
def setup(conf,params={})
conf.instance_exec(conf, params, &@initializer)
end
self.toolchains = {}
end
class Build
class << self
attr_accessor :current
end
include Rake::DSL
include LoadGems
attr_accessor :name, :bins, :exts, :file_separator, :build_dir, :gem_clone_dir
attr_reader :libmruby_objs, :gems, :toolchains, :gem_dir_to_repo_url
attr_writer :enable_bintest, :enable_test
alias libmruby libmruby_objs
COMPILERS = %w(cc cxx objc asm)
COMMANDS = COMPILERS + %w(linker archiver yacc gperf git exts mrbc)
attr_block MRuby::Build::COMMANDS
Exts = Struct.new(:object, :executable, :library)
def initialize(name='host', build_dir=nil, &block)
@name = name.to_s
unless MRuby.targets[@name]
if ENV['OS'] == 'Windows_NT'
@exts = Exts.new('.o', '.exe', '.a')
else
@exts = Exts.new('.o', '', '.a')
end
build_dir = build_dir || ENV['MRUBY_BUILD_DIR'] || "#{MRUBY_ROOT}/build"
@file_separator = '/'
@build_dir = "#{build_dir}/#{@name}"
@gem_clone_dir = "#{build_dir}/repos/#{@name}"
@cc = Command::Compiler.new(self, %w(.c))
@cxx = Command::Compiler.new(self, %w(.cc .cxx .cpp))
@objc = Command::Compiler.new(self, %w(.m))
@asm = Command::Compiler.new(self, %w(.S .asm))
@linker = Command::Linker.new(self)
@archiver = Command::Archiver.new(self)
@yacc = Command::Yacc.new(self)
@gperf = Command::Gperf.new(self)
@git = Command::Git.new(self)
@mrbc = Command::Mrbc.new(self)
@bins = []
@gems, @libmruby_objs = MRuby::Gem::List.new, []
@build_mrbtest_lib_only = false
@cxx_exception_enabled = false
@cxx_exception_disabled = false
@cxx_abi_enabled = false
@enable_bintest = false
@enable_test = false
@enable_lock = true
@toolchains = []
@gem_dir_to_repo_url = {}
MRuby.targets[@name] = self
end
MRuby::Build.current = MRuby.targets[@name]
MRuby.targets[@name].instance_eval(&block)
build_mrbc_exec if name == 'host'
build_mrbtest if test_enabled?
end
def debug_enabled?
@enable_debug
end
def enable_debug
compilers.each do |c|
c.defines += %w(MRB_DEBUG)
if toolchains.any? { |toolchain| toolchain == "gcc" }
c.flags += %w(-g3 -O0)
end
end
@mrbc.compile_options += ' -g'
@enable_debug = true
end
def disable_lock
@enable_lock = false
end
def lock_enabled?
Lockfile.enabled? && @enable_lock
end
def disable_cxx_exception
if @cxx_exception_enabled or @cxx_abi_enabled
raise "cxx_exception already enabled"
end
@cxx_exception_disabled = true
end
def enable_cxx_exception
return if @cxx_exception_enabled
return if @cxx_abi_enabled
if @cxx_exception_disabled
raise "cxx_exception disabled"
end
@cxx_exception_enabled = true
compilers.each { |c|
c.defines += %w(MRB_ENABLE_CXX_EXCEPTION)
c.flags << c.cxx_exception_flag
}
linker.command = cxx.command if toolchains.find { |v| v == 'gcc' }
end
def cxx_exception_enabled?
@cxx_exception_enabled
end
def cxx_abi_enabled?
@cxx_abi_enabled
end
def enable_cxx_abi
return if @cxx_abi_enabled
if @cxx_exception_enabled
raise "cxx_exception already enabled"
end
compilers.each { |c|
c.defines += %w(MRB_ENABLE_CXX_EXCEPTION MRB_ENABLE_CXX_ABI)
c.flags << c.cxx_compile_flag
c.flags = c.flags.flatten - c.cxx_invalid_flags.flatten
}
linker.command = cxx.command if toolchains.find { |v| v == 'gcc' }
@cxx_abi_enabled = true
end
def compile_as_cxx src, cxx_src, obj = nil, includes = []
obj = objfile(cxx_src) if obj.nil?
file cxx_src => [src, __FILE__] do |t|
FileUtils.mkdir_p File.dirname t.name
IO.write t.name, <<EOS
#define __STDC_CONSTANT_MACROS
#define __STDC_LIMIT_MACROS
#ifndef MRB_ENABLE_CXX_ABI
extern "C" {
#endif
#include "#{File.absolute_path src}"
#ifndef MRB_ENABLE_CXX_ABI
}
#endif
EOS
end
file obj => cxx_src do |t|
cxx.run t.name, t.prerequisites.first, [], ["#{MRUBY_ROOT}/src"] + includes
end
obj
end
def enable_bintest
@enable_bintest = true
end
def bintest_enabled?
@enable_bintest
end
def toolchain(name, params={})
name = name.to_s
tc = Toolchain.toolchains[name] || begin
path = "#{MRUBY_ROOT}/tasks/toolchains/#{name}.rake"
fail "Unknown #{name} toolchain" unless File.exist?(path)
load path
Toolchain.toolchains[name]
end
tc.setup(self, params)
@toolchains.unshift name
end
def primary_toolchain
@toolchains.first
end
def root
MRUBY_ROOT
end
def enable_test
@enable_test = true
end
def test_enabled?
@enable_test
end
def build_mrbtest
gem :core => 'mruby-test'
end
def build_mrbc_exec
gem :core => 'mruby-bin-mrbc'
end
def locks
Lockfile.build(@name)
end
def mrbcfile
return @mrbcfile if @mrbcfile
mrbc_build = MRuby.targets['host']
gems.each { |v| mrbc_build = self if v.name == 'mruby-bin-mrbc' }
@mrbcfile = mrbc_build.exefile("#{mrbc_build.build_dir}/bin/mrbc")
end
def compilers
COMPILERS.map do |c|
instance_variable_get("@#{c}")
end
end
def define_rules
compilers.each do |compiler|
if respond_to?(:enable_gems?) && enable_gems?
compiler.defines -= %w(DISABLE_GEMS)
else
compiler.defines += %w(DISABLE_GEMS)
end
compiler.define_rules build_dir, File.expand_path(File.join(File.dirname(__FILE__), '..', '..'))
end
end
def filename(name)
if name.is_a?(Array)
name.flatten.map { |n| filename(n) }
else
name.gsub('/', file_separator)
end
end
def cygwin_filename(name)
if name.is_a?(Array)
name.flatten.map { |n| cygwin_filename(n) }
else
`cygpath -w "#{filename(name)}"`.strip
end
end
def exefile(name)
if name.is_a?(Array)
name.flatten.map { |n| exefile(n) }
elsif File.extname(name).empty?
"#{name}#{exts.executable}"
else
# `name` sometimes have (non-standard) extension (e.g. `.bat`).
name
end
end
def objfile(name)
if name.is_a?(Array)
name.flatten.map { |n| objfile(n) }
else
"#{name}#{exts.object}"
end
end
def libfile(name)
if name.is_a?(Array)
name.flatten.map { |n| libfile(n) }
else
"#{name}#{exts.library}"
end
end
def build_mrbtest_lib_only
@build_mrbtest_lib_only = true
end
def build_mrbtest_lib_only?
@build_mrbtest_lib_only
end
def verbose_flag
$verbose ? ' -v' : ''
end
def run_test
puts ">>> Test #{name} <<<"
mrbtest = exefile("#{build_dir}/bin/mrbtest")
sh "#{filename mrbtest.relative_path}#{verbose_flag}"
puts
end
def run_bintest
puts ">>> Bintest #{name} <<<"
targets = @gems.select { |v| File.directory? "#{v.dir}/bintest" }.map { |v| filename v.dir }
targets << filename(".") if File.directory? "./bintest"
sh "ruby test/bintest.rb#{verbose_flag} #{targets.join ' '}"
end
def print_build_summary
puts "================================================"
puts " Config Name: #{@name}"
puts " Output Directory: #{self.build_dir.relative_path}"
puts " Binaries: #{@bins.join(', ')}" unless @bins.empty?
unless @gems.empty?
puts " Included Gems:"
@gems.map do |gem|
gem_version = " - #{gem.version}" if gem.version != '0.0.0'
gem_summary = " - #{gem.summary}" if gem.summary
puts " #{gem.name}#{gem_version}#{gem_summary}"
puts " - Binaries: #{gem.bins.join(', ')}" unless gem.bins.empty?
end
end
puts "================================================"
puts
end
def libmruby_static
libfile("#{build_dir}/lib/libmruby")
end
def libmruby_core_static
libfile("#{build_dir}/lib/libmruby_core")
end
def libraries
[libmruby_static]
end
end # Build
class CrossBuild < Build
attr_block %w(test_runner)
# cross compiling targets for building native extensions.
# host - arch of where the built binary will run
# build - arch of the machine building the binary
attr_accessor :host_target, :build_target
def initialize(name, build_dir=nil, &block)
@endian = nil
@test_runner = Command::CrossTestRunner.new(self)
super
end
def mrbcfile
MRuby.targets['host'].exefile("#{MRuby.targets['host'].build_dir}/bin/mrbc")
end
def run_test
@test_runner.runner_options << ' -v' if $verbose
mrbtest = exefile("#{build_dir}/bin/mrbtest")
if (@test_runner.command == nil)
puts "You should run #{mrbtest} on target device."
puts
else
@test_runner.run(mrbtest)
end
end
def big_endian
if @endian
puts "Endian has already specified as #{@endian}."
return
end
@endian = :big
@mrbc.compile_options += ' -E'
compilers.each do |c|
c.defines += %w(MRB_ENDIAN_BIG)
end
end
def little_endian
if @endian
puts "Endian has already specified as #{@endian}."
return
end
@endian = :little
@mrbc.compile_options += ' -e'
end
end # CrossBuild
end # MRuby
@@ -24,15 +24,24 @@ module MRuby
target
end
NotFoundCommands = {}
private
def _run(options, params={})
sh build.filename(command) + ' ' + ( options % params )
return sh command + ' ' + ( options % params ) if NotFoundCommands.key? @command
begin
sh build.filename(command) + ' ' + ( options % params )
rescue RuntimeError
NotFoundCommands[@command] = true
_run options, params
end
end
end
class Command::Compiler < Command
attr_accessor :flags, :include_paths, :defines, :source_exts
attr_accessor :compile_options, :option_define, :option_include_path, :out_ext
attr_accessor :cxx_compile_flag, :cxx_exception_flag, :cxx_invalid_flags
def initialize(build, source_exts=[])
super(build)
@@ -44,10 +53,23 @@ module MRuby
@option_include_path = '-I%s'
@option_define = '-D%s'
@compile_options = '%{flags} -o %{outfile} -c %{infile}'
@cxx_invalid_flags = []
end
def all_flags(_defineds=[], _include_paths=[], _flags=[])
define_flags = [defines, _defineds].flatten.map{ |d| option_define % d }
alias header_search_paths include_paths
def search_header_path(name)
header_search_paths.find do |v|
File.exist? build.filename("#{v}/#{name}").sub(/^"(.*)"$/, '\1')
end
end
def search_header(name)
path = search_header_path name
path && build.filename("#{path}/#{name}").sub(/^"(.*)"$/, '\1')
end
def all_flags(_defines=[], _include_paths=[], _flags=[])
define_flags = [defines, _defines].flatten.map{ |d| option_define % d }
include_path_flags = [include_paths, _include_paths].flatten.map do |f|
if MRUBY_BUILD_HOST_IS_CYGWIN
option_include_path % cygwin_filename(f)
@@ -58,20 +80,22 @@ module MRuby
[flags, define_flags, include_path_flags, _flags].flatten.join(' ')
end
def run(outfile, infile, _defineds=[], _include_paths=[], _flags=[])
def run(outfile, infile, _defines=[], _include_paths=[], _flags=[])
FileUtils.mkdir_p File.dirname(outfile)
_pp "CC", infile.relative_path, outfile.relative_path
if MRUBY_BUILD_HOST_IS_CYGWIN
_run compile_options, { :flags => all_flags(_defineds, _include_paths, _flags),
_run compile_options, { :flags => all_flags(_defines, _include_paths, _flags),
:infile => cygwin_filename(infile), :outfile => cygwin_filename(outfile) }
else
_run compile_options, { :flags => all_flags(_defineds, _include_paths, _flags),
_run compile_options, { :flags => all_flags(_defines, _include_paths, _flags),
:infile => filename(infile), :outfile => filename(outfile) }
end
end
def define_rules(build_dir, source_dir='')
@out_ext = build.exts.object
gemrake = File.join(source_dir, "mrbgem.rake")
rakedep = File.exist?(gemrake) ? [ gemrake ] : []
if build_dir.include? "mrbgems/"
generated_file_matcher = Regexp.new("^#{Regexp.escape build_dir}/(.*)#{Regexp.escape out_ext}$")
@@ -84,7 +108,7 @@ module MRuby
file.sub(generated_file_matcher, "#{source_dir}/\\1#{ext}")
},
proc { |file|
get_dependencies(file)
get_dependencies(file) + rakedep
}
] do |t|
run t.name, t.prerequisites.first
@@ -95,7 +119,7 @@ module MRuby
file.sub(generated_file_matcher, "#{build_dir}/\\1#{ext}")
},
proc { |file|
get_dependencies(file)
get_dependencies(file) + rakedep
}
] do |t|
run t.name, t.prerequisites.first
@@ -104,13 +128,40 @@ module MRuby
end
private
#
# === Example of +.d+ file
#
# ==== Without <tt>-MP</tt> compiler flag
#
# /build/host/src/array.o: \
# /src/array.c \
# /include/mruby/common.h \
# /include/mruby/value.h \
# /src/value_array.h
#
# ==== With <tt>-MP</tt> compiler flag
#
# /build/host/src/array.o: \
# /src/array.c \
# /include/mruby/common.h \
# /include/mruby/value.h \
# /src/value_array.h
#
# /include/mruby/common.h:
#
# /include/mruby/value.h:
#
# /src/value_array.h:
#
def get_dependencies(file)
file = file.ext('d') unless File.extname(file) == '.d'
deps = []
if File.exist?(file)
File.read(file).gsub("\\\n ", "").scan(/^\S+:\s+(.+)$/).flatten.map {|s| s.split(' ') }.flatten
else
[]
File.foreach(file){|line| deps << $1 if /^ +(.*?)(?: *\\)?$/ =~ line}
deps.uniq!
end
deps << MRUBY_CONFIG
end
end
@@ -220,14 +271,16 @@ module MRuby
class Command::Git < Command
attr_accessor :flags
attr_accessor :clone_options, :pull_options
attr_accessor :clone_options, :pull_options, :checkout_options, :reset_options
def initialize(build)
super
@command = 'git'
@flags = []
@flags = %w[]
@clone_options = "clone %{flags} %{url} %{dir}"
@pull_options = "pull"
@pull_options = "--git-dir '%{repo_dir}/.git' --work-tree '%{repo_dir}' pull"
@checkout_options = "--git-dir '%{repo_dir}/.git' --work-tree '%{repo_dir}' checkout %{checksum_hash}"
@reset_options = "--git-dir '%{repo_dir}/.git' --work-tree '%{repo_dir}' reset %{checksum_hash}"
end
def run_clone(dir, url, _flags = [])
@@ -236,11 +289,26 @@ module MRuby
end
def run_pull(dir, url)
root = Dir.pwd
Dir.chdir dir
_pp "GIT PULL", url, dir.relative_path
_run pull_options
Dir.chdir root
_run pull_options, { :repo_dir => dir }
end
def run_checkout(dir, checksum_hash)
_pp "GIT CHECKOUT", checksum_hash
_run checkout_options, { :checksum_hash => checksum_hash, :repo_dir => dir }
end
def run_reset_hard(dir, checksum_hash)
_pp "GIT RESET", checksum_hash
_run reset_options, { :checksum_hash => checksum_hash, :repo_dir => dir }
end
def commit_hash(dir)
`#{@command} --git-dir '#{dir}/.git' --work-tree '#{dir}' rev-parse --verify HEAD`.strip
end
def current_branch(dir)
`#{@command} --git-dir '#{dir}/.git' --work-tree '#{dir}' rev-parse --abbrev-ref HEAD`.strip
end
end
@@ -263,7 +331,7 @@ module MRuby
out.puts io.read
end
# if mrbc execution fail, drop the file
unless $?.exitstatus
if $?.exitstatus != 0
File.delete(out.path)
exit(-1)
end
+139
View File
@@ -0,0 +1,139 @@
module MRuby
module LoadGems
def gembox(gemboxfile)
gembox = File.expand_path("#{gemboxfile}.gembox", "#{MRUBY_ROOT}/mrbgems")
fail "Can't find gembox '#{gembox}'" unless File.exist?(gembox)
GemBox.config = self
GemBox.path = gembox
instance_eval File.read(gembox)
GemBox.path = nil
end
def gem(gemdir, &block)
caller_dir = File.expand_path(File.dirname(/^(.*?):\d/.match(caller.first).to_a[1]))
if gemdir.is_a?(Hash)
gemdir = load_special_path_gem(gemdir)
elsif GemBox.path && gemdir.is_a?(String)
gemdir = File.expand_path(gemdir, File.dirname(GemBox.path))
else
gemdir = File.expand_path(gemdir, caller_dir)
end
gemrake = File.join(gemdir, "mrbgem.rake")
fail "Can't find #{gemrake}" unless File.exist?(gemrake)
Gem.current = nil
load gemrake
return nil unless Gem.current
Gem.current.dir = gemdir
Gem.current.build = self.is_a?(MRuby::Build) ? self : MRuby::Build.current
Gem.current.build_config_initializer = block
gems << Gem.current
cxx_srcs = ['src', 'test', 'tools'].map do |subdir|
Dir.glob("#{Gem.current.dir}/#{subdir}/*.{cpp,cxx,cc}")
end.flatten
enable_cxx_exception unless cxx_srcs.empty?
Gem.current
end
def load_special_path_gem(params)
if params[:github]
params[:git] = "https://github.com/#{params[:github]}.git"
elsif params[:bitbucket]
if params[:method] == "ssh"
params[:git] = "git@bitbucket.org:#{params[:bitbucket]}.git"
else
params[:git] = "https://bitbucket.org/#{params[:bitbucket]}.git"
end
elsif params[:mgem]
mgem_list_dir = "#{gem_clone_dir}/mgem-list"
mgem_list_url = 'https://github.com/mruby/mgem-list.git'
if File.exist? mgem_list_dir
git.run_pull mgem_list_dir, mgem_list_url if $pull_gems
else
FileUtils.mkdir_p mgem_list_dir
git.run_clone mgem_list_dir, mgem_list_url, "--depth 1"
end
require 'yaml'
conf_path = "#{mgem_list_dir}/#{params[:mgem]}.gem"
conf_path = "#{mgem_list_dir}/mruby-#{params[:mgem]}.gem" unless File.exist? conf_path
fail "mgem not found: #{params[:mgem]}" unless File.exist? conf_path
conf = YAML.load File.read conf_path
fail "unknown mgem protocol: #{conf['protocol']}" if conf['protocol'] != 'git'
params[:git] = conf['repository']
params[:branch] = conf['branch'] if conf['branch']
end
if params[:core]
gemdir = "#{root}/mrbgems/#{params[:core]}"
elsif params[:git]
url = params[:git]
gemdir = "#{gem_clone_dir}/#{url.match(/([-\w]+)(\.[-\w]+|)$/).to_a[1]}"
# by default the 'master' branch is used
branch = params[:branch] ? params[:branch] : 'master'
lock = locks[url] if lock_enabled?
if File.exist?(gemdir)
if $pull_gems
git.run_pull gemdir, url
# Jump to the top of the branch
git.run_checkout(gemdir, branch)
git.run_reset_hard gemdir, "origin/#{branch}"
elsif params[:checksum_hash]
git.run_reset_hard(gemdir, params[:checksum_hash])
elsif lock
git.run_reset_hard(gemdir, lock['commit'])
end
else
options = [params[:options]] || []
options << "--recursive"
options << "--branch \"#{branch}\""
options << "--depth 1" unless params[:checksum_hash]
FileUtils.mkdir_p "#{gem_clone_dir}"
git.run_clone gemdir, url, options
# Jump to the specified commit
if params[:checksum_hash]
git.run_reset_hard gemdir, params[:checksum_hash]
elsif lock
git.run_reset_hard gemdir, lock['commit']
end
end
if lock_enabled?
@gem_dir_to_repo_url[gemdir] = url unless params[:path]
locks[url] = {
'url' => url,
'branch' => git.current_branch(gemdir),
'commit' => git.commit_hash(gemdir),
}
end
gemdir << "/#{params[:path]}" if params[:path]
elsif params[:path]
require 'pathname'
gemdir = Pathname.new(params[:path]).absolute? ? params[:path] : "#{root}/#{params[:path]}"
else
fail "unknown gem option #{params}"
end
gemdir
end
def enable_gems?
!@gems.empty?
end
end # LoadGems
end # MRuby
+462
View File
@@ -0,0 +1,462 @@
require 'forwardable'
autoload :TSort, 'tsort'
autoload :Shellwords, 'shellwords'
module MRuby
module Gem
class << self
attr_accessor :current
end
LinkerConfig = Struct.new(:libraries, :library_paths, :flags, :flags_before_libraries, :flags_after_libraries)
class Specification
include Rake::DSL
extend Forwardable
def_delegators :@build, :filename, :objfile, :libfile, :exefile
attr_accessor :name, :dir, :build
alias mruby build
attr_accessor :build_config_initializer
attr_accessor :mrblib_dir, :objs_dir
attr_accessor :version
attr_accessor :description, :summary
attr_accessor :homepage
attr_accessor :licenses, :authors
alias :license= :licenses=
alias :author= :authors=
attr_accessor :rbfiles, :objs
attr_accessor :test_objs, :test_rbfiles, :test_args
attr_accessor :test_preload
attr_accessor :bins
attr_accessor :requirements
attr_reader :dependencies, :conflicts
attr_accessor :export_include_paths
attr_reader :generate_functions
attr_block MRuby::Build::COMMANDS
def initialize(name, &block)
@name = name
@initializer = block
@version = "0.0.0"
@mrblib_dir = "mrblib"
@objs_dir = "src"
MRuby::Gem.current = self
end
def setup
return if defined?(@linker) # return if already set up
MRuby::Gem.current = self
MRuby::Build::COMMANDS.each do |command|
instance_variable_set("@#{command}", @build.send(command).clone)
end
@linker = LinkerConfig.new([], [], [], [], [])
@rbfiles = Dir.glob("#{@dir}/#{@mrblib_dir}/**/*.rb").sort
@objs = Dir.glob("#{@dir}/#{@objs_dir}/*.{c,cpp,cxx,cc,m,asm,s,S}").map do |f|
objfile(f.relative_path_from(@dir).to_s.pathmap("#{build_dir}/%X"))
end
@test_rbfiles = Dir.glob("#{dir}/test/**/*.rb").sort
@test_objs = Dir.glob("#{dir}/test/*.{c,cpp,cxx,cc,m,asm,s,S}").map do |f|
objfile(f.relative_path_from(dir).to_s.pathmap("#{build_dir}/%X"))
end
@custom_test_init = !@test_objs.empty?
@test_preload = nil # 'test/assert.rb'
@test_args = {}
@bins = []
@requirements = []
@dependencies, @conflicts = [], []
@export_include_paths = []
@export_include_paths << "#{dir}/include" if File.directory? "#{dir}/include"
instance_eval(&@initializer)
@generate_functions = !(@rbfiles.empty? && @objs.empty?)
@objs << objfile("#{build_dir}/gem_init") if @generate_functions
if !name || !licenses || !authors
fail "#{name || dir} required to set name, license(s) and author(s)"
end
build.libmruby_objs << @objs
instance_eval(&@build_config_initializer) if @build_config_initializer
repo_url = build.gem_dir_to_repo_url[dir]
build.locks[repo_url]['version'] = version if repo_url
end
def setup_compilers
compilers.each do |compiler|
compiler.define_rules build_dir, "#{dir}"
compiler.defines << %Q[MRBGEM_#{funcname.upcase}_VERSION=#{version}]
compiler.include_paths << "#{dir}/include" if File.directory? "#{dir}/include"
end
define_gem_init_builder if @generate_functions
end
def add_dependency(name, *requirements)
default_gem = requirements.last.kind_of?(Hash) ? requirements.pop : nil
requirements = ['>= 0.0.0'] if requirements.empty?
requirements.flatten!
@dependencies << {:gem => name, :requirements => requirements, :default => default_gem}
end
def add_test_dependency(*args)
add_dependency(*args) if build.test_enabled? || build.bintest_enabled?
end
def add_conflict(name, *req)
@conflicts << {:gem => name, :requirements => req.empty? ? nil : req}
end
def build_dir
"#{build.build_dir}/mrbgems/#{name}"
end
def test_rbireps
"#{build_dir}/gem_test.c"
end
def search_package(name, version_query=nil)
package_query = name
package_query += " #{version_query}" if version_query
_pp "PKG-CONFIG", package_query
escaped_package_query = Shellwords.escape(package_query)
if system("pkg-config --exists #{escaped_package_query}")
cc.flags += [`pkg-config --cflags #{escaped_package_query}`.strip]
cxx.flags += [`pkg-config --cflags #{escaped_package_query}`.strip]
linker.flags_before_libraries += [`pkg-config --libs #{escaped_package_query}`.strip]
true
else
false
end
end
def funcname
@funcname ||= @name.gsub('-', '_')
end
def compilers
MRuby::Build::COMPILERS.map do |c|
instance_variable_get("@#{c}")
end
end
def define_gem_init_builder
file objfile("#{build_dir}/gem_init") => [ "#{build_dir}/gem_init.c", File.join(dir, "mrbgem.rake") ]
file "#{build_dir}/gem_init.c" => [build.mrbcfile, __FILE__] + [rbfiles].flatten do |t|
FileUtils.mkdir_p build_dir
generate_gem_init("#{build_dir}/gem_init.c")
end
end
def generate_gem_init(fname)
open(fname, 'w') do |f|
print_gem_init_header f
build.mrbc.run f, rbfiles, "gem_mrblib_irep_#{funcname}" unless rbfiles.empty?
f.puts %Q[void mrb_#{funcname}_gem_init(mrb_state *mrb);]
f.puts %Q[void mrb_#{funcname}_gem_final(mrb_state *mrb);]
f.puts %Q[]
f.puts %Q[void GENERATED_TMP_mrb_#{funcname}_gem_init(mrb_state *mrb) {]
f.puts %Q[ int ai = mrb_gc_arena_save(mrb);]
f.puts %Q[ mrb_#{funcname}_gem_init(mrb);] if objs != [objfile("#{build_dir}/gem_init")]
unless rbfiles.empty?
f.puts %Q[ mrb_load_irep(mrb, gem_mrblib_irep_#{funcname});]
f.puts %Q[ if (mrb->exc) {]
f.puts %Q[ mrb_print_error(mrb);]
f.puts %Q[ mrb_close(mrb);]
f.puts %Q[ exit(EXIT_FAILURE);]
f.puts %Q[ }]
end
f.puts %Q[ mrb_gc_arena_restore(mrb, ai);]
f.puts %Q[}]
f.puts %Q[]
f.puts %Q[void GENERATED_TMP_mrb_#{funcname}_gem_final(mrb_state *mrb) {]
f.puts %Q[ mrb_#{funcname}_gem_final(mrb);] if objs != [objfile("#{build_dir}/gem_init")]
f.puts %Q[}]
end
end # generate_gem_init
def print_gem_comment(f)
f.puts %Q[/*]
f.puts %Q[ * This file is loading the irep]
f.puts %Q[ * Ruby GEM code.]
f.puts %Q[ *]
f.puts %Q[ * IMPORTANT:]
f.puts %Q[ * This file was generated!]
f.puts %Q[ * All manual changes will get lost.]
f.puts %Q[ */]
end
def print_gem_init_header(f)
print_gem_comment(f)
f.puts %Q[#include <stdlib.h>] unless rbfiles.empty?
f.puts %Q[#include <mruby.h>]
f.puts %Q[#include <mruby/irep.h>] unless rbfiles.empty?
end
def print_gem_test_header(f)
print_gem_comment(f)
f.puts %Q[#include <stdio.h>]
f.puts %Q[#include <stdlib.h>]
f.puts %Q[#include <mruby.h>]
f.puts %Q[#include <mruby/irep.h>]
f.puts %Q[#include <mruby/variable.h>]
f.puts %Q[#include <mruby/hash.h>] unless test_args.empty?
end
def test_dependencies
[@name]
end
def custom_test_init?
@custom_test_init
end
def version_ok?(req_versions)
req_versions.map do |req|
cmp, ver = req.split
cmp_result = Version.new(version) <=> Version.new(ver)
case cmp
when '=' then cmp_result == 0
when '!=' then cmp_result != 0
when '>' then cmp_result == 1
when '<' then cmp_result == -1
when '>=' then cmp_result >= 0
when '<=' then cmp_result <= 0
when '~>'
Version.new(version).twiddle_wakka_ok?(Version.new(ver))
else
fail "Comparison not possible with '#{cmp}'"
end
end.all?
end
end # Specification
class Version
include Comparable
include Enumerable
def <=>(other)
ret = 0
own = to_enum
other.each do |oth|
begin
ret = own.next <=> oth
rescue StopIteration
ret = 0 <=> oth
end
break unless ret == 0
end
ret
end
# ~> compare algorithm
#
# Example:
# ~> 2 means >= 2.0.0 and < 3.0.0
# ~> 2.2 means >= 2.2.0 and < 3.0.0
# ~> 2.2.2 means >= 2.2.2 and < 2.3.0
def twiddle_wakka_ok?(other)
gr_or_eql = (self <=> other) >= 0
still_major_or_minor = (self <=> other.skip_major_or_minor) < 0
gr_or_eql and still_major_or_minor
end
def skip_major_or_minor
a = @ary.dup
a << 0 if a.size == 1 # ~> 2 can also be represented as ~> 2.0
a.slice!(-1)
a[-1] = a[-1].succ
a
end
def initialize(str)
@str = str
@ary = @str.split('.').map(&:to_i)
end
def each(&block); @ary.each(&block); end
def [](index); @ary[index]; end
def []=(index, value)
@ary[index] = value
@str = @ary.join('.')
end
def slice!(index)
@ary.slice!(index)
@str = @ary.join('.')
end
end # Version
class List
include Enumerable
def initialize
@ary = []
end
def each(&b)
@ary.each(&b)
end
def <<(gem)
unless @ary.detect {|g| g.dir == gem.dir }
@ary << gem
else
# GEM was already added to this list
end
end
def empty?
@ary.empty?
end
def default_gem_params dep
if dep[:default]; dep
elsif File.exist? "#{MRUBY_ROOT}/mrbgems/#{dep[:gem]}" # check core
{ :gem => dep[:gem], :default => { :core => dep[:gem] } }
else # fallback to mgem-list
{ :gem => dep[:gem], :default => { :mgem => dep[:gem] } }
end
end
def generate_gem_table build
gem_table = each_with_object({}) { |spec, h| h[spec.name] = spec }
default_gems = {}
each do |g|
g.dependencies.each do |dep|
default_gems[dep[:gem]] ||= default_gem_params(dep)
end
end
until default_gems.empty?
def_name, def_gem = default_gems.shift
next if gem_table[def_name]
spec = gem_table[def_name] = build.gem(def_gem[:default])
fail "Invalid gem name: #{spec.name} (Expected: #{def_name})" if spec.name != def_name
spec.setup
spec.dependencies.each do |dep|
default_gems[dep[:gem]] ||= default_gem_params(dep)
end
end
each do |g|
g.dependencies.each do |dep|
name = dep[:gem]
req_versions = dep[:requirements]
dep_g = gem_table[name]
# check each GEM dependency against all available GEMs
if dep_g.nil?
fail "The GEM '#{g.name}' depends on the GEM '#{name}' but it could not be found"
end
unless dep_g.version_ok? req_versions
fail "#{name} version should be #{req_versions.join(' and ')} but was '#{dep_g.version}'"
end
end
cfls = g.conflicts.select { |c|
cfl_g = gem_table[c[:gem]]
cfl_g and cfl_g.version_ok?(c[:requirements] || ['>= 0.0.0'])
}.map { |c| "#{c[:gem]}(#{gem_table[c[:gem]].version})" }
fail "Conflicts of gem `#{g.name}` found: #{cfls.join ', '}" unless cfls.empty?
end
gem_table
end
def tsort_dependencies ary, table, all_dependency_listed = false
unless all_dependency_listed
left = ary.dup
until left.empty?
v = left.pop
table[v].dependencies.each do |dep|
left.push dep[:gem]
ary.push dep[:gem]
end
end
end
ary.uniq!
table.instance_variable_set :@root_gems, ary
class << table
include TSort
def tsort_each_node &b
@root_gems.each &b
end
def tsort_each_child(n, &b)
fetch(n).dependencies.each do |v|
b.call v[:gem]
end
end
end
begin
table.tsort.map { |v| table[v] }
rescue TSort::Cyclic => e
fail "Circular mrbgem dependency found: #{e.message}"
end
end
def check(build)
gem_table = generate_gem_table build
@ary = tsort_dependencies gem_table.keys, gem_table, true
each(&:setup_compilers)
each do |g|
import_include_paths(g)
end
end
def import_include_paths(g)
gem_table = each_with_object({}) { |spec, h| h[spec.name] = spec }
g.dependencies.each do |dep|
dep_g = gem_table[dep[:gem]]
# We can do recursive call safely
# as circular dependency has already detected in the caller.
import_include_paths(dep_g)
dep_g.export_include_paths.uniq!
g.compilers.each do |compiler|
compiler.include_paths += dep_g.export_include_paths
g.export_include_paths += dep_g.export_include_paths
compiler.include_paths.uniq!
g.export_include_paths.uniq!
end
end
end
end # List
end # Gem
GemBox = Object.new
class << GemBox
attr_accessor :path
def new(&block); block.call(self); end
def config=(obj); @config = obj; end
def gem(gemdir, &block); @config.gem(gemdir, &block); end
def gembox(gemfile); @config.gembox(gemfile); end
end # GemBox
end # MRuby
+73
View File
@@ -0,0 +1,73 @@
autoload :YAML, 'yaml'
module MRuby
autoload :Source, 'mruby/source'
class Lockfile
class << self
def enable
@enabled = true
end
def disable
@enabled = false
end
def enabled?
@enabled
end
def build(target_name)
instance.build(target_name)
end
def write
instance.write if enabled?
end
def instance
@instance ||= new("#{MRUBY_CONFIG}.lock")
end
end
def initialize(filename)
@filename = filename
end
def build(target_name)
read[target_name] ||= {}
end
def write
locks = {"mruby_version" => mruby}
locks["builds"] = @builds if @builds
File.write(@filename, YAML.dump(locks))
end
private
def read
@builds ||= if File.exist?(@filename)
YAML.load_file(@filename)["builds"] || {}
else
{}
end
end
def mruby
mruby = {
'version' => MRuby::Source::MRUBY_VERSION,
'release_no' => MRuby::Source::MRUBY_RELEASE_NO,
}
git_dir = "#{MRUBY_ROOT}/.git"
if File.directory?(git_dir)
mruby['git_commit'] = `git --git-dir '#{git_dir}' --work-tree '#{MRUBY_ROOT}' rev-parse --verify HEAD`.strip
end
mruby
end
enable
end
end
+30
View File
@@ -0,0 +1,30 @@
require "pathname"
module MRuby
module Source
# MRuby's source root directory
ROOT = Pathname.new(File.expand_path('../../../',__FILE__))
# Reads a constant defined at version.h
MRUBY_READ_VERSION_CONSTANT = Proc.new { |name| ROOT.join('include','mruby','version.h').read.match(/^#define #{name} +"?([\w\. ]+)"?$/)[1] }
MRUBY_RUBY_VERSION = MRUBY_READ_VERSION_CONSTANT['MRUBY_RUBY_VERSION']
MRUBY_RUBY_ENGINE = MRUBY_READ_VERSION_CONSTANT['MRUBY_RUBY_ENGINE']
MRUBY_RELEASE_MAJOR = Integer(MRUBY_READ_VERSION_CONSTANT['MRUBY_RELEASE_MAJOR'])
MRUBY_RELEASE_MINOR = Integer(MRUBY_READ_VERSION_CONSTANT['MRUBY_RELEASE_MINOR'])
MRUBY_RELEASE_TEENY = Integer(MRUBY_READ_VERSION_CONSTANT['MRUBY_RELEASE_TEENY'])
MRUBY_VERSION = [MRUBY_RELEASE_MAJOR,MRUBY_RELEASE_MINOR,MRUBY_RELEASE_TEENY].join('.')
MRUBY_RELEASE_NO = (MRUBY_RELEASE_MAJOR * 100 * 100 + MRUBY_RELEASE_MINOR * 100 + MRUBY_RELEASE_TEENY)
MRUBY_RELEASE_YEAR = Integer(MRUBY_READ_VERSION_CONSTANT['MRUBY_RELEASE_YEAR'])
MRUBY_RELEASE_MONTH = Integer(MRUBY_READ_VERSION_CONSTANT['MRUBY_RELEASE_MONTH'])
MRUBY_RELEASE_DAY = Integer(MRUBY_READ_VERSION_CONSTANT['MRUBY_RELEASE_DAY'])
MRUBY_RELEASE_DATE = [MRUBY_RELEASE_YEAR,MRUBY_RELEASE_MONTH,MRUBY_RELEASE_DAY].join('.')
MRUBY_BIRTH_YEAR = Integer(MRUBY_READ_VERSION_CONSTANT['MRUBY_BIRTH_YEAR'])
MRUBY_AUTHOR = MRUBY_READ_VERSION_CONSTANT['MRUBY_AUTHOR']
end
end
+180 -36
View File
@@ -7,6 +7,10 @@
require 'getoptlong'
require 'fileutils'
$rake_fiber_table = {}
$rake_jobs = 1
$rake_failed = []
class String
def ext(newext='')
return self.dup if ['.', '..'].include? self
@@ -86,14 +90,36 @@ module MiniRake
@name.to_s
end
# Invoke the task if it is needed. Prerequites are invoked first.
def done?; @done end
def running?; @running end
# Invoke the task if it is needed. Prerequisites are invoked first.
def invoke
puts "Invoke #{name} (already=[#{@already_invoked}], needed=[#{needed?}])" if $trace
return if @already_invoked
@already_invoked = true
prerequisites = @prerequisites.collect{ |n| n.is_a?(Proc) ? n.call(name) : n }.flatten
prerequisites.each { |n| Task[n].invoke }
execute if needed?
prerequisites.each do |n|
t = Task[n]
unless t.done?
return prerequisites.select{|v| v = Task[v]; v && (!v.done? || !v.running?) }
end
end
@already_invoked = true
if needed?
@running = true
if $rake_root_fiber
return Fiber.new do
self.execute
$rake_root_fiber.transfer
end
else
self.execute
end
end
@done = true
end
# Execute the actions associated with this task.
@@ -103,6 +129,8 @@ module MiniRake
unless $dryrun
@actions.each { |act| act.call(self) }
end
@done = true
@running = false
end
# Is this task needed?
@@ -113,8 +141,7 @@ module MiniRake
# Timestamp for this task. Basic tasks return the current time for
# their time stamp. Other tasks can be more sophisticated.
def timestamp
prerequisites = @prerequisites.collect{ |n| n.is_a?(Proc) ? n.call(name) : n }.flatten
prerequisites.collect { |n| Task[n].timestamp }.max || Time.now
Time.now
end
# Class Methods ----------------------------------------------------
@@ -179,25 +206,41 @@ module MiniRake
# task with the prerequisites and actions from the rule. Set the
# source attribute of the task appropriately for the rule. Return
# the enhanced task or nil of no rule was found.
def enhance_with_matching_rule(task_name)
def enhance_with_matching_rule(task_name, level=0)
fail "Rule Recursion Too Deep: #{task_name}" if level >= 16
RULES.each do |pattern, extensions, block|
if pattern.match(task_name)
ext = extensions.first
deps = extensions[1..-1]
next unless pattern && pattern.match(task_name)
sources = extensions.flat_map do |ext|
case ext
when /%/
task_name.pathmap(ext)
when %r{/}
ext
when /^\./
source = task_name.sub(pattern, ext)
source == ext ? task_name.ext(ext) : source
when String
source = task_name.sub(/\.[^.]*$/, ext)
when Proc
source = ext.call(task_name)
ext
when Proc, Method
ext.arity == 1 ? ext.call(task_name) : ext.call
else
fail "Don't know how to handle rule dependent: #{ext.inspect}"
end
if File.exist?(source)
task = FileTask.define_task({task_name => [source]+deps}, &block)
task.source = source
return task
end
prereqs = sources.map do |source|
if File.exist?(source) || TASKS[source]
source
elsif parent = enhance_with_matching_rule(source, level + 1)
parent.name
else
break nil
end
end
if prereqs
task = FileTask.define_task(task_name => prereqs, &block)
task.source = prereqs.first
return task
end
end
nil
end
@@ -237,7 +280,9 @@ module MiniRake
# Time stamp for file task.
def timestamp
File::stat(name.to_s).mtime
return Time.at(0) unless File.exist?(name)
stat = File::stat(name.to_s)
stat.directory? ? Time.at(0) : stat.mtime
end
end
@@ -254,12 +299,14 @@ module MiniRake
# Declare a set of files tasks to create the given directories on
# demand.
def directory(dir)
path = []
Sys.split_all(dir).each do |p|
path << p
FileTask.define_task(File.join(path)) do |t|
Sys.makedirs(t.name)
def directory(args, &block)
MiniRake::FileTask.define_task(args) do |t|
block.call(t) unless block.nil?
dir = args.is_a?(Hash) ? args.keys.first : args
(dir.split(File::SEPARATOR) + ['']).inject do |acc, part|
(acc + File::SEPARATOR).tap do |d|
Dir.mkdir(d) unless File.exists? d
end + part
end
end
end
@@ -278,7 +325,19 @@ module MiniRake
# Run the system command +cmd+.
def sh(cmd)
puts cmd if $verbose
system(cmd) or fail "Command Failed: [#{cmd}]"
if !$rake_root_fiber || Fiber.current == $rake_root_fiber
system(cmd) or fail "Command Failed: [#{cmd}]"
return
end
pid = Process.spawn(cmd)
$rake_fiber_table[pid] = {
fiber: Fiber.current,
command: cmd,
process_waiter: Process.detach(pid)
}
$rake_root_fiber.transfer
end
def desc(text)
@@ -310,7 +369,7 @@ class RakeApp
['--nosearch', '-N', GetoptLong::NO_ARGUMENT,
"Do not search parent directories for the Rakefile."],
['--quiet', '-q', GetoptLong::NO_ARGUMENT,
"Do not log messages to standard output."],
"Do not log messages to standard output (default)."],
['--rakefile', '-f', GetoptLong::REQUIRED_ARGUMENT,
"Use FILE as the rakefile."],
['--require', '-r', GetoptLong::REQUIRED_ARGUMENT,
@@ -324,7 +383,11 @@ class RakeApp
['--usage', '-h', GetoptLong::NO_ARGUMENT,
"Display usage."],
['--verbose', '-v', GetoptLong::NO_ARGUMENT,
"Log message to standard output (default)."],
"Log message to standard output."],
['--directory', '-C', GetoptLong::REQUIRED_ARGUMENT,
"Change executing directory of rakefiles."],
['--jobs', '-j', GetoptLong::REQUIRED_ARGUMENT,
'Execute rake with parallel jobs.']
]
# Create a RakeApp object.
@@ -415,6 +478,10 @@ class RakeApp
when '--version'
puts "rake, version #{RAKEVERSION}"
exit
when '--directory'
Dir.chdir value
when '--jobs'
$rake_jobs = [value.to_i, 1].max
else
fail "Unknown option: #{opt}"
end
@@ -431,6 +498,12 @@ class RakeApp
# Run the +rake+ application.
def run
handle_options
unless $rake_root_fiber
require 'fiber'
$rake_root_fiber = Fiber.current
end
begin
here = Dir.pwd
while ! have_rakefile
@@ -440,12 +513,12 @@ class RakeApp
end
here = Dir.pwd
end
tasks = []
root_tasks = []
ARGV.each do |task_name|
if /^(\w+)=(.*)/.match(task_name)
ENV[$1] = $2
else
tasks << task_name
root_tasks << task_name
end
end
puts "(in #{Dir.pwd})"
@@ -454,22 +527,93 @@ class RakeApp
if $show_tasks
display_tasks
else
tasks.push("default") if tasks.size == 0
tasks.each do |task_name|
MiniRake::Task[task_name].invoke
root_tasks.push("default") if root_tasks.empty?
# revese tasks for popping
root_tasks.reverse!
tasks = []
until root_tasks.empty?
root_name = root_tasks.pop
tasks << root_name
until tasks.empty?
task_name = tasks.pop
t = MiniRake::Task[task_name]
f = t.invoke
# append additional tasks to task queue
if f.kind_of?(Array)
tasks.push(*f)
tasks.uniq!
end
unless f.kind_of? Fiber
tasks.insert 0, task_name unless t.done?
if root_name == task_name
wait_process
end
next
end
wait_process while $rake_fiber_table.size >= $rake_jobs
f.transfer
end
end
wait_process until $rake_fiber_table.empty?
end
rescue Exception => ex
puts "rake aborted!"
rescue Exception => e
begin
$rake_failed << e
wait_process until $rake_fiber_table.empty?
rescue Exception => next_e
e = next_e
retry
end
end
return if $rake_failed.empty?
puts "rake aborted!"
$rake_failed.each do |ex|
puts ex.message
if $trace
if $trace || $verbose
puts ex.backtrace.join("\n")
else
puts ex.backtrace.find {|str| str =~ /#{@rakefile}/ } || ""
end
exit 1
end
exit 1
end
def wait_process(count = 0)
dur = [0.0001 * (10 ** count), 1].min
sleep dur
exited = []
$rake_fiber_table.each do |pid, v|
exited << pid unless v[:process_waiter].alive?
end
exited.each do |pid|
ent = $rake_fiber_table.delete pid
st = ent[:process_waiter].value
# ignore process that isn't created by `sh` method
return if ent.nil?
if st.exitstatus != 0
raise "Command Failed: [#{ent[:command]}]"
end
fail 'task scheduling bug!' if $rake_fiber_table.size >= $rake_jobs
ent[:fiber].transfer
end
wait_process(count + 1) if !$rake_fiber_table.empty? && exited.empty?
end
end
if __FILE__ == $0 then
+43 -10
View File
@@ -1,4 +1,13 @@
MRuby::GemBox.new do |conf|
# Meta-programming features
conf.gem :core => "mruby-metaprog"
# Use standard IO/File class
conf.gem :core => "mruby-io"
# Use standard Array#pack, String#unpack methods
conf.gem :core => "mruby-pack"
# Use standard Kernel#sprintf method
conf.gem :core => "mruby-sprintf"
@@ -14,34 +23,37 @@ MRuby::GemBox.new do |conf|
# Use standard Struct class
conf.gem :core => "mruby-struct"
# Use extensional Enumerable module
# Use Comparable module extension
conf.gem :core => "mruby-compar-ext"
# Use Enumerable module extension
conf.gem :core => "mruby-enum-ext"
# Use extensional String class
# Use String class extension
conf.gem :core => "mruby-string-ext"
# Use extensional Numeric class
# Use Numeric class extension
conf.gem :core => "mruby-numeric-ext"
# Use extensional Array class
# Use Array class extension
conf.gem :core => "mruby-array-ext"
# Use extensional Hash class
# Use Hash class extension
conf.gem :core => "mruby-hash-ext"
# Use extensional Range class
# Use Range class extension
conf.gem :core => "mruby-range-ext"
# Use extensional Proc class
# Use Proc class extension
conf.gem :core => "mruby-proc-ext"
# Use extensional Symbol class
# Use Symbol class extension
conf.gem :core => "mruby-symbol-ext"
# Use Random class
conf.gem :core => "mruby-random"
# Use extensional Object class
# Use Object class extension
conf.gem :core => "mruby-object-ext"
# Use ObjectSpace class
@@ -50,7 +62,13 @@ MRuby::GemBox.new do |conf|
# Use Fiber class
conf.gem :core => "mruby-fiber"
# Use extended toplevel object (main) methods
# Use Enumerator class (require mruby-fiber)
conf.gem :core => "mruby-enumerator"
# Use Enumerator::Lazy class (require mruby-enumerator)
conf.gem :core => "mruby-enum-lazy"
# Use toplevel object (main) methods extension
conf.gem :core => "mruby-toplevel-ext"
# Generate mirb command
@@ -58,4 +76,19 @@ MRuby::GemBox.new do |conf|
# Generate mruby command
conf.gem :core => "mruby-bin-mruby"
# Generate mruby-strip command
conf.gem :core => "mruby-bin-strip"
# Use Kernel module extension
conf.gem :core => "mruby-kernel-ext"
# Use class/module extension
conf.gem :core => "mruby-class-ext"
# Use Method/UnboundMethod class
conf.gem :core => "mruby-method"
# Use mruby-compiler to build other mrbgems
conf.gem :core => "mruby-compiler"
end
+3 -3
View File
@@ -2,8 +2,8 @@ MRuby::GemBox.new do |conf|
conf.gem :core => "mruby-sprintf"
conf.gem :core => "mruby-print"
Dir.glob("#{root}/mrbgems/mruby-*") do |x|
g = File.basename(x)
conf.gem :core => g unless g =~ /^mruby-(print|sprintf)$/
Dir.glob("#{root}/mrbgems/mruby-*/mrbgem.rake") do |x|
g = File.basename File.dirname x
conf.gem :core => g unless g =~ /^mruby-(print|sprintf|bin-debugger|test)$/
end
end
+1
View File
@@ -1,4 +1,5 @@
MRuby::Gem::Specification.new('mruby-array-ext') do |spec|
spec.license = 'MIT'
spec.author = 'mruby developers'
spec.summary = 'Array class extension'
end
+789 -48
View File
@@ -1,7 +1,8 @@
class Array
##
# call-seq:
# ary.uniq! -> ary or nil
# ary.uniq! -> ary or nil
# ary.uniq! { |item| ... } -> ary or nil
#
# Removes duplicate elements from +self+.
# Returns <code>nil</code> if no changes are made (that is, no
@@ -11,13 +12,23 @@ class Array
# a.uniq! #=> ["a", "b", "c"]
# b = [ "a", "b", "c" ]
# b.uniq! #=> nil
# c = [["student","sam"], ["student","george"], ["teacher","matz"]]
# c.uniq! { |s| s.first } # => [["student", "sam"], ["teacher", "matz"]]
#
def uniq!
ary = self.dup
result = []
while ary.size > 0
result << ary.shift
ary.delete(result.last)
def uniq!(&block)
hash = {}
if block
self.each do |val|
key = block.call(val)
hash[key] = val unless hash.key?(key)
end
result = hash.values
else
hash = {}
self.each do |val|
hash[val] = val
end
result = hash.keys
end
if result.size == self.size
nil
@@ -28,16 +39,20 @@ class Array
##
# call-seq:
# ary.uniq -> new_ary
# ary.uniq -> new_ary
# ary.uniq { |item| ... } -> new_ary
#
# Returns a new array by removing duplicate values in +self+.
#
# a = [ "a", "a", "b", "b", "c" ]
# a.uniq #=> ["a", "b", "c"]
#
def uniq
# b = [["student","sam"], ["student","george"], ["teacher","matz"]]
# b.uniq { |s| s.first } # => [["student", "sam"], ["teacher", "matz"]]
#
def uniq(&block)
ary = self.dup
ary.uniq!
ary.uniq!(&block)
ary
end
@@ -57,11 +72,38 @@ class Array
hash = {}
array = []
elem.each { |x| hash[x] = true }
self.each { |x| array << x unless hash[x] }
idx = 0
len = elem.size
while idx < len
hash[elem[idx]] = true
idx += 1
end
idx = 0
len = size
while idx < len
v = self[idx]
array << v unless hash[v]
idx += 1
end
array
end
##
# call-seq:
# ary.difference(other_ary1, other_ary2, ...) -> new_ary
#
# Returns a new array that is a copy of the original array, removing all
# occurrences of any item that also appear in +other_ary+. The order is
# preserved from the original array.
#
def difference(*args)
ary = self
args.each do |x|
ary = ary - x
end
ary
end
##
# call-seq:
# ary | other_ary -> new_ary
@@ -79,6 +121,25 @@ class Array
ary.uniq! or ary
end
##
# call-seq:
# ary.union(other_ary,...) -> new_ary
#
# Set Union---Returns a new array by joining this array with
# <i>other_ary</i>, removing duplicates.
#
# ["a", "b", "c"].union(["c", "d", "a"], ["a", "c", "e"])
# #=> ["a", "b", "c", "d", "e"]
#
def union(*args)
ary = self.dup
args.each do |x|
ary.concat(x)
ary.uniq!
end
ary
end
##
# call-seq:
# ary & other_ary -> new_ary
@@ -93,16 +154,43 @@ class Array
hash = {}
array = []
elem.each{|v| hash[v] = true }
self.each do |v|
idx = 0
len = elem.size
while idx < len
hash[elem[idx]] = true
idx += 1
end
idx = 0
len = size
while idx < len
v = self[idx]
if hash[v]
array << v
hash.delete v
end
idx += 1
end
array
end
##
# call-seq:
# ary.intersection(other_ary,...) -> new_ary
#
# Set Intersection---Returns a new array containing elements common to
# this array and <i>other_ary</i>s, removing duplicates. The order is
# preserved from the original array.
#
# [1, 2, 3].intersection([3, 4, 1], [1, 3, 5]) #=> [1, 3]
#
def intersection(*args)
ary = self
args.each do |x|
ary = ary & x
end
ary
end
##
# call-seq:
# ary.flatten -> new_ary
@@ -121,15 +209,9 @@ class Array
# a.flatten(1) #=> [1, 2, 3, [4, 5]]
#
def flatten(depth=nil)
ar = []
self.each do |e|
if e.is_a?(Array) && (depth.nil? || depth > 0)
ar += e.flatten(depth.nil? ? nil : depth - 1)
else
ar << e
end
end
ar
res = dup
res.flatten! depth
res
end
##
@@ -152,13 +234,17 @@ class Array
def flatten!(depth=nil)
modified = false
ar = []
self.each do |e|
idx = 0
len = size
while idx < len
e = self[idx]
if e.is_a?(Array) && (depth.nil? || depth > 0)
ar += e.flatten(depth.nil? ? nil : depth - 1)
modified = true
else
ar << e
end
idx += 1
end
if modified
self.replace(ar)
@@ -194,43 +280,698 @@ class Array
# [ "a", "b", "c" ].compact! #=> nil
#
def compact!
result = self.select { |e| e != nil }
result = self.select { |e| !e.nil? }
if result.size == self.size
nil
else
self.replace(result)
end
end
# for efficiency
def reverse_each(&block)
return to_enum :reverse_each unless block
i = self.size - 1
while i>=0
block.call(self[i])
i -= 1
end
self
end
##
# call-seq:
# ary[rng] -> ary slice
# call-seq:
# ary.fetch(index) -> obj
# ary.fetch(index, default) -> obj
# ary.fetch(index) { |index| block } -> obj
#
# Remeturns a slice of +ary+ according to the Range instance +rng+.
# Tries to return the element at position +index+, but throws an IndexError
# exception if the referenced +index+ lies outside of the array bounds. This
# error can be prevented by supplying a second argument, which will act as a
# +default+ value.
#
# a = [ "a", "b", "c", "d", "e" ]
# a[1] => "b"
# a[1,2] => ["b", "c"]
# a[1..-2] => ["b", "c", "d"]
# Alternatively, if a block is given it will only be executed when an
# invalid +index+ is referenced.
#
def [](idx, len=nil)
case idx
when Range
if idx.last < 0 then
len = self.length - idx.first + idx.last + 1
else
len = idx.last - idx.first + 1
# Negative values of +index+ count from the end of the array.
#
# a = [ 11, 22, 33, 44 ]
# a.fetch(1) #=> 22
# a.fetch(-1) #=> 44
# a.fetch(4, 'cat') #=> "cat"
# a.fetch(100) { |i| puts "#{i} is out of bounds" }
# #=> "100 is out of bounds"
#
def fetch(n, ifnone=NONE, &block)
warn "block supersedes default value argument" if !n.nil? && ifnone != NONE && block
idx = n
if idx < 0
idx += size
end
if idx < 0 || size <= idx
return block.call(n) if block
if ifnone == NONE
raise IndexError, "index #{n} outside of array bounds: #{-size}...#{size}"
end
return self.slice(idx.first, len)
when Numeric
if len then
return self.slice(idx.to_i, len.to_i)
else
return self.slice(idx.to_i)
return ifnone
end
self[idx]
end
##
# call-seq:
# ary.fill(obj) -> ary
# ary.fill(obj, start [, length]) -> ary
# ary.fill(obj, range ) -> ary
# ary.fill { |index| block } -> ary
# ary.fill(start [, length] ) { |index| block } -> ary
# ary.fill(range) { |index| block } -> ary
#
# The first three forms set the selected elements of +self+ (which
# may be the entire array) to +obj+.
#
# A +start+ of +nil+ is equivalent to zero.
#
# A +length+ of +nil+ is equivalent to the length of the array.
#
# The last three forms fill the array with the value of the given block,
# which is passed the absolute index of each element to be filled.
#
# Negative values of +start+ count from the end of the array, where +-1+ is
# the last element.
#
# a = [ "a", "b", "c", "d" ]
# a.fill("x") #=> ["x", "x", "x", "x"]
# a.fill("w", -1) #=> ["x", "x", "x", "w"]
# a.fill("z", 2, 2) #=> ["x", "x", "z", "z"]
# a.fill("y", 0..1) #=> ["y", "y", "z", "z"]
# a.fill { |i| i*i } #=> [0, 1, 4, 9]
# a.fill(-2) { |i| i*i*i } #=> [0, 1, 8, 27]
# a.fill(1, 2) { |i| i+1 } #=> [0, 2, 3, 27]
# a.fill(0..1) { |i| i+1 } #=> [1, 2, 3, 27]
#
def fill(arg0=nil, arg1=nil, arg2=nil, &block)
if arg0.nil? && arg1.nil? && arg2.nil? && !block
raise ArgumentError, "wrong number of arguments (0 for 1..3)"
end
beg = len = 0
ary = []
if block
if arg0.nil? && arg1.nil? && arg2.nil?
# ary.fill { |index| block } -> ary
beg = 0
len = self.size
elsif !arg0.nil? && arg0.kind_of?(Range)
# ary.fill(range) { |index| block } -> ary
beg = arg0.begin
beg += self.size if beg < 0
len = arg0.end
len += self.size if len < 0
len += 1 unless arg0.exclude_end?
elsif !arg0.nil?
# ary.fill(start [, length] ) { |index| block } -> ary
beg = arg0
beg += self.size if beg < 0
if arg1.nil?
len = self.size
else
len = arg0 + arg1
end
end
else
self.slice(idx)
if !arg0.nil? && arg1.nil? && arg2.nil?
# ary.fill(obj) -> ary
beg = 0
len = self.size
elsif !arg0.nil? && !arg1.nil? && arg1.kind_of?(Range)
# ary.fill(obj, range ) -> ary
beg = arg1.begin
beg += self.size if beg < 0
len = arg1.end
len += self.size if len < 0
len += 1 unless arg1.exclude_end?
elsif !arg0.nil? && !arg1.nil?
# ary.fill(obj, start [, length]) -> ary
beg = arg1
beg += self.size if beg < 0
if arg2.nil?
len = self.size
else
len = beg + arg2
end
end
end
i = beg
if block
while i < len
self[i] = block.call(i)
i += 1
end
else
while i < len
self[i] = arg0
i += 1
end
end
self
end
##
# call-seq:
# ary.rotate(count=1) -> new_ary
#
# Returns a new array by rotating +self+ so that the element at +count+ is
# the first element of the new array.
#
# If +count+ is negative then it rotates in the opposite direction, starting
# from the end of +self+ where +-1+ is the last element.
#
# a = [ "a", "b", "c", "d" ]
# a.rotate #=> ["b", "c", "d", "a"]
# a #=> ["a", "b", "c", "d"]
# a.rotate(2) #=> ["c", "d", "a", "b"]
# a.rotate(-3) #=> ["b", "c", "d", "a"]
def rotate(count=1)
ary = []
len = self.length
if len > 0
idx = (count < 0) ? (len - (~count % len) - 1) : (count % len) # rotate count
len.times do
ary << self[idx]
idx += 1
idx = 0 if idx > len-1
end
end
ary
end
##
# call-seq:
# ary.rotate!(count=1) -> ary
#
# Rotates +self+ in place so that the element at +count+ comes first, and
# returns +self+.
#
# If +count+ is negative then it rotates in the opposite direction, starting
# from the end of the array where +-1+ is the last element.
#
# a = [ "a", "b", "c", "d" ]
# a.rotate! #=> ["b", "c", "d", "a"]
# a #=> ["b", "c", "d", "a"]
# a.rotate!(2) #=> ["d", "a", "b", "c"]
# a.rotate!(-3) #=> ["a", "b", "c", "d"]
def rotate!(count=1)
self.replace(self.rotate(count))
end
##
# call-seq:
# ary.delete_if { |item| block } -> ary
# ary.delete_if -> Enumerator
#
# Deletes every element of +self+ for which block evaluates to +true+.
#
# The array is changed instantly every time the block is called, not after
# the iteration is over.
#
# See also Array#reject!
#
# If no block is given, an Enumerator is returned instead.
#
# scores = [ 97, 42, 75 ]
# scores.delete_if {|score| score < 80 } #=> [97]
def delete_if(&block)
return to_enum :delete_if unless block
idx = 0
while idx < self.size do
if block.call(self[idx])
self.delete_at(idx)
else
idx += 1
end
end
self
end
##
# call-seq:
# ary.reject! { |item| block } -> ary or nil
# ary.reject! -> Enumerator
#
# Equivalent to Array#delete_if, deleting elements from +self+ for which the
# block evaluates to +true+, but returns +nil+ if no changes were made.
#
# The array is changed instantly every time the block is called, not after
# the iteration is over.
#
# See also Enumerable#reject and Array#delete_if.
#
# If no block is given, an Enumerator is returned instead.
def reject!(&block)
return to_enum :reject! unless block
len = self.size
idx = 0
while idx < self.size do
if block.call(self[idx])
self.delete_at(idx)
else
idx += 1
end
end
if self.size == len
nil
else
self
end
end
##
# call-seq:
# ary.insert(index, obj...) -> ary
#
# Inserts the given values before the element with the given +index+.
#
# Negative indices count backwards from the end of the array, where +-1+ is
# the last element.
#
# a = %w{ a b c d }
# a.insert(2, 99) #=> ["a", "b", 99, "c", "d"]
# a.insert(-2, 1, 2, 3) #=> ["a", "b", 99, "c", 1, 2, 3, "d"]
def insert(idx, *args)
idx += self.size + 1 if idx < 0
self[idx, 0] = args
self
end
##
# call-seq:
# ary.bsearch {|x| block } -> elem
#
# By using binary search, finds a value from this array which meets
# the given condition in O(log n) where n is the size of the array.
#
# You can use this method in two use cases: a find-minimum mode and
# a find-any mode. In either case, the elements of the array must be
# monotone (or sorted) with respect to the block.
#
# In find-minimum mode (this is a good choice for typical use case),
# the block must return true or false, and there must be an index i
# (0 <= i <= ary.size) so that:
#
# - the block returns false for any element whose index is less than
# i, and
# - the block returns true for any element whose index is greater
# than or equal to i.
#
# This method returns the i-th element. If i is equal to ary.size,
# it returns nil.
#
# ary = [0, 4, 7, 10, 12]
# ary.bsearch {|x| x >= 4 } #=> 4
# ary.bsearch {|x| x >= 6 } #=> 7
# ary.bsearch {|x| x >= -1 } #=> 0
# ary.bsearch {|x| x >= 100 } #=> nil
#
# In find-any mode (this behaves like libc's bsearch(3)), the block
# must return a number, and there must be two indices i and j
# (0 <= i <= j <= ary.size) so that:
#
# - the block returns a positive number for ary[k] if 0 <= k < i,
# - the block returns zero for ary[k] if i <= k < j, and
# - the block returns a negative number for ary[k] if
# j <= k < ary.size.
#
# Under this condition, this method returns any element whose index
# is within i...j. If i is equal to j (i.e., there is no element
# that satisfies the block), this method returns nil.
#
# ary = [0, 4, 7, 10, 12]
# # try to find v such that 4 <= v < 8
# ary.bsearch {|x| 1 - (x / 4).truncate } #=> 4 or 7
# # try to find v such that 8 <= v < 10
# ary.bsearch {|x| 4 - (x / 2).truncate } #=> nil
#
# You must not mix the two modes at a time; the block must always
# return either true/false, or always return a number. It is
# undefined which value is actually picked up at each iteration.
def bsearch(&block)
return to_enum :bsearch unless block
if idx = bsearch_index(&block)
self[idx]
else
nil
end
end
##
# call-seq:
# ary.bsearch_index {|x| block } -> int or nil
#
# By using binary search, finds an index of a value from this array which
# meets the given condition in O(log n) where n is the size of the array.
#
# It supports two modes, depending on the nature of the block and they are
# exactly the same as in the case of #bsearch method with the only difference
# being that this method returns the index of the element instead of the
# element itself. For more details consult the documentation for #bsearch.
def bsearch_index(&block)
return to_enum :bsearch_index unless block
low = 0
high = size
satisfied = false
while low < high
mid = ((low+high)/2).truncate
res = block.call self[mid]
case res
when 0 # find-any mode: Found!
return mid
when Numeric # find-any mode: Continue...
in_lower_half = res < 0
when true # find-min mode
in_lower_half = true
satisfied = true
when false, nil # find-min mode
in_lower_half = false
else
raise TypeError, 'invalid block result (must be numeric, true, false or nil)'
end
if in_lower_half
high = mid
else
low = mid + 1
end
end
satisfied ? low : nil
end
##
# call-seq:
# ary.delete_if { |item| block } -> ary
# ary.delete_if -> Enumerator
#
# Deletes every element of +self+ for which block evaluates to +true+.
#
# The array is changed instantly every time the block is called, not after
# the iteration is over.
#
# See also Array#reject!
#
# If no block is given, an Enumerator is returned instead.
#
# scores = [ 97, 42, 75 ]
# scores.delete_if {|score| score < 80 } #=> [97]
def delete_if(&block)
return to_enum :delete_if unless block
idx = 0
while idx < self.size do
if block.call(self[idx])
self.delete_at(idx)
else
idx += 1
end
end
self
end
##
# call-seq:
# ary.keep_if { |item| block } -> ary
# ary.keep_if -> Enumerator
#
# Deletes every element of +self+ for which the given block evaluates to
# +false+.
#
# See also Array#select!
#
# If no block is given, an Enumerator is returned instead.
#
# a = [1, 2, 3, 4, 5]
# a.keep_if { |val| val > 3 } #=> [4, 5]
def keep_if(&block)
return to_enum :keep_if unless block
idx = 0
len = self.size
while idx < self.size do
if block.call(self[idx])
idx += 1
else
self.delete_at(idx)
end
end
self
end
##
# call-seq:
# ary.select! {|item| block } -> ary or nil
# ary.select! -> Enumerator
#
# Invokes the given block passing in successive elements from +self+,
# deleting elements for which the block returns a +false+ value.
#
# If changes were made, it will return +self+, otherwise it returns +nil+.
#
# See also Array#keep_if
#
# If no block is given, an Enumerator is returned instead.
def select!(&block)
return to_enum :select! unless block
result = []
idx = 0
len = size
while idx < len
elem = self[idx]
result << elem if block.call(elem)
idx += 1
end
return nil if len == result.size
self.replace(result)
end
##
# call-seq:
# ary.index(val) -> int or nil
# ary.index {|item| block } -> int or nil
#
# Returns the _index_ of the first object in +ary+ such that the object is
# <code>==</code> to +obj+.
#
# If a block is given instead of an argument, returns the _index_ of the
# first object for which the block returns +true+. Returns +nil+ if no
# match is found.
#
# ISO 15.2.12.5.14
def index(val=NONE, &block)
return to_enum(:find_index, val) if !block && val == NONE
if block
idx = 0
len = size
while idx < len
return idx if block.call self[idx]
idx += 1
end
else
return self.__ary_index(val)
end
nil
end
##
# call-seq:
# ary.dig(idx, ...) -> object
#
# Extracts the nested value specified by the sequence of <i>idx</i>
# objects by calling +dig+ at each step, returning +nil+ if any
# intermediate step is +nil+.
#
def dig(idx,*args)
n = self[idx]
if args.size > 0
n&.dig(*args)
else
n
end
end
##
# call-seq:
# ary.permutation { |p| block } -> ary
# ary.permutation -> Enumerator
# ary.permutation(n) { |p| block } -> ary
# ary.permutation(n) -> Enumerator
#
# When invoked with a block, yield all permutations of length +n+ of the
# elements of the array, then return the array itself.
#
# If +n+ is not specified, yield all permutations of all elements.
#
# The implementation makes no guarantees about the order in which the
# permutations are yielded.
#
# If no block is given, an Enumerator is returned instead.
#
# Examples:
#
# a = [1, 2, 3]
# a.permutation.to_a #=> [[1,2,3],[1,3,2],[2,1,3],[2,3,1],[3,1,2],[3,2,1]]
# a.permutation(1).to_a #=> [[1],[2],[3]]
# a.permutation(2).to_a #=> [[1,2],[1,3],[2,1],[2,3],[3,1],[3,2]]
# a.permutation(3).to_a #=> [[1,2,3],[1,3,2],[2,1,3],[2,3,1],[3,1,2],[3,2,1]]
# a.permutation(0).to_a #=> [[]] # one permutation of length 0
# a.permutation(4).to_a #=> [] # no permutations of length 4
def permutation(n=self.size, &block)
return to_enum(:permutation, n) unless block
size = self.size
if n == 0
yield []
elsif 0 < n && n <= size
i = 0
while i<size
result = [self[i]]
if n-1 > 0
ary = self[0...i] + self[i+1..-1]
ary.permutation(n-1) do |c|
yield result + c
end
else
yield result
end
i += 1
end
end
self
end
##
# call-seq:
# ary.combination(n) { |c| block } -> ary
# ary.combination(n) -> Enumerator
#
# When invoked with a block, yields all combinations of length +n+ of elements
# from the array and then returns the array itself.
#
# The implementation makes no guarantees about the order in which the
# combinations are yielded.
#
# If no block is given, an Enumerator is returned instead.
#
# Examples:
#
# a = [1, 2, 3, 4]
# a.combination(1).to_a #=> [[1],[2],[3],[4]]
# a.combination(2).to_a #=> [[1,2],[1,3],[1,4],[2,3],[2,4],[3,4]]
# a.combination(3).to_a #=> [[1,2,3],[1,2,4],[1,3,4],[2,3,4]]
# a.combination(4).to_a #=> [[1,2,3,4]]
# a.combination(0).to_a #=> [[]] # one combination of length 0
# a.combination(5).to_a #=> [] # no combinations of length 5
def combination(n, &block)
return to_enum(:combination, n) unless block
size = self.size
if n == 0
yield []
elsif n == 1
i = 0
while i<size
yield [self[i]]
i += 1
end
elsif n <= size
i = 0
while i<size
result = [self[i]]
self[i+1..-1].combination(n-1) do |c|
yield result + c
end
i += 1
end
end
self
end
##
# call-seq:
# ary.transpose -> new_ary
#
# Assumes that self is an array of arrays and transposes the rows and columns.
#
# If the length of the subarrays don't match, an IndexError is raised.
#
# Examples:
#
# a = [[1,2], [3,4], [5,6]]
# a.transpose #=> [[1, 3, 5], [2, 4, 6]]
def transpose
return [] if empty?
column_count = nil
self.each do |row|
raise TypeError unless row.is_a?(Array)
column_count ||= row.size
raise IndexError, 'element size differs' unless column_count == row.size
end
Array.new(column_count) do |column_index|
self.map { |row| row[column_index] }
end
end
##
# call-seq:
# ary.to_h -> Hash
# ary.to_h{|item| ... } -> Hash
#
# Returns the result of interpreting <i>aray</i> as an array of
# <tt>[key, value]</tt> pairs. If a block is given, it should
# return <tt>[key, value]</tt> pairs to construct a hash.
#
# [[:foo, :bar], [1, 2]].to_h
# # => {:foo => :bar, 1 => 2}
# [1, 2].to_h{|x| [x, x*2]}
# # => {1 => 2, 2 => 4}
#
def to_h(&blk)
h = {}
self.each do |v|
v = blk.call(v) if blk
raise TypeError, "wrong element type #{v.class}" unless Array === v
raise ArgumentError, "wrong array length (expected 2, was #{v.length})" unless v.length == 2
h[v[0]] = v[1]
end
h
end
alias append push
alias prepend unshift
alias filter! select!
end
+98 -35
View File
@@ -1,35 +1,8 @@
#include "mruby.h"
#include "mruby/value.h"
#include "mruby/array.h"
/*
* call-seq:
* Array.try_convert(obj) -> array or nil
*
* Try to convert <i>obj</i> into an array, using +to_ary+ method.
* Returns converted array or +nil+ if <i>obj</i> cannot be converted
* for any reason. This method can be used to check if an argument is an
* array.
*
* Array.try_convert([1]) #=> [1]
* Array.try_convert("1") #=> nil
*
* if tmp = Array.try_convert(arg)
* # the argument is an array
* elsif tmp = String.try_convert(arg)
* # the argument is a string
* end
*
*/
static mrb_value
mrb_ary_s_try_convert(mrb_state *mrb, mrb_value self)
{
mrb_value ary;
mrb_get_args(mrb, "o", &ary);
return mrb_check_array_type(mrb, ary);
}
#include <mruby.h>
#include <mruby/value.h>
#include <mruby/array.h>
#include <mruby/range.h>
#include <mruby/hash.h>
/*
* call-seq:
@@ -92,7 +65,7 @@ mrb_ary_rassoc(mrb_state *mrb, mrb_value ary)
for (i = 0; i < RARRAY_LEN(ary); ++i) {
v = RARRAY_PTR(ary)[i];
if (mrb_type(v) == MRB_TT_ARRAY &&
if (mrb_array_p(v) &&
RARRAY_LEN(v) > 1 &&
mrb_equal(mrb, RARRAY_PTR(v)[1], value))
return v;
@@ -122,16 +95,106 @@ mrb_ary_at(mrb_state *mrb, mrb_value ary)
return mrb_ary_entry(ary, pos);
}
static mrb_value
mrb_ary_values_at(mrb_state *mrb, mrb_value self)
{
mrb_int argc;
mrb_value *argv;
mrb_get_args(mrb, "*", &argv, &argc);
return mrb_get_values_at(mrb, self, RARRAY_LEN(self), argc, argv, mrb_ary_ref);
}
/*
* call-seq:
* ary.slice!(index) -> obj or nil
* ary.slice!(start, length) -> new_ary or nil
* ary.slice!(range) -> new_ary or nil
*
* Deletes the element(s) given by an +index+ (optionally up to +length+
* elements) or by a +range+.
*
* Returns the deleted object (or objects), or +nil+ if the +index+ is out of
* range.
*
* a = [ "a", "b", "c" ]
* a.slice!(1) #=> "b"
* a #=> ["a", "c"]
* a.slice!(-1) #=> "c"
* a #=> ["a"]
* a.slice!(100) #=> nil
* a #=> ["a"]
*/
static mrb_value
mrb_ary_slice_bang(mrb_state *mrb, mrb_value self)
{
struct RArray *a = mrb_ary_ptr(self);
mrb_int i, j, k, len, alen;
mrb_value val;
mrb_value *ptr;
mrb_value ary;
mrb_ary_modify(mrb, a);
if (mrb_get_argc(mrb) == 1) {
mrb_value index;
mrb_get_args(mrb, "o|i", &index, &len);
switch (mrb_type(index)) {
case MRB_TT_RANGE:
if (mrb_range_beg_len(mrb, index, &i, &len, ARY_LEN(a), TRUE) == MRB_RANGE_OK) {
goto delete_pos_len;
}
else {
return mrb_nil_value();
}
case MRB_TT_FIXNUM:
val = mrb_funcall(mrb, self, "delete_at", 1, index);
return val;
default:
val = mrb_funcall(mrb, self, "delete_at", 1, index);
return val;
}
}
mrb_get_args(mrb, "ii", &i, &len);
delete_pos_len:
alen = ARY_LEN(a);
if (i < 0) i += alen;
if (i < 0 || alen < i) return mrb_nil_value();
if (len < 0) return mrb_nil_value();
if (alen == i) return mrb_ary_new(mrb);
if (len > alen - i) len = alen - i;
ary = mrb_ary_new_capa(mrb, len);
ptr = ARY_PTR(a);
for (j = i, k = 0; k < len; ++j, ++k) {
mrb_ary_push(mrb, ary, ptr[j]);
}
ptr += i;
for (j = i; j < alen - len; ++j) {
*ptr = *(ptr+len);
++ptr;
}
mrb_ary_resize(mrb, self, alen - len);
return ary;
}
void
mrb_mruby_array_ext_gem_init(mrb_state* mrb)
{
struct RClass * a = mrb->array_class;
mrb_define_class_method(mrb, a, "try_convert", mrb_ary_s_try_convert, MRB_ARGS_REQ(1));
mrb_define_method(mrb, a, "assoc", mrb_ary_assoc, MRB_ARGS_REQ(1));
mrb_define_method(mrb, a, "at", mrb_ary_at, MRB_ARGS_REQ(1));
mrb_define_method(mrb, a, "rassoc", mrb_ary_rassoc, MRB_ARGS_REQ(1));
mrb_define_method(mrb, a, "values_at", mrb_ary_values_at, MRB_ARGS_ANY());
mrb_define_method(mrb, a, "slice!", mrb_ary_slice_bang, MRB_ARGS_ARG(1,1));
}
void
+364 -46
View File
@@ -1,9 +1,21 @@
##
# Array(Ext) Test
assert("Array::try_convert") do
Array.try_convert([1]) == [1] and
Array.try_convert("1").nil?
def assert_permutation_combination(exp, receiver, meth, *args)
act = []
ret = receiver.__send__(meth, *args) { |v| act << v }
assert "assert_#{meth}" do
assert_equal(exp, act.sort)
assert_same(receiver, ret)
end
end
def assert_permutation(exp, receiver, *args)
assert_permutation_combination(exp, receiver, :permutation, *args)
end
def assert_combination(exp, receiver, *args)
assert_permutation_combination(exp, receiver, :combination, *args)
end
assert("Array#assoc") do
@@ -12,105 +24,411 @@ assert("Array#assoc") do
s3 = "foo"
a = [ s1, s2, s3 ]
a.assoc("letters") == [ "letters", "a", "b", "c" ] and
a.assoc("foo").nil?
assert_equal [ "letters", "a", "b", "c" ], a.assoc("letters")
assert_nil a.assoc("foo")
end
assert("Array#at") do
a = [ "a", "b", "c", "d", "e" ]
a.at(0) == "a" and a.at(-1) == "e"
assert_equal "a", a.at(0)
assert_equal "e", a.at(-1)
end
assert("Array#rassoc") do
a = [ [ 1, "one"], [2, "two"], [3, "three"], ["ii", "two"] ]
a.rassoc("two") == [2, "two"] and
a.rassoc("four").nil?
assert_equal [2, "two"], a.rassoc("two")
assert_nil a.rassoc("four")
end
assert("Array#uniq!") do
a = [1, 2, 3, 1]
a.uniq!
a == [1, 2, 3]
assert_equal [1, 2, 3], a
b = [ "a", "b", "c" ]
assert_nil b.uniq!
c = [["student","sam"], ["student","george"], ["teacher","matz"]]
assert_equal [["student", "sam"], ["teacher", "matz"]], c.uniq! { |s| s.first }
d = [["student","sam"], ["teacher","matz"]]
assert_nil d.uniq! { |s| s.first }
end
assert("Array#uniq") do
a = [1, 2, 3, 1]
a.uniq == [1, 2, 3] && a == [1, 2, 3, 1]
assert_equal [1, 2, 3], a.uniq
assert_equal [1, 2, 3, 1], a
b = [["student","sam"], ["student","george"], ["teacher","matz"]]
assert_equal [["student", "sam"], ["teacher", "matz"]], b.uniq { |s| s.first }
end
assert("Array#-") do
a = [1, 2, 3, 1]
b = [1]
c = 1
e1 = nil
begin
a - c
rescue => e1
end
(a - b) == [2, 3] and e1.class == TypeError and a == [1, 2, 3, 1]
assert_raise(TypeError) { a - c }
assert_equal [2, 3], (a - b)
assert_equal [1, 2, 3, 1], a
end
assert("Array#|") do
a = [1, 2, 3, 1]
b = [1, 4]
c = 1
e1 = nil
begin
a | c
rescue => e1
end
assert_raise(TypeError) { a | c }
assert_equal [1, 2, 3, 4], (a | b)
assert_equal [1, 2, 3, 1], a
end
(a | b) == [1, 2, 3, 4] and e1.class == TypeError and a == [1, 2, 3, 1]
assert("Array#union") do
a = [1, 2, 3, 1]
b = [1, 4]
c = [1, 5]
assert_equal [1, 2, 3, 4, 5], a.union(b,c)
end
assert("Array#difference") do
a = [1, 2, 3, 1, 6, 7]
b = [1, 4, 6]
c = [1, 5, 7]
assert_equal [2, 3], a.difference(b,c)
end
assert("Array#&") do
a = [1, 2, 3, 1]
b = [1, 4]
c = 1
e1 = nil
begin
a & c
rescue => e1
end
assert_raise(TypeError) { a & c }
assert_equal [1], (a & b)
assert_equal [1, 2, 3, 1], a
end
(a & b) == [1] and e1.class == TypeError and a == [1, 2, 3, 1]
assert("Array#intersection") do
a = [1, 2, 3, 1, 8, 6, 7, 8]
b = [1, 4, 6, 8]
c = [1, 5, 7, 8]
assert_equal [1, 8], a.intersection(b,c)
end
assert("Array#flatten") do
[1, 2, "3", {4=>5}, :'6'] == [1, 2, "3", {4=>5}, :'6'].flatten and
[1, 2, 3, 4, 5, 6] == [1, 2, [3, 4, 5], 6].flatten and
[1, 2, 3, 4, 5, 6] == [1, 2, [3, [4, 5], 6]].flatten and
[1, [2, [3, [4, [5, [6]]]]]] == [1, [2, [3, [4, [5, [6]]]]]].flatten(0) and
[1, 2, [3, [4, [5, [6]]]]] == [1, [2, [3, [4, [5, [6]]]]]].flatten(1) and
[1, 2, 3, [4, [5, [6]]]] == [1, [2, [3, [4, [5, [6]]]]]].flatten(2) and
[1, 2, 3, 4, [5, [6]]] == [1, [2, [3, [4, [5, [6]]]]]].flatten(3) and
[1, 2, 3, 4, 5, [6]] == [1, [2, [3, [4, [5, [6]]]]]].flatten(4) and
[1, 2, 3, 4, 5, 6] == [1, [2, [3, [4, [5, [6]]]]]].flatten(5)
assert_equal [1, 2, "3", {4=>5}, :'6'], [1, 2, "3", {4=>5}, :'6'].flatten
assert_equal [1, 2, 3, 4, 5, 6], [1, 2, [3, 4, 5], 6].flatten
assert_equal [1, 2, 3, 4, 5, 6], [1, 2, [3, [4, 5], 6]].flatten
assert_equal [1, [2, [3, [4, [5, [6]]]]]], [1, [2, [3, [4, [5, [6]]]]]].flatten(0)
assert_equal [1, 2, [3, [4, [5, [6]]]]], [1, [2, [3, [4, [5, [6]]]]]].flatten(1)
assert_equal [1, 2, 3, [4, [5, [6]]]], [1, [2, [3, [4, [5, [6]]]]]].flatten(2)
assert_equal [1, 2, 3, 4, [5, [6]]], [1, [2, [3, [4, [5, [6]]]]]].flatten(3)
assert_equal [1, 2, 3, 4, 5, [6]], [1, [2, [3, [4, [5, [6]]]]]].flatten(4)
assert_equal [1, 2, 3, 4, 5, 6], [1, [2, [3, [4, [5, [6]]]]]].flatten(5)
end
assert("Array#flatten!") do
[1, 2, 3, 4, 5, 6] == [1, 2, [3, [4, 5], 6]].flatten!
assert_equal [1, 2, 3, 4, 5, 6], [1, 2, [3, [4, 5], 6]].flatten!
end
assert("Array#compact") do
a = [1, nil, "2", nil, :t, false, nil]
a.compact == [1, "2", :t, false] && a == [1, nil, "2", nil, :t, false, nil]
assert_equal [1, "2", :t, false], a.compact
assert_equal [1, nil, "2", nil, :t, false, nil], a
end
assert("Array#compact!") do
a = [1, nil, "2", nil, :t, false, nil]
a.compact!
a == [1, "2", :t, false]
assert_equal [1, "2", :t, false], a
end
assert("Array#[]") do
a = [ "a", "b", "c", "d", "e" ]
a[1.1] == "b" and
a[1,2] == ["b", "c"] and
a[1..-2] == ["b", "c", "d"]
assert("Array#fetch") do
a = [ 11, 22, 33, 44 ]
assert_equal 22, a.fetch(1)
assert_equal 44, a.fetch(-1)
assert_equal 'cat', a.fetch(4, 'cat')
ret = 0
a.fetch(100) { |i| ret = i }
assert_equal 100, ret
assert_raise(IndexError) { a.fetch(100) }
end
assert("Array#fill") do
a = [ "a", "b", "c", "d" ]
assert_equal ["x", "x", "x", "x"], a.fill("x")
assert_equal ["x", "x", "x", "w"], a.fill("w", -1)
assert_equal ["x", "x", "z", "z"], a.fill("z", 2, 2)
assert_equal ["y", "y", "z", "z"], a.fill("y", 0..1)
assert_equal [0, 1, 4, 9], a.fill { |i| i*i }
assert_equal [0, 1, 8, 27], a.fill(-2) { |i| i*i*i }
assert_equal [0, 2, 3, 27], a.fill(1, 2) { |i| i+1 }
assert_equal [1, 2, 3, 27], a.fill(0..1) { |i| i+1 }
assert_raise(ArgumentError) { a.fill }
assert_equal([0, 1, 2, 3, -1, 5], [0, 1, 2, 3, 4, 5].fill(-1, -2, 1))
assert_equal([0, 1, 2, 3, -1, -1, -1], [0, 1, 2, 3, 4, 5].fill(-1, -2, 3))
assert_equal([0, 1, 2, -1, -1, 5], [0, 1, 2, 3, 4, 5].fill(-1, 3..4))
assert_equal([0, 1, 2, -1, 4, 5], [0, 1, 2, 3, 4, 5].fill(-1, 3...4))
assert_equal([0, 1, -1, -1, -1, 5], [0, 1, 2, 3, 4, 5].fill(-1, 2..-2))
assert_equal([0, 1, -1, -1, 4, 5], [0, 1, 2, 3, 4, 5].fill(-1, 2...-2))
assert_equal([0, 1, 2, 13, 14, 5], [0, 1, 2, 3, 4, 5].fill(3..4){|i| i+10})
assert_equal([0, 1, 2, 13, 4, 5], [0, 1, 2, 3, 4, 5].fill(3...4){|i| i+10})
assert_equal([0, 1, 12, 13, 14, 5], [0, 1, 2, 3, 4, 5].fill(2..-2){|i| i+10})
assert_equal([0, 1, 12, 13, 4, 5], [0, 1, 2, 3, 4, 5].fill(2...-2){|i| i+10})
assert_equal [1, 2, 3, 4, 'x', 'x'], [1, 2, 3, 4, 5, 6].fill('x', -2..-1)
assert_equal [1, 2, 3, 4, 'x', 6], [1, 2, 3, 4, 5, 6].fill('x', -2...-1)
assert_equal [1, 2, 3, 4, 5, 6], [1, 2, 3, 4, 5, 6].fill('x', -2...-2)
assert_equal [1, 2, 3, 4, 'x', 6], [1, 2, 3, 4, 5, 6].fill('x', -2..-2)
assert_equal [1, 2, 3, 4, 5, 6], [1, 2, 3, 4, 5, 6].fill('x', -2..0)
end
assert("Array#reverse_each") do
a = [ "a", "b", "c", "d" ]
b = []
a.reverse_each do |i|
b << i
end
assert_equal [ "d", "c", "b", "a" ], b
if Object.const_defined?(:Enumerator)
assert_equal [ "d", "c", "b", "a" ], a.reverse_each.to_a
else
true
end
end
assert("Array#rotate") do
a = ["a", "b", "c", "d"]
assert_equal ["b", "c", "d", "a"], a.rotate
assert_equal ["a", "b", "c", "d"], a
assert_equal ["c", "d", "a", "b"], a.rotate(2)
assert_equal ["b", "c", "d", "a"], a.rotate(-3)
assert_equal ["c", "d", "a", "b"], a.rotate(10)
assert_equal [], [].rotate
end
assert("Array#rotate!") do
a = ["a", "b", "c", "d"]
assert_equal ["b", "c", "d", "a"], a.rotate!
assert_equal ["b", "c", "d", "a"], a
assert_equal ["d", "a", "b", "c"], a.rotate!(2)
assert_equal ["a", "b", "c", "d"], a.rotate!(-3)
assert_equal ["c", "d", "a", "b"], a.rotate(10)
assert_equal [], [].rotate!
end
assert("Array#delete_if") do
a = [1, 2, 3, 4, 5]
assert_equal [1, 2, 3, 4, 5], a.delete_if { false }
assert_equal [1, 2, 3, 4, 5], a
a = [1, 2, 3, 4, 5]
assert_equal [], a.delete_if { true }
assert_equal [], a
a = [1, 2, 3, 4, 5]
assert_equal [1, 2, 3], a.delete_if { |i| i > 3 }
assert_equal [1, 2, 3], a
end
assert("Array#reject!") do
a = [1, 2, 3, 4, 5]
assert_nil a.reject! { false }
assert_equal [1, 2, 3, 4, 5], a
a = [1, 2, 3, 4, 5]
assert_equal [], a.reject! { true }
assert_equal [], a
a = [1, 2, 3, 4, 5]
assert_equal [1, 2, 3], a.reject! { |val| val > 3 }
assert_equal [1, 2, 3], a
end
assert("Array#insert") do
a = ["a", "b", "c", "d"]
assert_equal ["a", "b", 99, "c", "d"], a.insert(2, 99)
assert_equal ["a", "b", 99, "c", 1, 2, 3, "d"], a.insert(-2, 1, 2, 3)
b = ["a", "b", "c", "d"]
assert_equal ["a", "b", "c", "d", nil, nil, 99], b.insert(6, 99)
end
assert("Array#bsearch") do
# Find minimum mode
a = [0, 2, 4]
assert_equal 0, a.bsearch{ |x| x >= -1 }
assert_equal 0, a.bsearch{ |x| x >= 0 }
assert_equal 2, a.bsearch{ |x| x >= 1 }
assert_equal 2, a.bsearch{ |x| x >= 2 }
assert_equal 4, a.bsearch{ |x| x >= 3 }
assert_equal 4, a.bsearch{ |x| x >= 4 }
assert_nil a.bsearch{ |x| x >= 5 }
# Find any mode
a = [0, 4, 8]
def between(lo, x, hi)
if x < lo
1
elsif x > hi
-1
else
0
end
end
assert_nil a.bsearch{ |x| between(-3, x, -1) }
assert_equal 0, a.bsearch{ |x| between(-1, x, 1) }
assert_nil a.bsearch{ |x| between( 1, x, 3) }
assert_equal 4, a.bsearch{ |x| between( 3, x, 5) }
assert_nil a.bsearch{ |x| between( 5, x, 7) }
assert_equal 8, a.bsearch{ |x| between( 7, x, 9) }
assert_nil a.bsearch{ |x| between( 9, x, 11) }
assert_equal 0, a.bsearch{ |x| between( 0, x, 3) }
assert_equal 4, a.bsearch{ |x| between( 0, x, 4) }
assert_equal 4, a.bsearch{ |x| between( 4, x, 8) }
assert_equal 8, a.bsearch{ |x| between( 5, x, 8) }
# Invalid block result
assert_raise TypeError, 'invalid block result (must be numeric, true, false or nil)' do
a.bsearch{ 'I like to watch the world burn' }
end
end
# tested through Array#bsearch
#assert("Array#bsearch_index") do
#end
assert("Array#delete_if") do
a = [1, 2, 3, 4, 5]
assert_equal [1, 2, 3, 4, 5], a.delete_if { false }
assert_equal [1, 2, 3, 4, 5], a
a = [1, 2, 3, 4, 5]
assert_equal [], a.delete_if { true }
assert_equal [], a
a = [ 1, 2, 3, 4, 5 ]
assert_equal [1, 2, 3], a.delete_if { |val| val > 3 }
end
assert("Array#keep_if") do
a = [1, 2, 3, 4, 5]
assert_equal [1, 2, 3, 4, 5], a.keep_if { true }
assert_equal [1, 2, 3, 4, 5], a
a = [1, 2, 3, 4, 5]
assert_equal [], a.keep_if { false }
assert_equal [], a
a = [1, 2, 3, 4, 5]
assert_equal [4, 5], a.keep_if { |val| val > 3 }
assert_equal [4, 5], a
end
assert("Array#select!") do
a = [1, 2, 3, 4, 5]
assert_nil a.select! { true }
assert_equal [1, 2, 3, 4, 5], a
a = [1, 2, 3, 4, 5]
assert_equal [], a.select! { false }
assert_equal [], a
a = [1, 2, 3, 4, 5]
assert_equal [4, 5], a.select! { |val| val > 3 }
assert_equal [4, 5], a
end
assert('Array#values_at') do
a = %w{red green purple white none}
assert_equal %w{red purple none}, a.values_at(0, 2, 4)
assert_equal ['green', 'white', nil, nil], a.values_at(1, 3, 5, 7)
assert_equal ['none', 'white', 'white', nil], a.values_at(-1, -2, -2, -7)
assert_equal ['none', nil, nil, 'red', 'green', 'purple'], a.values_at(4..6, 0...3)
assert_raise(TypeError) { a.values_at 'tt' }
end
assert('Array#to_h') do
assert_equal({}, [].to_h)
assert_equal({a: 1, b:2}, [[:a, 1], [:b, 2]].to_h)
assert_raise(TypeError) { [1].to_h }
assert_raise(ArgumentError) { [[1]].to_h }
end
assert("Array#index (block)") do
assert_nil (1..10).to_a.index { |i| i % 5 == 0 and i % 7 == 0 }
assert_equal 34, (1..100).to_a.index { |i| i % 5 == 0 and i % 7 == 0 }
end
assert("Array#dig") do
h = [[[1]], 0]
assert_equal(1, h.dig(0, 0, 0))
assert_nil(h.dig(2, 0))
assert_raise(TypeError) {h.dig(:a)}
end
assert("Array#slice!") do
a = [1, 2, 3]
b = a.slice!(0)
c = [1, 2, 3, 4, 5]
d = c.slice!(0, 2)
e = [1, 2, 3, 4, 5]
f = e.slice!(1..3)
g = [1, 2, 3]
h = g.slice!(-1)
i = [1, 2, 3]
j = i.slice!(0, -1)
assert_equal(a, [2, 3])
assert_equal(b, 1)
assert_equal(c, [3, 4, 5])
assert_equal(d, [1, 2])
assert_equal(e, [1, 5])
assert_equal(f, [2, 3, 4])
assert_equal(g, [1, 2])
assert_equal(h, 3)
assert_equal(i, [1, 2, 3])
assert_equal(j, nil)
end
assert("Array#permutation") do
a = [1, 2, 3]
assert_permutation([[1,2,3],[1,3,2],[2,1,3],[2,3,1],[3,1,2],[3,2,1]], a)
assert_permutation([[1],[2],[3]], a, 1)
assert_permutation([[1,2],[1,3],[2,1],[2,3],[3,1],[3,2]], a, 2)
assert_permutation([[1,2,3],[1,3,2],[2,1,3],[2,3,1],[3,1,2],[3,2,1]], a, 3)
assert_permutation([[]], a, 0)
assert_permutation([], a, 4)
assert_permutation([], a, -1)
end
assert("Array#combination") do
a = [1, 2, 3, 4]
assert_combination([[1],[2],[3],[4]], a, 1)
assert_combination([[1,2],[1,3],[1,4],[2,3],[2,4],[3,4]], a, 2)
assert_combination([[1,2,3],[1,2,4],[1,3,4],[2,3,4]], a, 3)
assert_combination([[1,2,3,4]], a, 4)
assert_combination([[]], a, 0)
assert_combination([], a, 5)
assert_combination([], a, -1)
end
assert('Array#transpose') do
assert_equal([].transpose, [])
assert_equal([[]].transpose, [])
assert_equal([[1]].transpose, [[1]])
assert_equal([[1,2,3]].transpose, [[1], [2], [3]])
assert_equal([[1], [2], [3]].transpose, [[1,2,3]])
assert_equal([[1,2], [3,4], [5,6]].transpose, [[1,3,5], [2,4,6]])
assert_raise(TypeError) { [1].transpose }
assert_raise(IndexError) { [[1], [2,3,4]].transpose }
end
+23
View File
@@ -0,0 +1,23 @@
unless MRuby::Build.current.kind_of?(MRuby::CrossBuild)
MRuby::Gem::Specification.new('mruby-bin-config') do |spec|
name = 'mruby-config'
spec.license = 'MIT'
spec.author = 'mruby developers'
spec.summary = "#{name} command"
mruby_config = name + (ENV['OS'] == 'Windows_NT' ? '.bat' : '')
mruby_config_path = "#{build.build_dir}/bin/#{mruby_config}"
make_cfg = "#{build.build_dir}/lib/libmruby.flags.mak"
tmplt_path = "#{__dir__}/#{mruby_config}"
build.bins << mruby_config
file mruby_config_path => [make_cfg, tmplt_path] do |t|
config = Hash[File.readlines(make_cfg).map!(&:chomp).map! {|l|
l.gsub('\\"', '"').split(' = ', 2).map! {|s| s.sub(/^(?=.)/, 'echo ')}
}]
tmplt = File.read(tmplt_path)
File.write(t.name, tmplt.gsub(/(#{Regexp.union(*config.keys)})\b/, config))
FileUtils.chmod(0755, t.name)
end
end
end
+20
View File
@@ -0,0 +1,20 @@
#!/bin/sh
while [ $# -gt 0 ]; do
case $1 in
--cflags) echo MRUBY_CFLAGS;;
--ldflags) echo MRUBY_LDFLAGS;;
--ldflags-before-libs) echo MRUBY_LDFLAGS_BEFORE_LIBS;;
--libs) echo MRUBY_LIBS;;
--libmruby-path) echo MRUBY_LIBMRUBY_PATH;;
--help) echo "Usage: mruby-config [switches]"
echo " switches:"
echo " --cflags print flags passed to compiler"
echo " --ldflags print flags passed to linker"
echo " --ldflags-before-libs print flags passed to linker before linked libraries"
echo " --libs print linked libraries"
echo " --libmruby-path print libmruby path"
exit 0;;
esac
shift
done
+42
View File
@@ -0,0 +1,42 @@
@echo off
:top
shift
if "%0" equ "" goto :eof
if "%0" equ "--cflags" goto cflags
if "%0" equ "--ldflags" goto ldflags
if "%0" equ "--ldflags-before-libs" goto ldflagsbeforelibs
if "%0" equ "--libs" goto libs
if "%0" equ "--libmruby-path" goto libmrubypath
if "%0" equ "--help" goto showhelp
echo Invalid Option
goto :eof
:cflags
echo MRUBY_CFLAGS
goto top
:libs
echo MRUBY_LIBS
goto top
:ldflags
echo MRUBY_LDFLAGS
goto top
:ldflagsbeforelibs
echo MRUBY_LDFLAGS_BEFORE_LIBS
goto top
:libmrubypath
echo MRUBY_LIBMRUBY_PATH
goto top
:showhelp
echo Usage: mruby-config [switches]
echo switches:
echo --cflags print flags passed to compiler
echo --ldflags print flags passed to linker
echo --ldflags-before-libs print flags passed to linker before linked libraries
echo --libs print linked libraries
echo --libmruby-path print libmruby path
+286
View File
@@ -0,0 +1,286 @@
require 'open3'
require 'tempfile'
class BinTest_MrubyBinDebugger
@debug1=false
@debug2=true
@debug3=true
def self.test(rubysource, testcase)
script, bin = Tempfile.new(['test', '.rb']), Tempfile.new(['test', '.mrb'])
# .rb
script.write rubysource
script.flush
# compile
`./bin/mrbc -g -o "#{bin.path}" "#{script.path}"`
# add mrdb quit
testcase << {:cmd=>"quit"}
stdin_data = testcase.map{|t| t[:cmd]}.join("\n") << "\n"
["bin/mrdb #{script.path}","bin/mrdb -b #{bin.path}"].each do |cmd|
o, s = Open3.capture2(cmd, :stdin_data => stdin_data)
exp_vals = testcase.map{|t| t.fetch(:exp, nil)}
unexp_vals = testcase.map{|t| t.fetch(:unexp, nil)}
if @debug1
o.split("\n").each_with_index do |i,actual|
p [i,actual]
end
end
# compare actual / expected
o.split("\n").each do |actual|
next if actual.empty?
exp = exp_vals.shift
if @debug2
a = true
a = actual.include?(exp) unless exp.nil?
p [actual, exp] unless a
end
assert_true actual.include?(exp) unless exp.nil?
end
# compare actual / unexpected
o.split("\n").each do |actual|
next if actual.empty?
unexp = unexp_vals.shift
if @debug3
a = false
a = actual.include?(unexp) unless unexp.nil?
p [actual, unexp] if a
end
assert_false actual.include?(unexp) unless unexp.nil?
end
end
end
end
INVCMD = "invalid command"
assert('mruby-bin-debugger(mrdb) command line') do
# ruby source
src = "foo = 'foo'\n"
str = ""
103.times {
str += "1234567890"
}
cmd = "p a=#{str}"
# test case
BinTest_MrubyBinDebugger.test(src, [{:cmd=>cmd[0...1023], :unexp=>'command line too long.'}])
BinTest_MrubyBinDebugger.test(src, [{:cmd=>cmd[0...1024], :unexp=>'command line too long.'}])
BinTest_MrubyBinDebugger.test(src, [{:cmd=>cmd[0...1025], :exp=>'command line too long.'}])
end
assert('mruby-bin-debugger(mrdb) command: "break"') do
# ruby source
src = "foo = 'foo'\n"
# test case
tc = []
tc << {:cmd=>"b", :unexp=>INVCMD}
tc << {:cmd=>"br", :unexp=>INVCMD}
tc << {:cmd=>"brea", :unexp=>INVCMD}
tc << {:cmd=>"break", :unexp=>INVCMD}
BinTest_MrubyBinDebugger.test(src, tc)
BinTest_MrubyBinDebugger.test(src, [{:cmd=>"bl", :exp=>INVCMD}])
BinTest_MrubyBinDebugger.test(src, [{:cmd=>"breaka", :exp=>INVCMD}])
end
assert('mruby-bin-debugger(mrdb) command: "continue"') do
# ruby source
src = "foo = 'foo'\n"
# test case
BinTest_MrubyBinDebugger.test(src, [{:cmd=>"c", :unexp=>INVCMD}])
BinTest_MrubyBinDebugger.test(src, [{:cmd=>"co", :unexp=>INVCMD}])
BinTest_MrubyBinDebugger.test(src, [{:cmd=>"continu", :unexp=>INVCMD}])
BinTest_MrubyBinDebugger.test(src, [{:cmd=>"continue", :unexp=>INVCMD}])
BinTest_MrubyBinDebugger.test(src, [{:cmd=>"cn", :exp=>INVCMD}])
BinTest_MrubyBinDebugger.test(src, [{:cmd=>"continuee", :exp=>INVCMD}])
end
assert('mruby-bin-debugger(mrdb) command: "delete"') do
# ruby source
src = "foo = 'foo'\n"
# test case
tc = []
tc << {:cmd=>"d 1", :unexp=>INVCMD}
tc << {:cmd=>"de 1", :unexp=>INVCMD}
tc << {:cmd=>"delet 1", :unexp=>INVCMD}
tc << {:cmd=>"delete 1", :unexp=>INVCMD}
BinTest_MrubyBinDebugger.test(src, tc)
BinTest_MrubyBinDebugger.test(src, [{:cmd=>"dd 1", :exp=>INVCMD}])
BinTest_MrubyBinDebugger.test(src, [{:cmd=>"deletee 1", :exp=>INVCMD}])
end
assert('mruby-bin-debugger(mrdb) command: "disable"') do
# ruby source
src = "foo = 'foo'\n"
# test case
tc = []
tc << {:cmd=>"dis", :unexp=>INVCMD}
tc << {:cmd=>"disa", :unexp=>INVCMD}
tc << {:cmd=>"disabl", :unexp=>INVCMD}
tc << {:cmd=>"disable", :unexp=>INVCMD}
BinTest_MrubyBinDebugger.test(src, tc)
BinTest_MrubyBinDebugger.test(src, [{:cmd=>"di", :exp=>INVCMD}])
BinTest_MrubyBinDebugger.test(src, [{:cmd=>"disb", :exp=>INVCMD}])
BinTest_MrubyBinDebugger.test(src, [{:cmd=>"disablee", :exp=>INVCMD}])
end
assert('mruby-bin-debugger(mrdb) command: "enable"') do
# ruby source
src = "foo = 'foo'\n"
# test case
tc = []
tc << {:cmd=>"en", :unexp=>INVCMD}
tc << {:cmd=>"ena", :unexp=>INVCMD}
tc << {:cmd=>"enabl", :unexp=>INVCMD}
tc << {:cmd=>"enable", :unexp=>INVCMD}
BinTest_MrubyBinDebugger.test(src, tc)
BinTest_MrubyBinDebugger.test(src, [{:cmd=>"e", :exp=>INVCMD}])
BinTest_MrubyBinDebugger.test(src, [{:cmd=>"enb", :exp=>INVCMD}])
BinTest_MrubyBinDebugger.test(src, [{:cmd=>"enablee", :exp=>INVCMD}])
end
assert('mruby-bin-debugger(mrdb) command: "eval"') do
# ruby source
src = "foo = 'foo'\n"
# test case
tc = []
tc << {:cmd=>"ev", :unexp=>INVCMD}
tc << {:cmd=>"eva", :unexp=>INVCMD}
tc << {:cmd=>"eval", :unexp=>INVCMD}
BinTest_MrubyBinDebugger.test(src, tc)
BinTest_MrubyBinDebugger.test(src, [{:cmd=>"e", :exp=>INVCMD}])
BinTest_MrubyBinDebugger.test(src, [{:cmd=>"evl", :exp=>INVCMD}])
BinTest_MrubyBinDebugger.test(src, [{:cmd=>"evall", :exp=>INVCMD}])
end
assert('mruby-bin-debugger(mrdb) command: "help"') do
# ruby source
src = "foo = 'foo'\n"
# test case
tc = []
tc << {:cmd=>"h", :unexp=>INVCMD}
tc << {:cmd=>"he", :unexp=>INVCMD}
tc << {:cmd=>"hel", :unexp=>INVCMD}
tc << {:cmd=>"help", :unexp=>INVCMD}
BinTest_MrubyBinDebugger.test(src, tc)
BinTest_MrubyBinDebugger.test(src, [{:cmd=>"hl", :exp=>INVCMD}])
BinTest_MrubyBinDebugger.test(src, [{:cmd=>"helpp", :exp=>INVCMD}])
end
assert('mruby-bin-debugger(mrdb) command: "info breakpoints"') do
# ruby source
src = "foo = 'foo'\n"
# test case
tc = []
tc << {:cmd=>"i b", :unexp=>INVCMD}
tc << {:cmd=>"in b", :unexp=>INVCMD}
tc << {:cmd=>"i br", :unexp=>INVCMD}
tc << {:cmd=>"inf breakpoint", :unexp=>INVCMD}
tc << {:cmd=>"info breakpoints", :unexp=>INVCMD}
BinTest_MrubyBinDebugger.test(src, tc)
BinTest_MrubyBinDebugger.test(src, [{:cmd=>"ii b", :exp=>INVCMD}])
BinTest_MrubyBinDebugger.test(src, [{:cmd=>"i bb", :exp=>INVCMD}])
BinTest_MrubyBinDebugger.test(src, [{:cmd=>"infoo breakpoints", :exp=>INVCMD}])
BinTest_MrubyBinDebugger.test(src, [{:cmd=>"info breakpointss", :exp=>INVCMD}])
end
assert('mruby-bin-debugger(mrdb) command: "list"') do
# ruby source
src = "foo = 'foo'\n"
# test case
tc = []
tc << {:cmd=>"l", :unexp=>INVCMD}
tc << {:cmd=>"li", :unexp=>INVCMD}
tc << {:cmd=>"lis", :unexp=>INVCMD}
tc << {:cmd=>"list", :unexp=>INVCMD}
BinTest_MrubyBinDebugger.test(src, tc)
BinTest_MrubyBinDebugger.test(src, [{:cmd=>"ll", :exp=>INVCMD}])
BinTest_MrubyBinDebugger.test(src, [{:cmd=>"listt", :exp=>INVCMD}])
end
assert('mruby-bin-debugger(mrdb) command: "print"') do
# ruby source
src = "foo = 'foo'\n"
# test case
tc = []
tc << {:cmd=>"p", :unexp=>INVCMD}
tc << {:cmd=>"pr", :unexp=>INVCMD}
tc << {:cmd=>"prin", :unexp=>INVCMD}
tc << {:cmd=>"print", :unexp=>INVCMD}
BinTest_MrubyBinDebugger.test(src, tc)
BinTest_MrubyBinDebugger.test(src, [{:cmd=>"pp", :exp=>INVCMD}])
BinTest_MrubyBinDebugger.test(src, [{:cmd=>"printt", :exp=>INVCMD}])
end
assert('mruby-bin-debugger(mrdb) command: "quit"') do
# ruby source
src = "foo = 'foo'\n"
# test case
BinTest_MrubyBinDebugger.test(src, [{:cmd=>"q", :unexp=>INVCMD}])
BinTest_MrubyBinDebugger.test(src, [{:cmd=>"qu", :unexp=>INVCMD}])
BinTest_MrubyBinDebugger.test(src, [{:cmd=>"qui", :unexp=>INVCMD}])
BinTest_MrubyBinDebugger.test(src, [{:cmd=>"quit", :unexp=>INVCMD}])
BinTest_MrubyBinDebugger.test(src, [{:cmd=>"qq", :exp=>INVCMD}])
BinTest_MrubyBinDebugger.test(src, [{:cmd=>"quitt", :exp=>INVCMD}])
end
assert('mruby-bin-debugger(mrdb) command: "run"') do
# ruby source
src = "foo = 'foo'\n"
# test case
BinTest_MrubyBinDebugger.test(src, [{:cmd=>"r", :unexp=>INVCMD}])
BinTest_MrubyBinDebugger.test(src, [{:cmd=>"ru", :unexp=>INVCMD}])
BinTest_MrubyBinDebugger.test(src, [{:cmd=>"run", :unexp=>INVCMD}])
BinTest_MrubyBinDebugger.test(src, [{:cmd=>"rr", :exp=>INVCMD}])
BinTest_MrubyBinDebugger.test(src, [{:cmd=>"runn", :exp=>INVCMD}])
end
assert('mruby-bin-debugger(mrdb) command: "step"') do
# ruby source
src = <<"SRC"
while true
foo = 'foo'
end
SRC
# test case
tc = []
tc << {:cmd=>"s", :unexp=>INVCMD}
tc << {:cmd=>"st", :unexp=>INVCMD}
tc << {:cmd=>"ste", :unexp=>INVCMD}
tc << {:cmd=>"step", :unexp=>INVCMD}
BinTest_MrubyBinDebugger.test(src, tc)
BinTest_MrubyBinDebugger.test(src, [{:cmd=>"ss", :exp=>INVCMD}])
BinTest_MrubyBinDebugger.test(src, [{:cmd=>"stepp", :exp=>INVCMD}])
end
+701
View File
@@ -0,0 +1,701 @@
require 'open3'
require 'tempfile'
class BinTest_MrubyBinDebugger
@debug1=false
@debug2=true
def self.test(rubysource, testcase)
script, bin = Tempfile.new(['test', '.rb']), Tempfile.new(['test', '.mrb'])
# .rb
script.write rubysource
script.flush
# compile
`./bin/mrbc -g -o "#{bin.path}" "#{script.path}"`
# add mrdb quit
testcase << {:cmd=>"quit"}
stdin_data = testcase.map{|t| t[:cmd]}.join("\n") << "\n"
["bin/mrdb #{script.path}","bin/mrdb -b #{bin.path}"].each do |cmd|
o, s = Open3.capture2(cmd, :stdin_data => stdin_data)
exp_vals = testcase.map{|t| t.fetch(:exp, nil)}
=begin
if @debug1
o.split("\n").each_with_index do |i,actual|
p [i,actual]
end
end
# compare actual / expected
o.split("\n").each do |actual|
next if actual.empty?
exp = exp_vals.shift
if @debug2
a = true
a = actual.include?(exp) unless exp.nil?
p [actual, exp] unless a
end
assert_true actual.include?(exp) unless exp.nil?
end
=end
idx = 0
exp_vals.each do |exp|
next if exp.nil?
idx = o.index(exp, idx)
assert_false idx.nil?
break unless idx
idx += 1
end
end
end
end
assert('mruby-bin-debugger(print) invalid arguments') do
# ruby source
src = "foo = 'foo'\n"
# test case
tc = []
tc << {:cmd=>"p", :exp=>"Parameter not specified."}
BinTest_MrubyBinDebugger.test(src, tc)
end
assert('mruby-bin-debugger(print) nomal') do
# ruby source
src = <<"SRC"
foo = 'foo'
bar = foo
baz = bar
SRC
# test case
tc = []
tc << {:cmd=>"s"}
tc << {:cmd=>"p (1+2)", :exp=>'$1 = 3'}
tc << {:cmd=>"p foo", :exp=>'$2 = "foo"'}
tc << {:cmd=>"p foo*=2", :exp=>'$3 = "foofoo"'}
tc << {:cmd=>"s"}
tc << {:cmd=>"p bar", :exp=>'$4 = "foofoo"'}
BinTest_MrubyBinDebugger.test(src, tc)
end
assert('mruby-bin-debugger(print) error') do
# ruby source
src = "foo = 'foo'\n"
# test case
tc = []
tc << {:cmd=>"p (1+2", :exp=>'$1 = SyntaxError'}
tc << {:cmd=>"p bar", :exp=>'$2 = (eval):2: undefined method'}
BinTest_MrubyBinDebugger.test(src, tc)
end
# Kernel#instance_eval(string) does't work multiple statements.
=begin
assert('mruby-bin-debugger(print) multiple statements') do
# ruby source
src = <<"SRC"
x = 0
y = 0
z = 0
SRC
# test case
tc = []
tc << {:cmd=>"s",}
tc << {:cmd=>"p x=1;x+=2", :exp=>"3"}
tc << {:cmd=>"s",}
tc << {:cmd=>"p x", :exp=>"3"}
BinTest_MrubyBinDebugger.test(src, tc)
end
=end
assert('mruby-bin-debugger(print) scope:top') do
# ruby source (bp is break point)
src = "bp=nil\n"
# test case
tc = []
tc << {:cmd=>"p self", :exp=>'$1 = main'}
BinTest_MrubyBinDebugger.test(src, tc)
end
assert('mruby-bin-debugger(print) scope:class') do
# ruby source (bp is break point)
src = <<"SRC"
class TestClassScope
bp = nil
end
SRC
# test case
tc = []
tc << {:cmd=>"s"}
tc << {:cmd=>"p self", :exp=>'$1 = TestClassScope'}
BinTest_MrubyBinDebugger.test(src, tc)
end
assert('mruby-bin-debugger(print) scope:module') do
# ruby source (bp is break point)
src = <<"SRC"
class TestModuleScope
bp = nil
end
SRC
# test case
tc = []
tc << {:cmd=>"s"}
tc << {:cmd=>"p self", :exp=>'$1 = TestModuleScope'}
BinTest_MrubyBinDebugger.test(src, tc)
end
assert('mruby-bin-debugger(print) scope:instance method') do
# ruby source (bp is break point)
src = <<"SRC"
class TestMethodScope
def m
bp = nil
end
end
TestMethodScope.new.m
SRC
tc = []
tc << {:cmd=>"b 3"}
tc << {:cmd=>"r"}
tc << {:cmd=>"p self", :exp=>'$1 = #<TestMethodScope:'}
BinTest_MrubyBinDebugger.test(src, tc)
end
assert('mruby-bin-debugger(print) scope:class method') do
# ruby source (bp is break point)
src = <<"SRC"
class TestClassMethodScope
def self.cm
bp = nil
end
end
TestClassMethodScope.cm
SRC
tc = []
tc << {:cmd=>"b 3"}
tc << {:cmd=>"r"}
tc << {:cmd=>"p self", :exp=>'$1 = TestClassMethodScope'}
BinTest_MrubyBinDebugger.test(src, tc)
end
assert('mruby-bin-debugger(print) scope:block') do
# ruby source (bp is break point)
src = <<"SRC"
1.times do
bp = nil
end
class TestBlockScope
1.times do
bp = nil
end
def m
1.times do
bp = nil
end
end
end
TestBlockScope.new.m
SRC
tc = []
tc << {:cmd=>"b 2"}
tc << {:cmd=>"b 6"}
tc << {:cmd=>"b 10"}
tc << {:cmd=>"c"}
tc << {:cmd=>"p self", :exp=>'$1 = main'}
tc << {:cmd=>"c"}
tc << {:cmd=>"p self", :exp=>'$2 = TestBlockScope'}
tc << {:cmd=>"c"}
tc << {:cmd=>"p self", :exp=>'$3 = #<TestBlockScope:'}
BinTest_MrubyBinDebugger.test(src, tc)
end
assert('mruby-bin-debugger(print) same name:local variabe') do
# ruby source (bp is break point)
src = <<"SRC"
lv = 'top'
class TestLocalVariableName
lv = 'class'
def m
lv = 'instance method'
bp = nil
end
bp = nil
end
TestLocalVariableName.new.m
bp = nil
SRC
tc = []
tc << {:cmd=>"b 6"}
tc << {:cmd=>"b 8"}
tc << {:cmd=>"b 11"}
tc << {:cmd=>"r"}
tc << {:cmd=>"p lv", :exp=>'$1 = "class"'}
tc << {:cmd=>"c"}
tc << {:cmd=>"p lv", :exp=>'$2 = "instance method"'}
tc << {:cmd=>"c"}
tc << {:cmd=>"p lv", :exp=>'$3 = "top"'}
BinTest_MrubyBinDebugger.test(src, tc)
end
assert('mruby-bin-debugger(print) same name:instance variabe') do
# ruby source (bp is break point)
src = <<"SRC"
@iv = 'top'
class TestInstanceVariableName
def initialize(v)
@iv = v
end
def m
bp = nil
end
end
i1 = TestInstanceVariableName.new('instance1')
i2 = TestInstanceVariableName.new('instance2')
i1.m
i2.m
bp = nil
SRC
tc = []
tc << {:cmd=>"b 7"}
tc << {:cmd=>"b 14"}
tc << {:cmd=>"r"}
tc << {:cmd=>"p @iv", :exp=>'$1 = "instance1"'}
tc << {:cmd=>"c"}
tc << {:cmd=>"p @iv", :exp=>'$2 = "instance2"'}
tc << {:cmd=>"c"}
tc << {:cmd=>"p @iv", :exp=>'$3 = "top"'}
BinTest_MrubyBinDebugger.test(src, tc)
end
# Kernel#instance_eval(string) does't work const.
=begin
assert('mruby-bin-debugger(print) same name:const') do
# ruby source (bp is break point)
src = <<"SRC"
CONST='top'
class TestConstNameSuperClass
CONST='super class'
def m
bp = nil
end
end
class TestConstNameSubClass < TestConstNameSuperClass
CONST='sub class'
def m
bp = nil
end
end
TestConstNameSuperClass.new.m()
TestConstNameSubClass.new.m()
bp = nil
SRC
# todo: wait for 'break' to be implemented
tc = []
9.times { tc << {:cmd=>"s"} }
tc << {:cmd=>"p CONST", :exp=>"super class"}
3.times { tc << {:cmd=>"s"} }
tc << {:cmd=>"p CONST", :exp=>"sub class"}
1.times { tc << {:cmd=>"s"} }
tc << {:cmd=>"p CONST", :exp=>"top"}
BinTest_MrubyBinDebugger.test(src, tc)
end
=end
assert('mruby-bin-debugger(print) Literal:Numeric') do
# ruby source
src = "foo = 'foo'\n"
# test case
tc = []
tc << {:cmd=>"p 100", :exp=>'$1 = 100'}
tc << {:cmd=>"p -0b100", :exp=>'$2 = -4'}
tc << {:cmd=>"p +0100", :exp=>'$3 = 64'}
tc << {:cmd=>"p 0x100", :exp=>'$4 = 256'}
tc << {:cmd=>"p 1_234", :exp=>'$5 = 1234'}
tc << {:cmd=>"p 0b1000_0000", :exp=>"$6 = #{0b1000_0000}"}
tc << {:cmd=>"p 0x1000_0000", :exp=>"$7 = #{0x1000_0000}"}
tc << {:cmd=>"p 3.14", :exp=>'$8 = 3.14'}
tc << {:cmd=>"p -12.3", :exp=>'$9 = -12.3'}
tc << {:cmd=>"p +12.000", :exp=>'$10 = 12'}
tc << {:cmd=>"p 1e4", :exp=>'$11 = 10000'}
tc << {:cmd=>"p -0.1e-2", :exp=>'$12 = -0.001'}
BinTest_MrubyBinDebugger.test(src, tc)
end
assert('mruby-bin-debugger(print) Literal:String') do
# ruby source
src = <<"SRC"
foo = 'foo'
bar = "bar"
baz = "baz"
SRC
# test case
tc = []
tc << {:cmd=>"s"}
tc << {:cmd=>"s"}
tc << {:cmd=>'p "str"', :exp=>'$1 = "str"'}
tc << {:cmd=>'p "s\tt\rr\n"', :exp=>'$2 = "s\\tt\\rr\\n"'}
tc << {:cmd=>'p "\C-a\C-z"', :exp=>'$3 = "\\x01\\x1a"'}
tc << {:cmd=>'p "#{foo+bar}"', :exp=>'$4 = "foobar"'}
tc << {:cmd=>'p \'str\'', :exp=>'$5 = "str"'}
tc << {:cmd=>'p \'s\\tt\\rr\\n\'', :exp=>'$6 = "s\\\\tt\\\\rr\\\\n"'}
tc << {:cmd=>'p \'\\C-a\\C-z\'', :exp=>'$7 = "\\\\C-a\\\\C-z"'}
tc << {:cmd=>'p \'#{foo+bar}\'', :exp=>'$8 = "\\#{foo+bar}"'}
tc << {:cmd=>'p %!str!', :exp=>'$9 = "str"'}
tc << {:cmd=>'p %!s\tt\rr\n!', :exp=>'$10 = "s\\tt\\rr\\n"'}
tc << {:cmd=>'p %!\C-a\C-z!', :exp=>'$11 = "\\x01\\x1a"'}
tc << {:cmd=>'p %!#{foo+bar}!', :exp=>'$12 = "foobar"'}
tc << {:cmd=>'p %Q!str!', :exp=>'$13 = "str"'}
tc << {:cmd=>'p %Q!s\tt\rr\n!', :exp=>'$14 = "s\\tt\\rr\\n"'}
tc << {:cmd=>'p %Q!\C-a\C-z!', :exp=>'$15 = "\\x01\\x1a"'}
tc << {:cmd=>'p %Q!#{foo+bar}!', :exp=>'$16 = "foobar"'}
tc << {:cmd=>'p %q!str!', :exp=>'$17 = "str"'}
tc << {:cmd=>'p %q!s\\tt\\rr\\n!', :exp=>'$18 = "s\\\\tt\\\\rr\\\\n"'}
tc << {:cmd=>'p %q!\\C-a\\C-z!', :exp=>'$19 = "\\\\C-a\\\\C-z"'}
tc << {:cmd=>'p %q!#{foo+bar}!', :exp=>'$20 = "\\#{foo+bar}"'}
BinTest_MrubyBinDebugger.test(src, tc)
end
assert('mruby-bin-debugger(print) Literal:Array') do
# ruby source
src = <<"SRC"
foo = 'foo'
bar = "bar"
baz = "baz"
SRC
# test case
tc = []
tc << {:cmd=>"s"}
tc << {:cmd=>"s"}
tc << {:cmd=>'p []', :exp=>'$1 = []'}
tc << {:cmd=>'p [ 5, 12, 8, 10, ]', :exp=>'$2 = [5, 12, 8, 10]'}
tc << {:cmd=>'p [1,2.5,"#{foo+bar}"]', :exp=>'$3 = [1, 2.5, "foobar"]'}
tc << {:cmd=>'p %w[3.14 A\ &\ B #{foo}]', :exp=>'$4 = ["3.14", "A & B", "\#{foo}"]'}
tc << {:cmd=>'p %W[3.14 A\ &\ B #{foo}]', :exp=>'$5 = ["3.14", "A & B", "foo"]'}
BinTest_MrubyBinDebugger.test(src, tc)
end
assert('mruby-bin-debugger(print) Literal:Hash') do
# ruby source
src = <<"SRC"
foo = 'foo'
bar = "bar"
baz = "baz"
SRC
# test case
tc = []
tc << {:cmd=>"s"}
tc << {:cmd=>"s"}
tc << {:cmd=>'p {}', :exp=>'$1 = {}'}
tc << {:cmd=>'p {"one"=>1,"two"=>2}', :exp=>'$2 = {"one"=>1, "two"=>2}'}
tc << {:cmd=>'p {:eins=>"1", :zwei=>"2", }', :exp=>'$3 = {:eins=>"1", :zwei=>"2"}'}
tc << {:cmd=>'p {uno:"one", dos: 2}', :exp=>'$4 = {:uno=>"one", :dos=>2}'}
tc << {:cmd=>'p {"one"=>1, :zwei=>2, tres:3}', :exp=>'$5 = {"one"=>1, :zwei=>2, :tres=>3}'}
tc << {:cmd=>'p {:foo=>"#{foo}",:bar=>"#{bar}"}', :exp=>'$6 = {:foo=>"foo", :bar=>"bar"}'}
BinTest_MrubyBinDebugger.test(src, tc)
end
assert('mruby-bin-debugger(print) Literal:Range') do
# ruby source
src = "foo = 'foo'\n"
# test case
tc = []
tc << {:cmd=>'p 1..10', :exp=>'$1 = 1..10'}
tc << {:cmd=>'p 1...10', :exp=>'$2 = 1...10'}
tc << {:cmd=>'p 100..10', :exp=>'$3 = 100..10'}
tc << {:cmd=>'p 1 ... 10', :exp=>'$4 = 1...10'}
tc << {:cmd=>'p "1" .. "9"', :exp=>'$5 = "1".."9"'}
tc << {:cmd=>'p "A" ... "Z"', :exp=>'$6 = "A"..."Z"'}
BinTest_MrubyBinDebugger.test(src, tc)
end
assert('mruby-bin-debugger(print) Literal:Symbol') do
# ruby source
src = <<"SRC"
foo = 'foo'
bar = "bar"
baz = "baz"
SRC
# test case
tc = []
tc << {:cmd=>"s"}
tc << {:cmd=>"s"}
tc << {:cmd=>'p :sym', :exp=>'$1 = :sym'}
tc << {:cmd=>'p :"sd"', :exp=>'$2 = :sd'}
tc << {:cmd=>"p :'ss'", :exp=>'$3 = :ss'}
tc << {:cmd=>'p :"123"', :exp=>'$4 = :"123"'}
tc << {:cmd=>'p :"#{foo} baz"', :exp=>'$5 = :"foo baz"'}
tc << {:cmd=>'p %s!symsym!', :exp=>'$6 = :symsym'}
BinTest_MrubyBinDebugger.test(src, tc)
end
assert('mruby-bin-debugger(print) Unary operation') do
# ruby source
src = "foo = 'foo'\n"
# test case
tc = []
tc << {:cmd=>'p +10', :exp=>'$1 = 10'}
tc << {:cmd=>'p -100', :exp=>'$2 = -100'}
tc << {:cmd=>'p !true', :exp=>'$3 = false'}
tc << {:cmd=>'p !false', :exp=>'$4 = true'}
tc << {:cmd=>'p !nil', :exp=>'$5 = true'}
tc << {:cmd=>'p !1', :exp=>'$6 = false'}
BinTest_MrubyBinDebugger.test(src, tc)
end
assert('mruby-bin-debugger(print) Binary operation') do
# ruby source
src = <<"SRC"
CONST = 100
a,b,c = 1, 5, 8
foo,bar,baz = 'foo','bar','baz'
ary = []
SRC
# test case
tc = []
tc << {:cmd=>'s'}
tc << {:cmd=>'s'}
tc << {:cmd=>'s'}
tc << {:cmd=>'p a+1', :exp=>'$1 = 2'}
tc << {:cmd=>'p 2-b', :exp=>'$2 = -3'}
tc << {:cmd=>'p c * 3', :exp=>'$3 = 24'}
tc << {:cmd=>'p a/b', :exp=>'$4 = 0.2'}
tc << {:cmd=>'p c%b', :exp=>'$5 = 3'}
tc << {:cmd=>'p 2**10', :exp=>'$6 = 1024'}
tc << {:cmd=>'p ~3', :exp=>'$7 = -4'}
tc << {:cmd=>'p 1<<2', :exp=>'$8 = 4'}
tc << {:cmd=>'p 64>>5', :exp=>'$9 = 2'}
tc << {:cmd=>'p a|c', :exp=>'$10 = 9'}
tc << {:cmd=>'p a&b', :exp=>'$11 = 1'}
tc << {:cmd=>'p a^b', :exp=>'$12 = 4'}
tc << {:cmd=>'p a>b', :exp=>'$13 = false'}
tc << {:cmd=>'p a<b', :exp=>'$14 = true'}
tc << {:cmd=>'p b>=5', :exp=>'$15 = true'}
tc << {:cmd=>'p b<=5', :exp=>'$16 = true'}
tc << {:cmd=>'p "A"<=>"B"', :exp=>'$17 = -1'}
tc << {:cmd=>'p "A"=="B"', :exp=>'$18 = false'}
tc << {:cmd=>'p "A"==="B"', :exp=>'$19 = false'}
tc << {:cmd=>'p "A"!="B"', :exp=>'$20 = true'}
tc << {:cmd=>'p false || true', :exp=>'$21 = true'}
tc << {:cmd=>'p false && true', :exp=>'$22 = false'}
tc << {:cmd=>'p not nil', :exp=>'$23 = true'}
tc << {:cmd=>'p false or true', :exp=>'$24 = true'}
tc << {:cmd=>'p false and true', :exp=>'$25 = false'}
BinTest_MrubyBinDebugger.test(src, tc)
end
assert('mruby-bin-debugger(print) Ternary operation') do
# ruby source
src = <<"SRC"
CONST = 100
a,b,c = 1, 5, -10
foo,bar,baz = 'foo','bar','baz'
ary = []
SRC
# test case
tc = []
tc << {:cmd=>'s'}
tc << {:cmd=>'s'}
tc << {:cmd=>'s'}
tc << {:cmd=>'p (a < b) ? a : b', :exp=>'$1 = 1'}
tc << {:cmd=>'p (a > b) ? a : b', :exp=>'$2 = 5'}
tc << {:cmd=>'p true ? "true" : "false"', :exp=>'$3 = "true"'}
tc << {:cmd=>'p false ? "true" : "false"', :exp=>'$4 = "false"'}
tc << {:cmd=>'p nil ? "true" : "false"', :exp=>'$5 = "false"'}
BinTest_MrubyBinDebugger.test(src, tc)
end
assert('mruby-bin-debugger(print) Substitution:simple') do
# ruby source
src = <<"SRC"
CONST = 100
a,b,c = 1, 5, -10
foo,bar,baz = 'foo','bar','baz'
ary = []
SRC
# test case
tc = []
tc << {:cmd=>'s'}
tc << {:cmd=>'s'}
tc << {:cmd=>'s'}
tc << {:cmd=>'p a=2', :exp=>'$1 = 2'}
tc << {:cmd=>'p foo=[foo,bar,baz]', :exp=>'$2 = ["foo", "bar", "baz"]'}
tc << {:cmd=>'p undefined=-1', :exp=>'$3 = -1'}
tc << {:cmd=>'p "#{undefined}"', :exp=>'$4 = (eval):2: undefined method'}
BinTest_MrubyBinDebugger.test(src, tc)
end
assert('mruby-bin-debugger(print) Substitution:self') do
# ruby source
src = <<"SRC"
CONST = 100
a,b,c = 1, 5, -10
foo,bar,baz = 'foo','bar','baz'
ary = []
SRC
# test case
tc = []
tc << {:cmd=>'s'}
tc << {:cmd=>'s'}
tc << {:cmd=>'s'}
tc << {:cmd=>'p a+=9', :exp=>'$1 = 10'}
tc << {:cmd=>'p b-=c', :exp=>'$2 = 15'}
tc << {:cmd=>'p bar*=2', :exp=>'$3 = "barbar"'}
tc << {:cmd=>'p a/=4', :exp=>'$4 = 2.5'}
tc << {:cmd=>'p c%=4', :exp=>'$5 = 2'}
tc << {:cmd=>'p b&=0b0101', :exp=>'$6 = 5'}
tc << {:cmd=>'p c|=0x10', :exp=>'$7 = 18'}
tc << {:cmd=>'p "#{a} #{b} #{c}"', :exp=>'$8 = "2.5 5 18"'}
tc << {:cmd=>'p "#{foo}#{bar}#{baz}"', :exp=>'$9 = "foobarbarbaz"'}
tc << {:cmd=>'p a,b,c=[10,20,30]',:exp=>'$10 = [10, 20, 30]'}
tc << {:cmd=>'p [a,b,c]', :exp=>'$11 = [10, 20, 30]'}
tc << {:cmd=>'p a,b=b,a', :exp=>'$12 = [20, 10]'}
tc << {:cmd=>'p [a,b]', :exp=>'$13 = [20, 10]'}
tc << {:cmd=>'p undefined=-1', :exp=>'$14 = -1'}
tc << {:cmd=>'p "#{undefined}"', :exp=>'$15 = (eval):2: undefined method'}
BinTest_MrubyBinDebugger.test(src, tc)
end
assert('mruby-bin-debugger(print) Substitution:multiple') do
# ruby source
src = <<"SRC"
CONST = 100
a,b,c = 1, 5, -10
foo,bar,baz = 'foo','bar','baz'
ary = []
SRC
# test case
tc = []
tc << {:cmd=>'s'}
tc << {:cmd=>'s'}
tc << {:cmd=>'s'}
tc << {:cmd=>'p a,b=[10,20]', :exp=>'$1 = [10, 20]'}
tc << {:cmd=>'p [a,b,c]', :exp=>'$2 = [10, 20, -10]'}
tc << {:cmd=>'p foo,bar=["FOO","BAR","BAZ"]', :exp=>'$3 = ["FOO", "BAR", "BAZ"]'}
tc << {:cmd=>'p [foo,bar,baz]', :exp=>'$4 = ["FOO", "BAR", "baz"]'}
tc << {:cmd=>'p a,foo=foo,a', :exp=>'$5 = ["FOO", 10]'}
tc << {:cmd=>'p [a,foo]', :exp=>'$6 = ["FOO", 10]'}
# tc << {:cmd=>'p a,*b=[123, 456, 789]'}
# tc << {:cmd=>'p [a,b]', :exp=>'[123, [456, 789]]'}
BinTest_MrubyBinDebugger.test(src, tc)
end
assert('mruby-bin-debugger(print) Substitution:self') do
# ruby source
src = <<"SRC"
CONST = 100
a,b,c = 1, 5, -10
foo,bar,baz = 'foo','bar','baz'
ary = []
SRC
# test case
tc = []
tc << {:cmd=>'s'}
tc << {:cmd=>'s'}
tc << {:cmd=>'s'}
tc << {:cmd=>'p a+=9', :exp=>'$1 = 10'}
tc << {:cmd=>'p b-=c', :exp=>'$2 = 15'}
tc << {:cmd=>'p bar*=2', :exp=>'$3 = "barbar"'}
tc << {:cmd=>'p a/=4', :exp=>'$4 = 2.5'}
tc << {:cmd=>'p c%=4', :exp=>'$5 = 2'}
tc << {:cmd=>'p b&=0b0101', :exp=>'$6 = 5'}
tc << {:cmd=>'p c|=0x10', :exp=>'$7 = 18'}
tc << {:cmd=>'p "#{a} #{b} #{c}"', :exp=>'$8 = "2.5 5 18"'}
tc << {:cmd=>'p "#{foo}#{bar}#{baz}"', :exp=>'$9 = "foobarbarbaz"'}
tc << {:cmd=>'p a,b,c=[10,20,30]',:exp=>'$10 = [10, 20, 30]'}
tc << {:cmd=>'p [a,b,c]', :exp=>'$11 = [10, 20, 30]'}
tc << {:cmd=>'p a,b=b,a', :exp=>'$12 = [20, 10]'}
tc << {:cmd=>'p [a,b]', :exp=>'$13 = [20, 10]'}
tc << {:cmd=>'p undefined=-1', :exp=>'$14 = -1'}
tc << {:cmd=>'p "#{undefined}"', :exp=>'$15 = (eval):2: undefined method'}
BinTest_MrubyBinDebugger.test(src, tc)
end
+9
View File
@@ -0,0 +1,9 @@
MRuby::Gem::Specification.new('mruby-bin-debugger') do |spec|
spec.license = 'MIT'
spec.author = 'mruby developers'
spec.summary = 'mruby debugger command'
spec.add_dependency('mruby-eval', :core => 'mruby-eval')
spec.bins = %w(mrdb)
end
@@ -0,0 +1,507 @@
/*
** apibreak.c
**
*/
#include <string.h>
#include <mruby.h>
#include <mruby/irep.h>
#include "mrdb.h"
#include <mruby/debug.h>
#include <mruby/opcode.h>
#include <mruby/class.h>
#include <mruby/proc.h>
#include <mruby/variable.h>
#include "mrdberror.h"
#include "apibreak.h"
#define MAX_BREAKPOINTNO (MAX_BREAKPOINT * 1024)
#define MRB_DEBUG_BP_FILE_OK (0x0001)
#define MRB_DEBUG_BP_LINENO_OK (0x0002)
static uint16_t
check_lineno(mrb_irep_debug_info_file *info_file, uint16_t lineno)
{
uint32_t count = info_file->line_entry_count;
uint16_t l_idx;
if (info_file->line_type == mrb_debug_line_ary) {
for (l_idx = 0; l_idx < count; ++l_idx) {
if (lineno == info_file->lines.ary[l_idx]) {
return lineno;
}
}
}
else {
for (l_idx = 0; l_idx < count; ++l_idx) {
if (lineno == info_file->lines.flat_map[l_idx].line) {
return lineno;
}
}
}
return 0;
}
static int32_t
get_break_index(mrb_debug_context *dbg, uint32_t bpno)
{
uint32_t i;
int32_t index;
char hit = FALSE;
for(i = 0 ; i < dbg->bpnum; i++) {
if (dbg->bp[i].bpno == bpno) {
hit = TRUE;
index = i;
break;
}
}
if (hit == FALSE) {
return MRB_DEBUG_BREAK_INVALID_NO;
}
return index;
}
static void
free_breakpoint(mrb_state *mrb, mrb_debug_breakpoint *bp)
{
switch(bp->type) {
case MRB_DEBUG_BPTYPE_LINE:
mrb_free(mrb, (void*)bp->point.linepoint.file);
break;
case MRB_DEBUG_BPTYPE_METHOD:
mrb_free(mrb, (void*)bp->point.methodpoint.method_name);
if (bp->point.methodpoint.class_name != NULL) {
mrb_free(mrb, (void*)bp->point.methodpoint.class_name);
}
break;
default:
break;
}
}
static uint16_t
check_file_lineno(mrb_state *mrb, struct mrb_irep *irep, const char *file, uint16_t lineno)
{
mrb_irep_debug_info_file *info_file;
uint16_t result = 0;
uint16_t f_idx;
uint16_t fix_lineno;
uint16_t i;
for (f_idx = 0; f_idx < irep->debug_info->flen; ++f_idx) {
const char *filename;
info_file = irep->debug_info->files[f_idx];
filename = mrb_sym_name_len(mrb, info_file->filename_sym, NULL);
if (!strcmp(filename, file)) {
result = MRB_DEBUG_BP_FILE_OK;
fix_lineno = check_lineno(info_file, lineno);
if (fix_lineno != 0) {
return result | MRB_DEBUG_BP_LINENO_OK;
}
}
for (i=0; i < irep->rlen; ++i) {
result |= check_file_lineno(mrb, irep->reps[i], file, lineno);
if (result == (MRB_DEBUG_BP_FILE_OK | MRB_DEBUG_BP_LINENO_OK)) {
return result;
}
}
}
return result;
}
static int32_t
compare_break_method(mrb_state *mrb, mrb_debug_breakpoint *bp, struct RClass *class_obj, mrb_sym method_sym, mrb_bool* isCfunc)
{
const char* class_name;
const char* method_name;
mrb_method_t m;
struct RClass* sc;
const char* sn;
mrb_sym ssym;
mrb_debug_methodpoint *method_p;
mrb_bool is_defined;
method_name = mrb_sym_name(mrb, method_sym);
method_p = &bp->point.methodpoint;
if (strcmp(method_p->method_name, method_name) == 0) {
class_name = mrb_class_name(mrb, class_obj);
if (class_name == NULL) {
if (method_p->class_name == NULL) {
return bp->bpno;
}
}
else if (method_p->class_name != NULL) {
m = mrb_method_search_vm(mrb, &class_obj, method_sym);
if (MRB_METHOD_UNDEF_P(m)) {
return MRB_DEBUG_OK;
}
if (MRB_METHOD_CFUNC_P(m)) {
*isCfunc = TRUE;
}
is_defined = mrb_class_defined(mrb, method_p->class_name);
if (is_defined == FALSE) {
return MRB_DEBUG_OK;
}
sc = mrb_class_get(mrb, method_p->class_name);
ssym = mrb_symbol(mrb_check_intern_cstr(mrb, method_p->method_name));
m = mrb_method_search_vm(mrb, &sc, ssym);
if (MRB_METHOD_UNDEF_P(m)) {
return MRB_DEBUG_OK;
}
class_name = mrb_class_name(mrb, class_obj);
sn = mrb_class_name(mrb, sc);
if (strcmp(sn, class_name) == 0) {
return bp->bpno;
}
}
}
return MRB_DEBUG_OK;
}
int32_t
mrb_debug_set_break_line(mrb_state *mrb, mrb_debug_context *dbg, const char *file, uint16_t lineno)
{
int32_t index;
char* set_file;
uint16_t result;
if ((mrb == NULL)||(dbg == NULL)||(file == NULL)) {
return MRB_DEBUG_INVALID_ARGUMENT;
}
if (dbg->bpnum >= MAX_BREAKPOINT) {
return MRB_DEBUG_BREAK_NUM_OVER;
}
if (dbg->next_bpno > MAX_BREAKPOINTNO) {
return MRB_DEBUG_BREAK_NO_OVER;
}
/* file and lineno check (line type mrb_debug_line_ary only.) */
result = check_file_lineno(mrb, dbg->root_irep, file, lineno);
if (result == 0) {
return MRB_DEBUG_BREAK_INVALID_FILE;
}
else if (result == MRB_DEBUG_BP_FILE_OK) {
return MRB_DEBUG_BREAK_INVALID_LINENO;
}
set_file = (char*)mrb_malloc(mrb, strlen(file) + 1);
index = dbg->bpnum;
dbg->bp[index].bpno = dbg->next_bpno;
dbg->next_bpno++;
dbg->bp[index].enable = TRUE;
dbg->bp[index].type = MRB_DEBUG_BPTYPE_LINE;
dbg->bp[index].point.linepoint.lineno = lineno;
dbg->bpnum++;
strncpy(set_file, file, strlen(file) + 1);
dbg->bp[index].point.linepoint.file = set_file;
return dbg->bp[index].bpno;
}
int32_t
mrb_debug_set_break_method(mrb_state *mrb, mrb_debug_context *dbg, const char *class_name, const char *method_name)
{
int32_t index;
char* set_class;
char* set_method;
if ((mrb == NULL) || (dbg == NULL) || (method_name == NULL)) {
return MRB_DEBUG_INVALID_ARGUMENT;
}
if (dbg->bpnum >= MAX_BREAKPOINT) {
return MRB_DEBUG_BREAK_NUM_OVER;
}
if (dbg->next_bpno > MAX_BREAKPOINTNO) {
return MRB_DEBUG_BREAK_NO_OVER;
}
if (class_name != NULL) {
set_class = (char*)mrb_malloc(mrb, strlen(class_name) + 1);
strncpy(set_class, class_name, strlen(class_name) + 1);
}
else {
set_class = NULL;
}
set_method = (char*)mrb_malloc(mrb, strlen(method_name) + 1);
strncpy(set_method, method_name, strlen(method_name) + 1);
index = dbg->bpnum;
dbg->bp[index].bpno = dbg->next_bpno;
dbg->next_bpno++;
dbg->bp[index].enable = TRUE;
dbg->bp[index].type = MRB_DEBUG_BPTYPE_METHOD;
dbg->bp[index].point.methodpoint.method_name = set_method;
dbg->bp[index].point.methodpoint.class_name = set_class;
dbg->bpnum++;
return dbg->bp[index].bpno;
}
int32_t
mrb_debug_get_breaknum(mrb_state *mrb, mrb_debug_context *dbg)
{
if ((mrb == NULL) || (dbg == NULL)) {
return MRB_DEBUG_INVALID_ARGUMENT;
}
return dbg->bpnum;
}
int32_t
mrb_debug_get_break_all(mrb_state *mrb, mrb_debug_context *dbg, uint32_t size, mrb_debug_breakpoint *bp)
{
uint32_t get_size = 0;
if ((mrb == NULL) || (dbg == NULL) || (bp == NULL)) {
return MRB_DEBUG_INVALID_ARGUMENT;
}
if (dbg->bpnum >= size) {
get_size = size;
}
else {
get_size = dbg->bpnum;
}
memcpy(bp, dbg->bp, sizeof(mrb_debug_breakpoint) * get_size);
return get_size;
}
int32_t
mrb_debug_get_break(mrb_state *mrb, mrb_debug_context *dbg, uint32_t bpno, mrb_debug_breakpoint *bp)
{
int32_t index;
if ((mrb == NULL) || (dbg == NULL) || (bp == NULL)) {
return MRB_DEBUG_INVALID_ARGUMENT;
}
index = get_break_index(dbg, bpno);
if (index == MRB_DEBUG_BREAK_INVALID_NO) {
return MRB_DEBUG_BREAK_INVALID_NO;
}
bp->bpno = dbg->bp[index].bpno;
bp->enable = dbg->bp[index].enable;
bp->point = dbg->bp[index].point;
bp->type = dbg->bp[index].type;
return 0;
}
int32_t
mrb_debug_delete_break(mrb_state *mrb, mrb_debug_context *dbg, uint32_t bpno)
{
uint32_t i;
int32_t index;
if ((mrb == NULL) ||(dbg == NULL)) {
return MRB_DEBUG_INVALID_ARGUMENT;
}
index = get_break_index(dbg, bpno);
if (index == MRB_DEBUG_BREAK_INVALID_NO) {
return MRB_DEBUG_BREAK_INVALID_NO;
}
free_breakpoint(mrb, &dbg->bp[index]);
for(i = index ; i < dbg->bpnum; i++) {
if ((i + 1) == dbg->bpnum) {
memset(&dbg->bp[i], 0, sizeof(mrb_debug_breakpoint));
}
else {
memcpy(&dbg->bp[i], &dbg->bp[i + 1], sizeof(mrb_debug_breakpoint));
}
}
dbg->bpnum--;
return MRB_DEBUG_OK;
}
int32_t
mrb_debug_delete_break_all(mrb_state *mrb, mrb_debug_context *dbg)
{
uint32_t i;
if ((mrb == NULL) || (dbg == NULL)) {
return MRB_DEBUG_INVALID_ARGUMENT;
}
for(i = 0 ; i < dbg->bpnum ; i++) {
free_breakpoint(mrb, &dbg->bp[i]);
}
dbg->bpnum = 0;
return MRB_DEBUG_OK;
}
int32_t
mrb_debug_enable_break(mrb_state *mrb, mrb_debug_context *dbg, uint32_t bpno)
{
int32_t index = 0;
if ((mrb == NULL) || (dbg == NULL)) {
return MRB_DEBUG_INVALID_ARGUMENT;
}
index = get_break_index(dbg, bpno);
if (index == MRB_DEBUG_BREAK_INVALID_NO) {
return MRB_DEBUG_BREAK_INVALID_NO;
}
dbg->bp[index].enable = TRUE;
return MRB_DEBUG_OK;
}
int32_t
mrb_debug_enable_break_all(mrb_state *mrb, mrb_debug_context *dbg)
{
uint32_t i;
if ((mrb == NULL) || (dbg == NULL)) {
return MRB_DEBUG_INVALID_ARGUMENT;
}
for(i = 0 ; i < dbg->bpnum; i++) {
dbg->bp[i].enable = TRUE;
}
return MRB_DEBUG_OK;
}
int32_t
mrb_debug_disable_break(mrb_state *mrb, mrb_debug_context *dbg, uint32_t bpno)
{
int32_t index = 0;
if ((mrb == NULL) || (dbg == NULL)) {
return MRB_DEBUG_INVALID_ARGUMENT;
}
index = get_break_index(dbg, bpno);
if (index == MRB_DEBUG_BREAK_INVALID_NO) {
return MRB_DEBUG_BREAK_INVALID_NO;
}
dbg->bp[index].enable = FALSE;
return MRB_DEBUG_OK;
}
int32_t
mrb_debug_disable_break_all(mrb_state *mrb, mrb_debug_context *dbg)
{
uint32_t i;
if ((mrb == NULL) || (dbg == NULL)) {
return MRB_DEBUG_INVALID_ARGUMENT;
}
for(i = 0 ; i < dbg->bpnum; i++) {
dbg->bp[i].enable = FALSE;
}
return MRB_DEBUG_OK;
}
static mrb_bool
check_start_pc_for_line(mrb_state *mrb, mrb_irep *irep, const mrb_code *pc, uint16_t line)
{
if (pc > irep->iseq) {
if (line == mrb_debug_get_line(mrb, irep, pc - irep->iseq - 1)) {
return FALSE;
}
}
return TRUE;
}
int32_t
mrb_debug_check_breakpoint_line(mrb_state *mrb, mrb_debug_context *dbg, const char *file, uint16_t line)
{
mrb_debug_breakpoint *bp;
mrb_debug_linepoint *line_p;
uint32_t i;
if ((mrb == NULL) || (dbg == NULL) || (file == NULL) || (line <= 0)) {
return MRB_DEBUG_INVALID_ARGUMENT;
}
if (!check_start_pc_for_line(mrb, dbg->irep, dbg->pc, line)) {
return MRB_DEBUG_OK;
}
bp = dbg->bp;
for(i=0; i<dbg->bpnum; i++) {
switch (bp->type) {
case MRB_DEBUG_BPTYPE_LINE:
if (bp->enable == TRUE) {
line_p = &bp->point.linepoint;
if ((strcmp(line_p->file, file) == 0) && (line_p->lineno == line)) {
return bp->bpno;
}
}
break;
case MRB_DEBUG_BPTYPE_METHOD:
break;
case MRB_DEBUG_BPTYPE_NONE:
default:
return MRB_DEBUG_OK;
}
bp++;
}
return MRB_DEBUG_OK;
}
int32_t
mrb_debug_check_breakpoint_method(mrb_state *mrb, mrb_debug_context *dbg, struct RClass *class_obj, mrb_sym method_sym, mrb_bool* isCfunc)
{
mrb_debug_breakpoint *bp;
int32_t bpno;
uint32_t i;
if ((mrb == NULL) || (dbg == NULL) || (class_obj == NULL)) {
return MRB_DEBUG_INVALID_ARGUMENT;
}
bp = dbg->bp;
for(i=0; i<dbg->bpnum; i++) {
if (bp->type == MRB_DEBUG_BPTYPE_METHOD) {
if (bp->enable == TRUE) {
bpno = compare_break_method(mrb, bp, class_obj, method_sym, isCfunc);
if (bpno > 0) {
return bpno;
}
}
}
else if (bp->type == MRB_DEBUG_BPTYPE_NONE) {
break;
}
bp++;
}
return 0;
}
@@ -0,0 +1,26 @@
/*
** apibreak.h
**
*/
#ifndef APIBREAK_H_
#define APIBREAK_H_
#include <mruby.h>
#include "mrdb.h"
int32_t mrb_debug_set_break_line(mrb_state *, mrb_debug_context *, const char *, uint16_t);
int32_t mrb_debug_set_break_method(mrb_state *, mrb_debug_context *, const char *, const char *);
int32_t mrb_debug_get_breaknum(mrb_state *, mrb_debug_context *);
int32_t mrb_debug_get_break_all(mrb_state *, mrb_debug_context *, uint32_t, mrb_debug_breakpoint bp[]);
int32_t mrb_debug_get_break(mrb_state *, mrb_debug_context *, uint32_t, mrb_debug_breakpoint *);
int32_t mrb_debug_delete_break(mrb_state *, mrb_debug_context *, uint32_t);
int32_t mrb_debug_delete_break_all(mrb_state *, mrb_debug_context *);
int32_t mrb_debug_enable_break(mrb_state *, mrb_debug_context *, uint32_t);
int32_t mrb_debug_enable_break_all(mrb_state *, mrb_debug_context *);
int32_t mrb_debug_disable_break(mrb_state *, mrb_debug_context *, uint32_t);
int32_t mrb_debug_disable_break_all(mrb_state *, mrb_debug_context *);
int32_t mrb_debug_check_breakpoint_line(mrb_state *, mrb_debug_context *, const char *, uint16_t);
int32_t mrb_debug_check_breakpoint_method(mrb_state *, mrb_debug_context *, struct RClass *, mrb_sym, mrb_bool*);
#endif /* APIBREAK_H_ */

Some files were not shown because too many files have changed in this diff Show More