Skip to content
This repository has been archived by the owner on Jan 17, 2021. It is now read-only.

Latest commit

 

History

History
57 lines (49 loc) · 1.21 KB

README.md

File metadata and controls

57 lines (49 loc) · 1.21 KB

Functions

Sample input file

Type:
int32
bool
binaryop = (int32, int32) -> int32

Symbol:
add(int32, int32) -> int32
subtract(int32, int32) -> int32
randomop() -> binaryop

Function:
f1: (int32, int32, int32) -> int32
f2: (binaryop) -> int32
f3: (int32, int32, int32, int32) -> int32
f4: () -> int32
f5: (int32, int32) -> binaryop

Usage (Swift)

let encoding = f1Encode { o1, o2, o3 in
    subtract(
        add(o1, 2 as Int32),
        add(o2, o3)
    )
}
class Implementation: Symbols {
    func add(_ o1: Int32, _ o2: Int32) -> Int32 {
        return o1 + o2
    }
    func subtract(_ o1: Int32, _ o2: Int32) -> Int32 {
        return o1 - o2
    }
    func randomop() -> binaryop {
        return { o1, o2 in o1 * o2 }
    }
}

let function = try! f1Decode(function: encoding, symbols: Implementation())
assert(function(1, 2, 3) == -2)

Getting Started

  1. Write specification file (See sample input)
  2. Compile specification to protobuf file and source code file 1
  3. Compile protobuf file to source code file 2
  4. Add both source code file 1 and 2 to your project

Demo

Demos mentioned in the report can be found on the releases page