Skip to main content

Crate huff_neo_core

Crate huff_neo_core 

Source
Expand description

§Huff Core

Core Compiler for the Huff Language.

§Usage

Compiling source code with the Compiler is very straightforward.

Once you instantiate a Compiler (WLOG, compiler) with the file source, you can generate the compiled artifacts by simply running:

ⓘ
let artifacts: Result<Vec<Artifact>, CompilerError> = compiler.execute();

Below we demonstrate taking a source file ../../resources/erc20/ERC20.huff, and generating the compiled artifacts.

use huff_neo_core::Compiler;
use huff_neo_utils::error::CompilerError;
use huff_neo_utils::artifact::Artifact;
use huff_neo_utils::prelude::EVMVersion;
use std::sync::Arc;
use std::cell::RefCell;
use std::rc::Rc;

// Instantiate the Compiler Instance with a targeted evm version.
let evm_version = &EVMVersion::default();
let mut compiler = Compiler::new(evm_version, Arc::new(vec!["../../resources/erc20/ERC20.huff".to_string()]), None, None, None, None, None, false, false);

// Execute the compiler
let res: Result<Vec<Arc<Artifact>>, Arc<CompilerError>> = compiler.execute();
assert!(res.is_ok());

The Compiler is easily configurable upon instantiation.

§Inner Workings

The Compiler is composed of several compilation phases and bundles them together in one process.


[Files] -> Lexer -> Parser -> Codegen -> [Bytecode]

Modules§

cache 🔒

Structs§

Compiler
The Core Huff Compiler