vm/codegen/instructions_gen.rb
# Wraps instruction implementation code provided by instructions.rb.
# It also captures some meta info using parsetree to generate
# better output.
#
Wraps instruction implementation code provided by instructions.rb.
It also captures some meta info using parsetree to generate
better output.
Wraps instruction implementation code provided by instructions . rb . It also captures some meta info using parsetree to generate better output .
def generate_implementation_info
    str = ""
    size = InstructionSet::OpCodes.size
    str << "const Implementation* implementation(int op) {\n"
    str << "static Implementation implementations[] = {\n"
    InstructionSet::OpCodes.each do |ins|
      str << "{ (void*)op_#{ins.opcode.to_s}, \"op_#{ins.opcode.to_s}\" },\n"
    end
    str << " { NULL, NULL} };\n"
    str << " if(op >= #{size}) return NULL;\n"
    str << " return &implementations[op]; }\n"
    str << "Status check_status(int op) {\n"
    str << "static Status check_status[] = {\n"
    methods = decode_methods()
    methods.each do |impl|
      if [:return, :raise].include?(impl.name.flow)
        str << "Terminate,\n"
      elsif impl.custom_continue?
        str << "MightReturn,\n"
      else
        str << "Unchanged,\n"
      end
    end
    str << " Unchanged };\n"
    str << "if(op >= #{size}) return Unchanged;\n"
    str << "return check_status[op]; }"
    str << "\n"
    str << generate_superinst_finder()
    str
  end
def generate_implementation_info str = "" size = InstructionSet :: OpCodes . size str << "const Implementation* implementation(int op) {\n" str << "static Implementation implementations[] = {\n" InstructionSet :: OpCodes . each do | ins | str << "{ (void*)op_#{ins.opcode.to_s}, \"op_#{ins.opcode.to_s}\" },\n" end str << " { NULL, NULL} };\n" str << " if(op >= #{size}) return NULL;\n" str << " return &implementations[op]; }\n" str << "Status check_status(int op) {\n" str << "static Status check_status[] = {\n" methods = decode_methods ( ) methods . each do | impl | if [ :return , :raise ] . include? ( impl . name . flow ) str << "Terminate,\n" elsif impl . custom_continue? str << "MightReturn,\n" else str << "Unchanged,\n" end end str << " Unchanged };\n" str << "if(op >= #{size}) return Unchanged;\n" str << "return check_status[op]; }" str << "\n" str << generate_superinst_finder ( ) str end
Wraps instruction implementation code provided by instructions.rb.
Wraps instruction implementation code provided by instructions . rb .