A toy dynamic programming language written in Ruby
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

class_definition.rb 556B

123456789101112131415161718192021
  1. class AST::ClassDefinition
  2. attr_reader :name, :members, :instance_methods, :class_methods
  3. def initialize(name, members, instance_methods, class_methods)
  4. @name = name
  5. @members = members
  6. @instance_methods = instance_methods
  7. @class_methods = class_methods
  8. end
  9. def ==(other)
  10. other.is_a?(AST::ClassDefinition) && other.name == @name &&
  11. other.members == @members &&
  12. other.instance_methods == @instance_methods
  13. other.class_methods == @class_methods
  14. end
  15. def execute(env)
  16. env.set(@name.name, self)
  17. end
  18. end