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.

function_definition.rb 398B

12345678910111213141516171819
  1. class AST::FunctionDefinition
  2. attr_reader :name, :parameters, :body
  3. def initialize(name, parameters, body)
  4. @name = name
  5. @parameters = parameters
  6. @body = body
  7. end
  8. def ==(other)
  9. other.is_a?(AST::FunctionDefinition) && other.name == @name &&
  10. other.parameters == @parameters &&
  11. other.body == @body
  12. end
  13. def execute(env)
  14. env.set(@name.name, self)
  15. end
  16. end