Method: Gruesome::Z::Opcode.name

Defined in:
lib/gruesome/z/opcode.rb

.name(opcode, version) ⇒ Object



358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
# File 'lib/gruesome/z/opcode.rb', line 358

def Opcode.name(opcode, version)
  opcode_class = opcode & 7
  if not is_valid?(opcode, version)
    "invalid"
  elsif opcode_class == OpcodeClass::OP0
    case opcode
    when Opcode::RTRUE then "rtrue"
    when Opcode::RFALSE then "rfalse"
    when Opcode::PRINT then "print"
    when Opcode::PRINT_RET then "print_ret"
    when Opcode::NOP then "nop"
    when Opcode::SAVE then "save"
    when Opcode::RESTORE then "restore"
    when Opcode::RESTART then "restart"
    when Opcode::RET_POPPED then "ret_popped"
    when Opcode::POP, Opcode::CATCH
      if version <= 4
        "pop"
      else
        "catch"
      end
    when Opcode::QUIT then "quit"
    when Opcode::NEW_LINE then "new_line"
    when Opcode::SHOW_STATUS then "show_status"
    when Opcode::VERIFY then "verify"
    when Opcode::PIRACY then "piracy"
    end
  elsif opcode_class == OpcodeClass::OP1
    case opcode
    when Opcode::JZ then "jz"
    when Opcode::GET_SIBLING then "get_sibling"
    when Opcode::GET_CHILD then "get_child"
    when Opcode::GET_PARENT then "get_parent"
    when Opcode::GET_PROP_LEN then "get_prop_len"
    when Opcode::INC then "inc"
    when Opcode::DEC then "dec"
    when Opcode::PRINT_ADDR then "print_addr"
    when Opcode::CALL_1S then "call_1s"
    when Opcode::REMOVE_OBJ then "remove_obj"
    when Opcode::PRINT_OBJ then "print_obj"
    when Opcode::RET then "ret"
    when Opcode::JUMP then "jump"
    when Opcode::PRINT_PADDR then "print_paddr"
    when Opcode::LOAD then "load"
    when Opcode::NOT, CALL_1N
      if version <= 4
        "not"
      else
        "call_1n"
      end
    end
  elsif opcode_class == OpcodeClass::OP2
    case opcode
    when Opcode::JE then "je"
    when Opcode::JL then "jl"
    when Opcode::JG then "jg"
    when Opcode::DEC_CHK then "dec_chk"
    when Opcode::INC_CHK then "inc_chk"
    when Opcode::JIN then "jin"
    when Opcode::TEST then "test"
    when Opcode::OR then "or"
    when Opcode::AND then "and"
    when Opcode::TEST_ATTR then "test_attr"
    when Opcode::SET_ATTR then "set_attr"
    when Opcode::CLEAR_ATTR then "clear_attr"
    when Opcode::STORE then "store"
    when Opcode::INSERT_OBJ then "insert_obj"
    when Opcode::LOADW then "loadw"
    when Opcode::LOADB then "loadb"
    when Opcode::GET_PROP then "get_prop"
    when Opcode::GET_PROP_ADDR then "get_prop_addr"
    when Opcode::GET_NEXT_PROP then "get_next_prop"
    when Opcode::ADD then "add"
    when Opcode::SUB then "sub"
    when Opcode::MUL then "mul"
    when Opcode::DIV then "div"
    when Opcode::MOD then "mod"
    when Opcode::CALL_2S then "call_2s"
    when Opcode::CALL_2N then "call_2n"
    when Opcode::SET_COLOUR then "set_colour"
    when Opcode::THROW then "throw"
    end
  elsif opcode_class == OpcodeClass::VAR
    case opcode
    when Opcode::CALL, Opcode::CALL_VS
      if version < 4
        "call"
      else
        "call_vs"
      end
    when Opcode::STOREW then "storew"
    when Opcode::STOREB then "storeb"
    when Opcode::PUT_PROP then "put_prop"
    when Opcode::SREAD, Opcode::AREAD
      if version < 5
        "sread"
      else
        "aread"
      end
    when Opcode::PRINT_CHAR then "print_char"
    when Opcode::PRINT_NUM then "print_num"
    when Opcode::RANDOM then "random"
    when Opcode::PUSH then "push"
    when Opcode::PULL then "pull"
    when Opcode::SPLIT_WINDOW then "split_window"
    when Opcode::SET_WINDOW then "set_window"
    when Opcode::CALL_VS2 then "call_vs2"
    when Opcode::ERASE_WINDOW then "erase_window"
    when Opcode::ERASE_LINE then "erase_line"
    when Opcode::SET_CURSOR then "set_cursor"
    when Opcode::GET_CURSOR then "get_cursor"
    when Opcode::SET_TSTYLE then "set_text_style"
    when Opcode::BUFFER_MODE then "buffer_mode"
    when Opcode::OUTPUT_STREAM then "output_stream"
    when Opcode::INPUT_STREAM then "input_stream"
    when Opcode::SOUND_EFFECT then "sound_effect"
    when Opcode::READ_CHAR then "read_char"
    when Opcode::SCAN_TABLE then "scan_table"
    when Opcode::NOT_2 then "not"
    when Opcode::CALL_VN then "call_vn"
    when Opcode::CALL_VN2 then "call_vn2"
    when Opcode::TOKENIZE then "tokenize"
    when Opcode::ENCODE_TEXT then "encode_text"
    when Opcode::COPY_TABLE then "copy_table"
    when Opcode::PRINT_TABLE then "print_table"
    when Opcode::CHECK_ARG_COUNT then "check_arg_count"
    end
  elsif opcode_class == OpcodeClass::EXT
    case opcode
    when Opcode::SAVE_TABLE then "save_table"
    when Opcode::RESTORE_TABLE then "restore_table"
    when Opcode::LOG_SHIFT then "log_shift"
    when Opcode::ART_SHIFT then "art_shift"
    when Opcode::SET_FONT then "set_font"
    when Opcode::DRAW_PICTURE then "draw_picture"
    when Opcode::PICTURE_DATA then "picture_data"
    when Opcode::ERASE_PICTURE then "erase_picture"
    when Opcode::SET_MARGINS then "set_margins"
    when Opcode::SAVE_UNDO then "save_undo"
    when Opcode::RESTORE_UNDO then "restore_undo"
    when Opcode::PRINT_UNICODE then "print_unicode"
    when Opcode::CHECK_UNICODE then "check_unicode"
    when Opcode::MOVE_WINDOW then "move_window"
    when Opcode::WINDOW_SIZE then "window_size"
    when Opcode::WINDOW_STYLE then "window_style"
    when Opcode::GET_WIND_PROP then "get_wind_prop"
    when Opcode::SCROLL_WINDOW then "scroll_window"
    when Opcode::POP_STACK then "pop_stack"
    when Opcode::READ_MOUSE then "read_mouse"
    when Opcode::MOUSE_WINDOW then "mouse_window"
    when Opcode::PUSH_STACK then "push_stack"
    when Opcode::PUT_WIND_PROP then "put_wind_prop"
    when Opcode::PRINT_FORM then "print_form"
    when Opcode::MAKE_MENU then "make_menu"
    when Opcode::PICTURE_TABLE then "picture_table"
    end
  end
end