 
   # Make sure that a constructor is defined for the class, and properly
   # configured.
-  ensureConstructor: (name) ->
-    if not @ctor
-      @ctor = new Code
-      @ctor.body.push new Literal "#{name}.__super__.constructor.apply(this, arguments)" if @parent
-      @ctor.body.push new Literal "#{@externalCtor}.apply(this, arguments)" if @externalCtor
-      @ctor.body.makeReturn()
+  ensureConstructor: (name, o) ->
+    missing = not @ctor
+    @ctor or= new Code
+    @ctor.ctor = @ctor.name = name
+    @ctor.klass = null
+    @ctor.noReturn = yes
+    if missing
+      superCall = new Literal "#{name}.__super__.constructor.apply(this, arguments)" if @parent
+      superCall = new Literal "#{@externalCtor}.apply(this, arguments)" if @externalCtor
+      if superCall
+        ref = new Literal o.scope.freeVariable 'ref'
+        @ctor.body.unshift new Assign ref, superCall
+      @addBoundFunctions o
+      if superCall
+        @ctor.body.push ref
+        @ctor.body.makeReturn()
       @body.expressions.unshift @ctor
-    @ctor.ctor     = @ctor.name = name
-    @ctor.klass    = null
-    @ctor.noReturn = yes
+    else
+      @addBoundFunctions o
+
 
   # Instead of generating the JavaScript string directly, we build up the
   # equivalent syntax tree and compile that, in pieces. You can see the

    @hoistDirectivePrologue()
    @setContext name
    @walkBody name, o
    @ensureConstructor name
    @body.spaced = yes
    @body.expressions.unshift @ctor unless @ctor instanceof Code
    @body.expressions.push lname
    @body.expressions.unshift @directives...
    @addBoundFunctions o

    call  = Closure.wrap @body


        body = new Block [new Return new Literal "#{@ctor.name}.prototype.#{name.value}.apply(_this, arguments)"]
        rhs = new Code func.params, body, 'boundfunc'
        bound = new Assign lhs, rhs
        @ctor.body.push bound
    return

  # Merge the properties from a top-level object as prototypal properties
