source: EcnlProtoTool/trunk/mruby-1.2.0/mrbgems/mruby-bin-debugger/tools/mrdb/cmdprint.c@ 270

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

mruby版ECNLプロトタイピング・ツールを追加

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
  • Property svn:mime-type set to text/x-csrc
File size: 1.2 KB
Line 
1/*
2** cmdprint.c - mruby debugger print command functions
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
16dbgcmd_state
17dbgcmd_print(mrb_state *mrb, mrdb_state *mrdb)
18{
19 mrb_value expr;
20 mrb_value result;
21 mrb_value s;
22 uint8_t wcnt;
23 int ai;
24
25 if (mrdb->wcnt <= 1) {
26 puts("Parameter not specified.");
27 return DBGST_PROMPT;
28 }
29
30 ai = mrb_gc_arena_save(mrb);
31
32 /* eval expr */
33 expr = mrb_str_new_cstr(mrb, NULL);
34 for (wcnt=1; wcnt<mrdb->wcnt; wcnt++) {
35 expr = mrb_str_cat_lit(mrb, expr, " ");
36 expr = mrb_str_cat_cstr(mrb, expr, mrdb->words[wcnt]);
37 }
38
39 result = mrb_debug_eval(mrb, mrdb->dbg, RSTRING_PTR(expr), RSTRING_LEN(expr), NULL);
40
41 /* $print_no = result */
42 s = mrb_str_cat_lit(mrb, result, "\0");
43 printf("$%lu = %s\n", (unsigned long)mrdb->print_no++, RSTRING_PTR(s));
44
45 if (mrdb->print_no == 0) {
46 mrdb->print_no = 1;
47 }
48
49 mrb_gc_arena_restore(mrb, ai);
50
51 return DBGST_PROMPT;
52}
53
54dbgcmd_state
55dbgcmd_eval(mrb_state *mrb, mrdb_state *mrdb)
56{
57 return dbgcmd_print(mrb, mrdb);
58}
Note: See TracBrowser for help on using the repository browser.