superinstance-flux-runtime 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/lib/superinstance/flux-runtime/assembler.rb +305 -0
- data/lib/superinstance/flux-runtime/cli.rb +190 -0
- data/lib/superinstance/flux-runtime/disassembler.rb +197 -0
- data/lib/superinstance/flux-runtime/exceptions.rb +49 -0
- data/lib/superinstance/flux-runtime/flux_vm.rb +1020 -0
- data/lib/superinstance/flux-runtime/loader.rb +55 -0
- data/lib/superinstance/flux-runtime/opcode.rb +141 -0
- data/lib/superinstance/flux-runtime/runtime/agent.rb +128 -0
- data/lib/superinstance/flux-runtime/runtime/opcode.rb +57 -0
- data/lib/superinstance/flux-runtime/version.rb +8 -0
- data/lib/superinstance-flux-runtime.rb +22 -0
- metadata +70 -0
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Flux
|
|
4
|
+
class FluxRuntimeError < StandardError
|
|
5
|
+
attr_reader :opcode, :pc
|
|
6
|
+
|
|
7
|
+
def initialize(message, opcode: nil, pc: nil)
|
|
8
|
+
super(message)
|
|
9
|
+
@opcode = opcode
|
|
10
|
+
@pc = pc
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
class HaltError < FluxRuntimeError
|
|
15
|
+
def initialize(pc = nil)
|
|
16
|
+
super('VM halted', opcode: :Halt, pc: pc)
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
class PanicError < FluxRuntimeError
|
|
21
|
+
def initialize(message = 'VM panicked', pc: nil, opcode: nil)
|
|
22
|
+
super(message, opcode: opcode || :Panic, pc: pc)
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
class YieldError < FluxRuntimeError
|
|
27
|
+
def initialize(pc = nil)
|
|
28
|
+
super('VM yielded', opcode: :Yield, pc: pc)
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
class UnknownOpcodeError < FluxRuntimeError
|
|
33
|
+
def initialize(opcode, pc = nil)
|
|
34
|
+
super("Unknown opcode: 0x#{opcode.to_s(16).upcase}", opcode: opcode, pc: pc)
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
class DivideByZeroError < FluxRuntimeError
|
|
39
|
+
def initialize(pc = nil)
|
|
40
|
+
super('Divide by zero', opcode: :IDiv, pc: pc)
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
class MemoryAccessError < FluxRuntimeError
|
|
45
|
+
def initialize(address, pc = nil)
|
|
46
|
+
super("Memory access error at address 0x#{address.to_s(16)}", pc: pc)
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
end
|