Commit Graph

99 Commits

Author SHA1 Message Date
dearblue a0526418ce Update documentation for mrb_top_run()
Also, add explanations for the `mrb_load_irep()` and `mrb_load_string()` families, which are indirect calls to `mrb_top_run()`.
2024-04-26 22:05:45 +09:00
Yukihiro "Matz" Matsumoto c5e3cbe4bf compile.h: stop using mrbc_ prefix for compiler context
Since it is confusing that the term `mrbc` stands for both "mruby
compiler" and "mruby compiler context" in the source code. Instead,
we use `mrb_ccontext` (stands for compiler context) prefix hereafter.

We choose `mrb_ccontext` because we have already used `mrb_context` (for
VM execusion context).
2023-12-06 15:22:08 +09:00
John Bampton 06a765a1c2 Change MRuby to mruby 2023-05-03 22:12:59 +10:00
Yukihiro "Matz" Matsumoto 561dffcccc parse.y: fix nested here-document bug; fix #5607
- remove `lex_strterm_before_heredoc` that does not nest
- remove `all_heredocs` that cannot distinguish nested and followed
  here-doc
- replace `lex_strterm` represented by cons list by C struct
- push/pop `lex_strterm` before/after interpolation
2022-06-13 22:25:37 +09:00
Yukihiro "Matz" Matsumoto 4d70d17af7 compile.h: reorder parser_heredoc_info members to reduce alignment gap. 2022-06-12 18:48:34 +09:00
dearblue 6b8582c95d Add bin/mrbc --no-ext-ops switch
Print an error if `OP_EXT[123]` is needed when generating mruby binary.
This may be useful for mruby/c.

Inspired by #5590.
2021-12-17 23:02:04 +09:00
Yukihiro "Matz" Matsumoto 7c1878669a parse.y: should allow newline after .... 2021-11-12 15:02:04 +09:00
Yukihiro "Matz" Matsumoto 2fb06aabe6 parse.y: refactor mrb_parser_parse().
- remove `mrb_jmpbuf` from `truct mrb_parser_state`
- unify exception handling of `mrb_state` and `mrb_parser_state`.
2021-09-07 07:31:21 +09:00
Seeker 1099050377 Treat tabs as 8 spaces in squiggly heredocs 2020-12-31 19:09:38 -08:00
Seeker 49b01f23a4 Fix mixed indentation and escaped tabs in squiggly heredocs 2020-12-28 18:22:13 -08:00
Seeker 54bfcaf1ff Add support for squiggly heredocs 2020-12-26 23:48:20 -08:00
John Bampton 4fa3359d44 refactor: remove trailing whitespace from C, Header, Ruby and YAML files
Lint
2020-12-15 19:44:02 +10:00
KOBAYASHI Shuji 3d056d084a Rename MRB_{ENABLE,DISABLE}_ to MRB_{USE,NO}_; close #5163
|        Previous Name         |        New Name         |
|------------------------------|-------------------------|
| MRB_ENABLE_ALL_SYMBOLS       | MRB_USE_ALL_SYMBOLS     |
| MRB_ENABLE_SYMBOLL_ALL       | MRB_USE_ALL_SYMBOLS     |
| MRB_ENABLE_CXX_ABI           | MRB_USE_CXX_ABI         |
| MRB_ENABLE_CXX_EXCEPTION     | MRB_USE_CXX_EXCEPTION   |
| MRB_ENABLE_DEBUG_HOOK        | MRB_USE_DEBUG_HOOK      |
| MRB_DISABLE_DIRECT_THREADING | MRB_NO_DIRECT_THREADING |
| MRB_DISABLE_STDIO            | MRB_NO_STDIO            |
| ENABLE_LINENOISE             | MRB_USE_LINENOISE       |
| ENABLE_READLINE              | MRB_USE_READLINE        |
| DISABLE_MIRB_UNDERSCORE      | MRB_NO_MIRB_UNDERSCORE  |
| DISABLE_GEMS                 | MRB_NO_GEMS             |

* `MRB_ENABLE_SYMBOLL_ALL` seems to be a typo, so it is fixed.
* `MRB_` prefix is added to those without.
* The previous names can also be used for compatibility.
2020-11-21 21:14:40 +09:00
dearblue a045b6b8d9 Allow to mixed and specify *.rb and *.mrb in bin/mruby
It is not decides by the extension.
In order to be recognized as a `.mrb` file, the following three points must be satisfied:
- File starts with "RITE"
- At least `sizeof(struct rite_binary_header)` bytes can be read
- `NUL` is included in the first 64 bytes of the file
If these are not met, it is judged as a text file and it is processed as a Ruby script.

