hamilton *hammett* verissimo

Another special person... just like everyone else

  Home  |   Contact  |   Syndication    |   Login
  19 Posts | 2 Stories | 5 Comments | 23 Trackbacks

News

www.flickr.com
This is a Flickr badge showing public photos from hammett1. Make your own badge here.

Archives

Post Categories

Image Galleries

Sunday, February 05, 2006 #

So among one phase and other of Manhunt, I'm improving my brain exercise. Now it's able to deal with boolean expressions. I had to review the AST nodes implementation to allow some tree rewriting.

a = 1 == 1 
b = 1 != 2
x = 10 
puts 3 * 90, a, b, x 

This produces the following initial AST

AssignmentExp
  NameReferenceExpression (a) 
  BinaryExp (....)

AssignmentExp
  NameReferenceExpression (b) 
  BinaryExp (....)

AssignmentExp
  NameReferenceExpression (x) 
  ConstantExp (10, int)

MethodInvocationExp
  Target NameReferenceExpression (puts)
  Arguments
    BinaryExp
    NameReferenceExpression (a) 
    NameReferenceExpression (b) 
    NameReferenceExpression (x) 

So I'm treating the names as some unknown entity that is rewrite as we discover more... The tree gets rewritten to

AssignmentExp
  VarRefExp (a) 
  BinaryExp (....)

AssignmentExp
  VarRefExp (b) 
  BinaryExp (....)

AssignmentExp
  VarRefExp (x) 
  ConstantExp (10, int)

MethodInvocationExp (puts)
  Target null
  Arguments
    BinaryExp
    VarRefExp (a) 
    VarRefExp (b) 
    VarRefExp (x) 

The code, once executed produces:

E:\dev\projects\Blah\BlahProj\bin\Debug>hello
270
True
True
10

Kinda cool. Now I'd like to introduce the dynamics capabilities, meaning: some names should be marked as dynamic, and thus the compiler should not attempt to type it and consequentially more code will be generated in order to perform checks and casts. It's kinda fun, but demands too many types to get something running :-\