base/AbstractSyntaxTree.rb in maroon-0.7.1 vs base/AbstractSyntaxTree.rb in maroon-0.8.0

- old
+ new

@@ -7,11 +7,11 @@ role :production do def is_role? case when production.is_call? && (interpretation_context.roles.has_key?(production[2])) - @date = [production[2]] + @data = [production[2]] return true when (production == :self || (production.is_indexer? && (production[1] == nil || production[1] == :self)) || (production && ((production.instance_of?(Sexp) || production.instance_of?(Array)) && production[0] == :self))) && @interpretation_context.defining_role @data = @interpretation_context.defining_role @@ -52,18 +52,35 @@ true end end end end - + def is_const? + if production.instance_of?(Sexp) && production.length == 2 && production[0] == :const && (production[1].instance_of? Symbol) + @data = [production[1]] + true + else + false + end + end + def is_initializer? + if production.is_call? + if AbstractSyntaxTree.new(production[1], @interpretation_context).type == Tokens::const + if production[2] == :new + return true + end + end + end + false + end def is_rolemethod_call? can_be = production.is_call? if can_be instance = AbstractSyntaxTree.new(production[1], @interpretation_context) can_be = instance.type == Tokens::role if can_be - instance_data = instance.data + instance_data = instance.data[0] role = @interpretation_context.roles[instance_data] data = production[2] can_be = role.has_key?(data) @data = [data, instance_data] @@ -91,9 +108,13 @@ Tokens::rolemethod_call when production.is_role? Tokens::role when production.is_indexer? Tokens::indexer + when production.is_const? + Tokens::const + when production.is_initializer? + Tokens::initializer when production.is_call? Tokens::call else Tokens::other end \ No newline at end of file