Phasor 3.1.1
Stack VM based Programming Language
Loading...
Searching...
No Matches
phasor Namespace Reference

Namespaces

namespace  Bytecode
namespace  Deserializer
namespace  Instruction
namespace  Native
namespace  OpCode
namespace  Serializer
namespace  Value

Variables

list __all__

Detailed Description

phasor
======
Python module for reading, writing, and manipulating Phasor VM bytecode.

-----------
Load a ``.phsb`` file::

    from phasor import Bytecode
    bc = Bytecode.load("program.phsb")
    print(bc.disassemble())

Round-trip a bytecode object::

    bc.save("copy.phsb")
    bc2 = Bytecode.from_bytes(bc.to_bytes())

Extract bytecode from a compiled native binary (requires ``lief``)::

    bc = Bytecode.from_native_binary("program")

Build bytecode programmatically::

    from phasor import Bytecode, Value, OpCode

    bc = Bytecode()
    ci = bc.add_constant(Value.from_int(42))
    bc.emit(OpCode.PUSH_CONST, ci)
    bc.emit(OpCode.HALT)
    bc.save("hello.phsb")

Variable Documentation

◆ __all__

list phasor.__all__
private
Initial value:
1= [
2 "Bytecode",
3 "BytecodeDeserializer",
4 "BytecodeSerializer",
5 "Instruction",
6 "OpCode",
7 "Value",
8 "ValueType",
9 "extract_phsb_bytes",
10 "MAGIC",
11 "VERSION",
12]

Definition at line 42 of file __init__.py.