Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

A python script for generating enums with opcode constants based on YAML file definition

License

NotificationsYou must be signed in to change notification settings

tekord/cpp-opcode-generator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

A python script for generating enums with opcode constants based on YAML file definition. It may be useful forvirtual machine developers. Defining opcodes in external file instead of direct C++/Rust enum has some advantages:

  1. It is easier to read. Definition file contains only relevant information, no C++ code.
  2. You can automate a documentation building.
  3. Opcode definition is isolated from your virtual machine implementation, so you can use it in non-C++ implementation(of course you'll have to modify this script a little bit).

Written on Python 3.

Installation

Execute the following command to install dependencies:

pip install -r requirements.txt

Usage

Copy theopcodes.example.yaml file to your application's folder, define all the opcodes you need in this file.Then run the script with the following arguments:

python main.py <opcode-list> <language> [--output path/to/file]

whereopcode-list is a path to file with opcodes (.yaml file);language is one of the following options:c,cpp,rust;--output specified the output file path. If theoutput option is not provided then result willbe printed to the standard output.

The result may look like this:

enum _GeneratedOpCodes {    OPCODE_NOP =0x00,    OPCODE_B =0xA0,    OPCODE_BZ =0xA1,    OPCODE_B_FALSE =0xA1/* alias for BZ*/,    OPCODE_B_ZERO =0xA1/* alias for BZ*/,    OPCODE_B_NULL =0xA1/* alias for BZ*/,    OPCODE_BNZ =0xA2,    OPCODE_B_TRUE =0xA2/* alias for BNZ*/,    OPCODE_B_NOT_ZERO =0xA2/* alias for BNZ*/,    OPCODE_B_NOT_NULL =0xA2/* alias for BNZ*/};

About

A python script for generating enums with opcode constants based on YAML file definition

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors2

  •  
  •  

Languages


[8]ページ先頭

©2009-2025 Movatter.jp