Phasor
3.1.1
Stack VM based Programming Language
Loading...
Searching...
No Matches
__init__.py
Go to the documentation of this file.
1
"""
2
phasor
3
======
4
Python module for reading, writing, and manipulating Phasor VM bytecode.
5
6
-----------
7
Load a ``.phsb`` file::
8
9
from phasor import Bytecode
10
bc = Bytecode.load("program.phsb")
11
print(bc.disassemble())
12
13
Round-trip a bytecode object::
14
15
bc.save("copy.phsb")
16
bc2 = Bytecode.from_bytes(bc.to_bytes())
17
18
Extract bytecode from a compiled native binary (requires ``lief``)::
19
20
bc = Bytecode.from_native_binary("program")
21
22
Build bytecode programmatically::
23
24
from phasor import Bytecode, Value, OpCode
25
26
bc = Bytecode()
27
ci = bc.add_constant(Value.from_int(42))
28
bc.emit(OpCode.PUSH_CONST, ci)
29
bc.emit(OpCode.HALT)
30
bc.save("hello.phsb")
31
"""
32
33
from
.Bytecode
import
Bytecode
34
from
.Deserializer
import
BytecodeDeserializer
35
from
.Instruction
import
Instruction
36
from
.Metadata
import
MAGIC, VERSION
37
from
.Native
import
extract_phsb_bytes
38
from
.OpCode
import
OpCode
39
from
.Serializer
import
BytecodeSerializer
40
from
.Value
import
Value, ValueType
41
42
__all__ = [
43
"Bytecode"
,
44
"BytecodeDeserializer"
,
45
"BytecodeSerializer"
,
46
"Instruction"
,
47
"OpCode"
,
48
"Value"
,
49
"ValueType"
,
50
"extract_phsb_bytes"
,
51
"MAGIC"
,
52
"VERSION"
,
53
]
src
Extensions
py
phasor
__init__.py
Generated by
1.16.1