documentation waypoint

This commit is contained in:
Jeremy Ashkenas
2009-12-21 11:41:45 -05:00
parent dcc70e5ab0
commit c7fa9c320a
42 changed files with 1026 additions and 53 deletions

View File

@@ -110,6 +110,10 @@ module CoffeeScript
STATEMENTS.include?(@value.to_s)
end
def line_ending
@value.to_s[-1..-1] == ';' ? '' : ';'
end
def compile(indent, scope, opts={})
code = @value.to_s
write(code)
@@ -171,6 +175,20 @@ module CoffeeScript
end
end
class ExtendNode < Node
attr_reader :subclass, :superclass
def initialize(subclass, superclass)
@subclass, @superclass = subclass, superclass
end
def compile(indent, scope, opts={})
"#{@subclass}.prototype = #{@superclass.compile(indent, scope, opts)}"
end
end
# A value, indexed or dotted into, or vanilla.
class ValueNode < Node
attr_reader :literal, :properties, :last
@@ -269,7 +287,7 @@ module CoffeeScript
def compile(indent, scope, opts={})
name = @variable.respond_to?(:compile) ? @variable.compile(indent, scope) : @variable
last = @variable.respond_to?(:last) ? @variable.last : name
last = @variable.respond_to?(:last) ? @variable.last.to_s : name.to_s
opts = opts.merge({:assign => name, :last_assign => last})
return write("#{@variable}: #{@value.compile(indent, scope, opts)}") if @context == :object
return write("#{name} = #{@value.compile(indent, scope, opts)}") if @variable.properties?