Skip to content

Latest commit

 

History

History
37 lines (28 loc) · 600 Bytes

README.md

File metadata and controls

37 lines (28 loc) · 600 Bytes

Codon plugin example

This repo implements an example plugin for Codon called MyValidate, which works on the following code:

def foo(x):
    return x*3 + x

def validate(x, y):
    print('validate called!')
    assert y == x*4

a = foo(10)
b = foo(1.5)
c = foo('a')

The plugin includes a Codon IR pass that inserts calls to validate() after calls to foo().

To build the plugin:

export LLVM_DIR=/path/to/lib/cmake/llvm
mkdir build
cd build
cmake ..
make

To use:

codon run -release -plugin /path/to/example-codon-plugin test.py