The `bin/mruby -b` switch is still available which treats the given file as a `.mrb` file.

New `MRB_API` function:
- `include/mruby/compile.h` and `mrbgems/mruby-compiler/core/parse.y`
  - `mrb_load_detect_file_cxt()` (remove with `MRB_DISABLE_STDIO`)

NOTE:
- Even script files now always open in binary mode for `bin/mruby`.
  The `\r\n` is handled by the `nextc()` function already, so there is no problem even on Windows.
- The `nextc0()` function in `mrbgems/mruby-compiler/core/parse.y` can now specify a string buffer and a file pointer at the same time.
  In this case, get it from the string buffer first.

This patch includes modifies by comment of https://github.com/mruby/mruby/pull/5157.
2020-11-21 19:05:46 +09:00
Yukihiro "Matz" Matsumoto 52507b1083 Generate C struct from irep instead of binary dump. 2020-10-12 16:21:10 +09:00
Yukihiro "Matz" Matsumoto c27e451931 Merge pull request #4933 from dearblue/variables
Fix take over file scope variables with `mruby` and `mirb` command
2020-09-10 18:12:38 +09:00
dearblue f85906b679 Remove patch_irep() in mruby-eval
- It can now deal with operands in the range of `OP_EXT*`.
- It can now call the same method as the variable name without arguments.

  ```ruby
  def a
    "Safe!"
  end

  a = "Auto!"

  eval "a()" # call method `a`
  ```
2020-06-02 14:49:27 +09:00
Rory OConnell 69bc477b43 Adding warnings for mrb_load functions leaking RProc objects 2020-05-19 01:07:49 -07:00
dearblue 893cc2780c Add mrbc_cleanup_local_variables() with mrbc_context; ref #4931
Clean up defined local variables.
2020-01-19 21:42:09 +09:00
Ukrainskiy Sergey 72d57ad094 Implement numbered parameters 2019-12-09 20:50:41 +09:00
David Siaw b5299b1c58 fix up documentation for values 2019-08-18 20:12:44 +09:00
KOBAYASHI Shuji acad9567c1 Unify type of line number to uint16_t 2019-07-15 23:03:41 +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 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 ec19c34a20 Fixed a bug in mirb heredoc handling; fix #3989 2018-11-20 10:39:34 +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 891839b976 New bytecode implementation of mruby VM. 2018-07-30 22:57:54 +09:00
Yukihiro "Matz" Matsumoto 37f6e42293 Removed redundant function prototype. 2017-11-04 17:59:00 +09:00
YAMAMOTO Masaya acdc2d1f24 Add MRB_WITHOUT_FLOAT 2017-10-11 17:58:11 +09:00
Yukihiro "Matz" Matsumoto f1fa5bf1c6 Remove integer type mismatch warnings from parse.y. 2017-08-28 22:31:02 +09:00
Christopher Aue 2fadddcd20 Replaced tabs with spaces 2017-08-09 21:56:27 +02: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 7944d9a6d4 Make mrb_load_exec a static function. 2017-06-23 17:56:12 +09: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 eda6c1dc05 fix build on vs2013-vs2015 2016-12-08 15:38:19 +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
Yukihiro "Matz" Matsumoto d4d807b774 relax string length limitation to 64KB; fix #2725 2016-07-13 03:22:15 +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 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 5c405dea3d include changed from by quotes ("") to by brackets (<>); close #3032 2015-11-27 17:48:23 +09:00
cremno ad21e5e6d8 fix MRB_DISABLE_STDIO typos 2015-11-17 00:08:41 +01: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
Seba Gamboa a0fe0c40b1 Remove old doxygen tags 2015-10-08 12:29:10 -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
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 81c894a1c6 add some MRB_API to function prototypes 2014-09-05 00:54:51 +09:00
Yukihiro "Matz" Matsumoto 3c4cd5428a allow no_optimize esp. for debugger 2014-08-29 15:09:14 +09:00
Yukihiro "Matz" Matsumoto 206f89e209 add MRB_API modifiers to mruby API functions 2014-08-04 00:47:08 +09:00