-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbytecode.rb
More file actions
16 lines (14 loc) · 799 Bytes
/
bytecode.rb
File metadata and controls
16 lines (14 loc) · 799 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
# frozen_string_literal: true
require 'ostruct'
class Bytecode
INFO = Hash[*File.readlines("#{__dir__}/bytecode.csv", chomp: true)
.select { |x| !x.start_with? '#' }
.map { |x| x.split(', ').map(&:strip) }
.map { |x| [x[1].to_sym, OpenStruct.new(code: x[0].to_i,
opcode: x[1].to_sym,
format: x[2],
return: x[3].to_sym,
stack: x[4].to_i,
pop: x[5].to_i,
push: x[6].to_i)]}.flatten]
end