class NScript::ExtendsNode

Public Class Methods

new(sub_object, super_object) click to toggle source
# File lib/nscript/parser/nodes.rb, line 256
def initialize(sub_object, super_object)
  @sub_object, @super_object = sub_object, super_object
end

Public Instance Methods

compile_node(o={}) click to toggle source
# File lib/nscript/parser/nodes.rb, line 260
def compile_node(o={})
  constructor = o[:scope].free_variable
  sub, sup = @sub_object.compile(o), @super_object.compile(o)
  "#{idt}#{constructor} = function(){};\n#{idt}" +
  "#{constructor}.prototype = #{sup}.prototype;\n#{idt}" +
  "#{sub}.__superClass__ = #{sup}.prototype;\n#{idt}" +
  "#{sub}.prototype = new #{constructor}();\n#{idt}" +
  "#{sub}.prototype.constructor = #{sub};"
end