Accessing structs defined in eval.c in extension

…yeah, I’m trying to do something wierd…

First off, why is there an eval.c that has several structs defined that
would probably be better to have defined in an eval.h file? (but there is
no eval.h file)

I’m trying to access a member of the BLOCK structure that is defined in
eval.c in an extension.

Here’s the definition in eval.c:

struct BLOCK {
NODE *var;
NODE *body;
VALUE self;
struct FRAME frame;
struct SCOPE *scope;
struct BLOCKTAG *tag;
VALUE klass;
int iter;
int vmode;
int flags;
struct RVarmap *dyna_vars;
VALUE orig_thread;
VALUE wrapper;
struct BLOCK *prev;
};

static struct BLOCK *ruby_block;

I want to access the ‘body’ member of the struct and use it to get the AST
for a proc. It seems to me that if these structs were defined in an
eval.h file, that would be easier :wink:

Phil

....yeah, I'm trying to do something wierd...

Like you said you are trying to do something weird ...

pigeon% ruby -rii -e 'a = Proc.new {|i| i += 1}; dump a'
Proc
nd_var
  DASGN_CURR i
nd_body
  NEWLINE <-e:1>
  DASGN_CURR i
    CALL +
      DVAR i
      ARRAY
        LIT 1

pigeon%

I want to access the 'body' member of the struct and use it to get the AST
for a proc. It seems to me that if these structs were defined in an
eval.h file, that would be easier :wink:

No.

Guy Decoux

In article 200211080558.gA85wGd11700@moulon.inra.fr,

…yeah, I’m trying to do something wierd…

Like you said you are trying to do something weird …

pigeon% ruby -rii -e ‘a = Proc.new {|i| i += 1}; dump a’
Proc
nd_var
DASGN_CURR i
nd_body
NEWLINE <-e:1>
DASGN_CURR i
CALL +
DVAR i
ARRAY
LIT 1

What is the ii library that you’re loading with the -r?

Here’s what I get when I try to run this:

$ ruby -rii -e ‘a = Proc.new {|i| i += 1}; dump a’
…/ruby: No such file to load – ii (LoadError)
$ ruby -v
ruby 1.7.3 (2002-11-07) [i686-linux]

Anyway, looks very cool, but I’m not sure how you got it to work…

Phil

···

ts decoux@moulon.inra.fr wrote: