# Console ShowASTs not working?

**URL:** <https://www.ruby-forum.com/t/console-showasts-not-working/131667>\
**Category:** IronRuby\
**Created:** [March 12, 2008, 10:42am UTC](https://www.ruby-forum.com/t/console-showasts-not-working/131667 "2008-03-12T10:42:59Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![xjivan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/x/6f9a4e/32.png) [@xjivan](https://www.ruby-forum.com/u/xjivan)\
**Post date:** [March 12, 2008, 10:42am UTC](https://www.ruby-forum.com/t/console-showasts-not-working/131667/1 "2008-03-12T10:42:59Z")

</div>

Hi

I tried to view what AST’s was being generated when I executed a very  
simple  
class with the following command line

rbx -X:ShowASTs test.rb

class HelloWorld  
def initialize  
@msg = “hello world”

end

def print  
puts @msg  
end  
end

h = HelloWorld.new  
h.print

I tried doing that on windows in powershell, cmd and on OSX with mono

I also tried a couple of other command switches but none of them seem to  
do  
anything, is that because it’s not supposed to be working?  
the other command options i tried were -X:TabCompletion, -X:DumpASTs and  
-X:ShowRules  
None of them seem to have any effect, do I submit a bug for this?

Thanks  
Ivan

---

<div class="post-metadata">

**Author:** ![xjivan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/x/6f9a4e/32.png) [@xjivan](https://www.ruby-forum.com/u/xjivan)\
**Post date:** [March 12, 2008, 11:38am UTC](https://www.ruby-forum.com/t/console-showasts-not-working/131667/2 "2008-03-12T11:38:50Z")

</div>

-X:ShowASTs works for me. Linux, Mono 1.2.6, IronRuby r76.

---

<div class="post-metadata">

**Author:** ![xjivan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/x/6f9a4e/32.png) [@xjivan](https://www.ruby-forum.com/u/xjivan)\
**Post date:** [March 12, 2008, 11:54am UTC](https://www.ruby-forum.com/t/console-showasts-not-working/131667/3 "2008-03-12T11:54:29Z")

</div>

Cool it’s working for me too, it was just me being stupid.

---

<div class="post-metadata">

**Author:** ![xjivan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/x/6f9a4e/32.png) [@xjivan](https://www.ruby-forum.com/u/xjivan)\
**Post date:** [March 12, 2008, 7:01pm UTC](https://www.ruby-forum.com/t/console-showasts-not-working/131667/4 "2008-03-12T19:01:08Z")

</div>

2008/3/12, Brian J. Cardiff [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):

> Not so important, but why the AST is shown twice?

One is before rewriting, the other is after rewriting.

See Microsoft.Scripting/Ast/Compiler.cs, from line 485:

private static void AnalyzeBlock(CodeBlock block) {  
DumpBlock(block);

```
ForestRewriter.Rewrite(block);
ClosureBinder.Bind(block);
FlowChecker.Check(block);

DumpBlock(block);

```

}

---

<div class="post-metadata">

**Author:** ![xjivan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/x/6f9a4e/32.png) [@xjivan](https://www.ruby-forum.com/u/xjivan)\
**Post date:** [March 12, 2008, 12:24pm UTC](https://www.ruby-forum.com/t/console-showasts-not-working/131667/5 "2008-03-12T12:24:02Z")

</div>

Not so important, but why the AST is shown twice?

> rbx /X:ShowASTs  
> IronRuby 0.1 on .NET 2.0.50727.1433  
> Copyright (c) Microsoft Corporation. All rights reserved.

Note that local variables do not work today in the console.  
As a workaround, use globals instead (eg $x = 42 instead of x = 42).

> > > 1  
> > > //  
> > > // AST wrapper  
> > > //

.codeblock Object wrapper ( global,)() {

```
.return (RubyOps.RunMain)(
    .context,
    (Boolean)True,
    (Object).block (main #1),
);

```

}  
//  
// CODE BLOCK: main (1)  
//

.codeblock Object main ()() {  
.var RuntimeFlowControl #rfc (Local)  
.var Object #self (Local)  
.var RubyScope #scope (Local)

```
{
    (.bound #scope) = (RubyOps.GetScope)(
        .context,
    )
    (.bound #rfc) = (RubyOps.GetRfc)(
        (.bound #scope),
    )
    (.bound #self) = (RubyOps.GetSelf)(
        (.bound #scope),
    )
    {
        .return 1;
    }
}

```

}  
//  
// AST wrapper  
//

.codeblock Object wrapper ( global,)() {

```
.return (RubyOps.RunMain)(
    .context,
    (Boolean)True,
    (Object).block (main #1),
);

```

}  
//  
// CODE BLOCK: main (1)  
//

.codeblock Object main ()() {  
.var RuntimeFlowControl #rfc (Local)  
.var Object #self (Local)  
.var RubyScope #scope (Local)

```
{
    (.bound #scope) = (RubyOps.GetScope)(
        .context,
    )
    (.bound #rfc) = (RubyOps.GetRfc)(
        (.bound #scope),
    )
    (.bound #self) = (RubyOps.GetSelf)(
        (.bound #scope),
    )
    {
        .return 1;
    }
}

```

}  
=\> 1

> > >

On Wed, Mar 12, 2008 at 8:47 AM, Ivan Porto C.  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)
