source: EcnlProtoTool/trunk/prototool/src/cmdprint.c@ 279

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

ファイルを追加、更新。

  • 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.1 KB
Line 
1/*
2** cmdprint.c - mruby debugger print command functions
3**
4*/
5
6#include <stdlib.h>
7
8#include "mrdb.h"
9#include "mruby/value.h"
10#include "mruby/class.h"
11#include "mruby/compile.h"
12#include "mruby/error.h"
13#include "mruby/numeric.h"
14#include "mruby/string.h"
15#include "apiprint.h"
16
17dbgcmd_state
18dbgcmd_print(mrb_state *mrb, mrdb_state *mrdb)
19{
20 mrb_value expr;
21 mrb_value result;
22 mrb_value s;
23 uint8_t wcnt;
24 int ai;
25
26 if (mrdb->wcnt <= 1) {
27 puts("Parameter not specified.");
28 return DBGST_PROMPT;
29 }
30
31 ai = mrb_gc_arena_save(mrb);
32
33 /* eval expr */
34 expr = mrb_str_new_cstr(mrb, NULL);
35 for (wcnt = 1; wcnt < mrdb->wcnt; wcnt++) {
36 expr = mrb_str_cat_lit(mrb, expr, " ");
37 expr = mrb_str_cat_cstr(mrb, expr, mrdb->words[wcnt]);
38 }
39
40 result = mrb_debug_eval(mrb, mrdb->dbg, RSTRING_PTR(expr), RSTRING_LEN(expr), NULL);
41
42 /* $print_no = result */
43 s = mrb_str_cat_lit(mrb, result, "\0");
44 printf("$%lu = %s\n", (unsigned long)mrdb->print_no++, RSTRING_PTR(s));
45
46 if (mrdb->print_no == 0) {
47 mrdb->print_no = 1;
48 }
49
50 mrb_gc_arena_restore(mrb, ai);
51
52 return DBGST_PROMPT;
53}
54
55dbgcmd_state
56dbgcmd_eval(mrb_state *mrb, mrdb_state *mrdb)
57{
58 return dbgcmd_print(mrb, mrdb);
59}
Note: See TracBrowser for help on using the repository browser.