vm/codegen/instructions_gen.rb
# Using an array of Implementation objects, +methods+, print a switch
# statement which decodes the arguments and calls the function that
# contains the implementation of the instruction.
#
Using an array of Implementation objects, +methods+, print a switch
statement which decodes the arguments and calls the function that
contains the implementation of the instruction.
Using an array of Implementation objects + methods + print a switch statement which decodes the arguments and calls the function that contains the implementation of the instruction .
def generate_decoder_switch(methods, io, flow=false)
    io.puts "switch(op) {"
    methods.each do |impl|
      io.puts "  case #{impl.name.bytecode}: { // #{impl.name.opcode}"
      args = impl.args
      case args.size
      when 2
        io.puts "  int #{args[0]} = next_int;"
        io.puts "  int #{args[1]} = next_int;"
        io.puts "  #{impl.body}"
      when 1
        io.puts "  int #{args[0]} = next_int;"
        io.puts "  #{impl.body}"
      when 0
        io.puts "  #{impl.body}"
      end
      io.puts "  break;"
      io.puts "  }"
    end
    io.puts "default:"
    io.puts %q!  std::cout << "Invalid instruction: " << InstructionSequence::get_instruction_name(op) << "\n"; abort();!
    io.puts "}"
  end
def generate_decoder_switch ( methods , io , flow = false ) io . puts "switch(op) {" methods . each do | impl | io . puts "  case #{impl.name.bytecode}: { // #{impl.name.opcode}" args = impl . args case args . size when 2 io . puts "  int #{args[0]} = next_int;" io . puts "  int #{args[1]} = next_int;" io . puts "  #{impl.body}" when 1 io . puts "  int #{args[0]} = next_int;" io . puts "  #{impl.body}" when 0 io . puts "  #{impl.body}" end io . puts "  break;" io . puts "  }" end io . puts "default:" io . puts %q!  std::cout << "Invalid instruction: " << InstructionSequence::get_instruction_name(op) << "\n"; abort();! io . puts "}" end
Using an array of Implementation objects, +methods+, print a switch
statement which decodes the arguments and calls the function that
contains the implementation of the instruction.
Using an array of Implementation objects + methods + print a switch statement which decodes the arguments and calls the function that contains the implementation of the instruction .
methods
<not_specific>
io
<not_specific>
flow
<not_specific>