A toy dynamic programming language written in Ruby
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

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