source: EcnlProtoTool/trunk/mruby-1.3.0/mrbgems/mruby-bin-debugger/tools/mrdb/apiprint.c@ 331

Last change on this file since 331 was 331, checked in by coas-nagasima, 6 years ago

prototoolに関連するプロジェクトをnewlibからmuslを使うよう変更・更新
ntshellをnewlibの下位の実装から、muslのsyscallの実装に変更・更新
以下のOSSをアップデート
・mruby-1.3.0
・musl-1.1.18
・onigmo-6.1.3
・tcc-0.9.27
以下のOSSを追加
・openssl-1.1.0e
・curl-7.57.0
・zlib-1.2.11
以下のmrbgemsを追加
・iij/mruby-digest
・iij/mruby-env
・iij/mruby-errno
・iij/mruby-iijson
・iij/mruby-ipaddr
・iij/mruby-mock
・iij/mruby-require
・iij/mruby-tls-openssl

  • Property svn:eol-style set to native
  • Property svn:mime-type set to text/x-csrc;charset=UTF-8
File size: 1.6 KB
Line 
1/*
2** apiprint.c
3**
4*/
5
6#include <string.h>
7#include "mrdb.h"
8#include <mruby/value.h>
9#include <mruby/class.h>
10#include <mruby/compile.h>
11#include <mruby/error.h>
12#include <mruby/numeric.h>
13#include <mruby/string.h>
14#include "apiprint.h"
15
16static void
17mrdb_check_syntax(mrb_state *mrb, mrb_debug_context *dbg, const char *expr, size_t len)
18{
19 mrbc_context *c;
20
21 c = mrbc_context_new(mrb);
22 c->no_exec = TRUE;
23 c->capture_errors = TRUE;
24 c->filename = (char*)dbg->prvfile;
25 c->lineno = dbg->prvline;
26
27 /* Load program */
28 mrb_load_nstring_cxt(mrb, expr, len, c);
29
30 mrbc_context_free(mrb, c);
31}
32
33mrb_value
34mrb_debug_eval(mrb_state *mrb, mrb_debug_context *dbg, const char *expr, size_t len, mrb_bool *exc)
35{
36 void (*tmp)(struct mrb_state *, struct mrb_irep *, mrb_code *, mrb_value *);
37 mrb_value ruby_code;
38 mrb_value s;
39 mrb_value v;
40 mrb_value recv;
41
42 /* disable code_fetch_hook */
43 tmp = mrb->code_fetch_hook;
44 mrb->code_fetch_hook = NULL;
45
46 mrdb_check_syntax(mrb, dbg, expr, len);
47 if (mrb->exc) {
48 v = mrb_obj_value(mrb->exc);
49 mrb->exc = 0;
50 }
51 else {
52 /*
53 * begin
54 * expr
55 * rescue => e
56 * e
57 * end
58 */
59 ruby_code = mrb_str_new_lit(mrb, "begin\n");
60 ruby_code = mrb_str_cat(mrb, ruby_code, expr, len);
61 ruby_code = mrb_str_cat_lit(mrb, ruby_code, "\nrescue => e\ne\nend");
62
63 recv = dbg->regs[0];
64
65 v = mrb_funcall(mrb, recv, "instance_eval", 1, ruby_code);
66 }
67
68 if (exc) {
69 *exc = mrb_obj_is_kind_of(mrb, v, mrb->eException_class);
70 }
71
72 s = mrb_funcall(mrb, v, "inspect", 0);
73
74 /* enable code_fetch_hook */
75 mrb->code_fetch_hook = tmp;
76
77 return s;
78}
Note: See TracBrowser for help on using the repository browser.