1#! /your/favourite/path/to/ruby
2# -*- mode: ruby; coding: utf-8; indent-tabs-mode: nil; ruby-indent-level: 2 -*-
3# -*- frozen_string_literal: true; -*-
4# -*- warn_indent: true; -*-
5#
6# Copyright (c) 2017 Urabe, Shyouhei.  All rights reserved.
7#
8# This file is  a part of the programming language  Ruby.  Permission is hereby
9# granted, to  either redistribute and/or  modify this file, provided  that the
10# conditions  mentioned in  the file  COPYING are  met.  Consult  the file  for
11# details.
12
13require_relative '../helpers/c_escape'
14require_relative 'bare_instructions'
15
16class RubyVM::TraceInstructions
17  include RubyVM::CEscape
18
19  attr_reader :name
20
21  def initialize orig
22    @orig = orig
23    @name = as_tr_cpp "trace @ #{@orig.name}"
24  end
25
26  def pretty_name
27    return sprintf "%s(...)(...)(...)", @name
28  end
29
30  def jump_destination
31    return @orig.name
32  end
33
34  def bin
35    return sprintf "BIN(%s)", @name
36  end
37
38  def width
39    return @orig.width
40  end
41
42  def operands_info
43    return @orig.operands_info
44  end
45
46  def rets
47    return ['...']
48  end
49
50  def pops
51    return ['...']
52  end
53
54  def attributes
55    return []
56  end
57
58  def has_attribute? *;
59    return false
60  end
61
62  private
63
64  @instances = RubyVM::Instructions.map {|i| new i }
65
66  def self.to_a
67    @instances
68  end
69
70  RubyVM::Instructions.push(*to_a)
71end
72