<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -1,8 +1,20 @@
 # Simple test...
 
 def test()
-  x = &quot;ohaie&quot;
-  printf(x)
+  x = 1
+  y = &quot;ohaie&quot;
+  printf(&quot;%d, %s&quot;, x, y)
 end
 
+def input()
+  buf = &quot; &quot;
+  read(0, buf, 1)
+  puts(buf)
+end
+
+puts(&quot;== test&quot;)
 test()
+puts(&quot;== input&quot;)
+input()
+puts(&quot;== exit&quot;)
+exit(7)
\ No newline at end of file</diff>
      <filename>example/simple.or</filename>
    </modified>
    <modified>
      <diff>@@ -34,8 +34,7 @@ module Orange
     end
     
     def assign(name, value)
-      # HACK assume *char for now
-      ptr = @entry_block.alloca(PCHAR, 0)
+      ptr = @entry_block.alloca(value_type(value), 0)
       @entry_block.store(value, ptr)
       @locals[name] = ptr
     end
@@ -75,6 +74,14 @@ module Orange
     private
       def define_external_functions
         @module.external_function(&quot;printf&quot;, Type.function(INT, [PCHAR], true))
+        @module.external_function(&quot;puts&quot;, Type.function(INT, [PCHAR]))
+        @module.external_function(&quot;read&quot;, Type.function(INT, [INT, PCHAR, INT]))
+        @module.external_function(&quot;exit&quot;, Type.function(INT, [INT]))
+      end
+      
+      TYPE_MAPPING = { 11 =&gt; PCHAR, 7 =&gt; INT }
+      def value_type(value)
+        TYPE_MAPPING[value.type.type_id]
       end
   end
 end
@@ -83,9 +90,11 @@ if __FILE__ == $PROGRAM_NAME
   g = Orange::Generator.new
   g.preamble
   g.function(&quot;test&quot;) do |gf|
-    str = gf.new_string(&quot;ohaie\n&quot;)
+    str = gf.new_string(&quot;&gt;&gt; %d\n&quot;)
+    num = gf.new_number(7)
     gf.assign(&quot;x&quot;, str)
-    gf.call(&quot;printf&quot;, gf.load(&quot;x&quot;))
+    gf.assign(&quot;y&quot;, num)
+    gf.call(&quot;printf&quot;, gf.load(&quot;x&quot;), gf.load(&quot;y&quot;))
   end
   g.call(&quot;test&quot;)
   g.finish</diff>
      <filename>lib/orange/generator.rb</filename>
    </modified>
    <modified>
      <diff>@@ -26,7 +26,7 @@ describe Orange::Generator do
     @generator.run
   end
 
-  it &quot;should call assign var&quot; do
+  it &quot;should call assign string var&quot; do
     str = @generator.new_string(&quot;&quot;)
     @generator.assign(&quot;x&quot;, str)
     @generator.call(&quot;printf&quot;, @generator.load(&quot;x&quot;))
@@ -37,4 +37,16 @@ describe Orange::Generator do
                                       &quot;load i8**&quot;)
     @generator.run
   end
+
+  it &quot;should call assign numeric var&quot; do
+    num = @generator.new_number(7)
+    @generator.assign(&quot;x&quot;, num)
+    @generator.call(&quot;printf&quot;, @generator.new_string(&quot;%d&quot;), @generator.load(&quot;x&quot;))
+    @generator.finish
+    
+    @generator.inspect.should include(&quot;alloca&quot;,
+                                      &quot;store i32 7&quot;,
+                                      &quot;load i32&quot;)
+    @generator.run
+  end
 end
\ No newline at end of file</diff>
      <filename>spec/generator_spec.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>35e4c43ed104b0d0258318f517d4e874ad05c81b</id>
    </parent>
  </parents>
  <author>
    <name>macournoyer</name>
    <email>macournoyer@gmail.com</email>
  </author>
  <url>http://github.com/macournoyer/orange/commit/48b8c83a080c57899ecd79b895c2efe32fa43f21</url>
  <id>48b8c83a080c57899ecd79b895c2efe32fa43f21</id>
  <committed-date>2008-10-28T20:07:42-07:00</committed-date>
  <authored-date>2008-10-28T20:07:42-07:00</authored-date>
  <message>Implement code generation for numbers, kind of a hack to guess the type of var...</message>
  <tree>3684d914c8b7e537c4b4990e262eb34db300bc3d</tree>
  <committer>
    <name>macournoyer</name>
    <email>macournoyer@gmail.com</email>
  </committer>
</commit>
