<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>Makefile</filename>
    </added>
    <added>
      <filename>runtime.c</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -40,7 +40,7 @@ class Compiler
     return scope.get_arg(a) if (a.is_a?(Symbol))
 
     seq = @string_constants[a]
-    return seq if seq
+    return [:strconst,seq] if seq
     seq = @seq
     @seq += 1
     @string_constants[a] = seq
@@ -131,12 +131,21 @@ class Compiler
     return [:subexpr]
   end
 
+  def compile_assign scope, left, right 
+    source = compile_eval_arg(scope, right) 
+    atype, aparam = get_arg(scope,left) 
+    raise &quot;Expected a variable on left hand side of assignment&quot; if atype != :arg 
+    puts &quot;\tmovl\t#{source},#{PTR_SIZE*(aparam+2)}(%ebp)&quot; 
+    return [:subexpr] 
+  end 
+
   def compile_exp(scope,exp)
     return if !exp || exp.size == 0
     return compile_do(scope,*exp[1..-1]) if exp[0] == :do 
     return compile_defun(scope,*exp[1..-1]) if (exp[0] == :defun)
     return compile_ifelse(scope,*exp[1..-1]) if (exp[0] == :if)
     return compile_lambda(scope,*exp[1..-1]) if (exp[0] == :lambda)
+    return compile_assign(scope,*exp[1..-1]) if (exp[0] == :assign) 
     return compile_call(scope,exp[1],exp[2]) if (exp[0] == :call)
     return compile_call(scope,exp[0],exp[1..-1])
   end
@@ -176,9 +185,12 @@ EPILOG
   end  
 end
 
-prog = [:do,
-  [:defun,:myputs,[:foo],[:puts,:foo]],
-  [:myputs,&quot;Demonstrating argument passing&quot;],
-]
+prog = [:call, [:lambda, [:i],  
+    [:do, 
+      [:printf, &quot;Testing sub and assign (before): %ld\\n&quot;, :i], 
+      [:assign, :i, [:sub, :i, 1]], 
+      [:printf, &quot;Testing sub and assign (after): %ld\\n&quot;, :i], 
+    ] 
+  ], [10] ] 
 
 Compiler.new.compile(prog)</diff>
      <filename>compiler.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>a3a3cf7588ee3683d86bd461890750e5af4737c2</id>
    </parent>
  </parents>
  <author>
    <name>Vidar Hokstad</name>
    <email>vidar@hokstad.com</email>
  </author>
  <url>http://github.com/vidarh/writing-a-compiler-in-ruby/commit/cde7a9e0e13606d7145f4869c5e5f4d60f655aff</url>
  <id>cde7a9e0e13606d7145f4869c5e5f4d60f655aff</id>
  <committed-date>2009-02-01T08:00:17-08:00</committed-date>
  <authored-date>2009-02-01T08:00:17-08:00</authored-date>
  <message>Step 8</message>
  <tree>544a56a02fb9eebdc421a72df7491bfd1c4fcd5c</tree>
  <committer>
    <name>Vidar Hokstad</name>
    <email>vidar@hokstad.com</email>
  </committer>
</commit>
