<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -57,7 +57,6 @@ module Duby
         @file = BiteScript::FileBuilder.new(@filename)
         AST.type_factory.define_types(@file)
         @type = AST::type(classname)
-        @class = @type.define(@file)
       end
 
       def compile(ast, expression = false)
@@ -65,19 +64,29 @@ module Duby
         log &quot;Compilation successful!&quot;
       end
 
+      def toplevel_class
+        @class = @type.define(@file)
+      end
+
       def define_main(body)
-        with :method =&gt; @class.main do
-          log &quot;Starting main method&quot;
+        if body.class != AST::ClassDefinition
+          @class = @type.define(@file)
+          with :method =&gt; @class.main do
+            log &quot;Starting main method&quot;
 
-          @method.start
+            @method.start
 
-          # declare argv variable
-          @method.local('argv', AST.type('string', true))
+            # declare argv variable
+            @method.local('argv', AST.type('string', true))
 
-          body.compile(self, false)
+            body.compile(self, false)
 
-          @method.returnvoid
-          @method.stop
+            @method.returnvoid
+            @method.stop
+          end
+          @class.stop
+        else
+          body.compile(self, false)
         end
 
         log &quot;Main method complete!&quot;
@@ -561,7 +570,6 @@ module Duby
       end
       
       def generate
-        @class.stop
         log &quot;Generating classes...&quot;
         @file.generate do |filename, builder|
           log &quot;  #{builder.class_name}&quot;</diff>
      <filename>lib/duby/jvm/compiler.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>c625ae98dee7c8da5d92cdf02414b76e268d64a0</id>
    </parent>
  </parents>
  <author>
    <name>Charles Oliver Nutter</name>
    <email>headius@headius.com</email>
  </author>
  <url>http://github.com/headius/duby/commit/39a665517398bc960a80ee52dc5a9a3285f82277</url>
  <id>39a665517398bc960a80ee52dc5a9a3285f82277</id>
  <committed-date>2009-11-07T08:40:20-08:00</committed-date>
  <authored-date>2009-11-07T08:40:20-08:00</authored-date>
  <message>If the root node of a script is a ClassDefinition, don't output a .class for the containing script.</message>
  <tree>38de323586304bfb6092175ec6a5c6cb5eba52aa</tree>
  <committer>
    <name>Charles Oliver Nutter</name>
    <email>headius@headius.com</email>
  </committer>
</commit>
