Skip to content

Releases: Sin7Y/ola-lang

pre-alpha

08 Feb 04:34
Compare
Choose a tag to compare
style: 💄 fmt all files

v0.1.1

31 Jan 02:00
Compare
Choose a tag to compare
add debug_print test dependency.

release v0.1.0

08 Nov 04:31
Compare
Choose a tag to compare

Ola language features

Language Type

  • Simple Types: Includes u32, field, bool, enum, address, and hash types. In Ola, all data types are internally represented as combinations of the field type. The maximum value for the field type is 0xFFFFFFFF00000001. The address and hash types are internally represented as arrays of four field elements.
  • Complex Types: Includes static arrays, dynamic arrays, string, fields, structures, and mappings. The fields type is a dynamic array of field elements.
  • Type Aliases: Support for type aliases is included.

Operators

  • Different types support different operators. The u32 type supports the most operators, such as: +, -, *, /, %, **, ==, !=, etc.

Functions

  • Functions are supported in a manner similar to Solidity and Rust, with the keyword fn used to declare functions.

Control Flow

  • Control flow constructs include if statements, if-else statements, while statements, do-while statements, for loops, continue, and break.

Prophet Functions

  • The prophet functions in Ola language are used for non-deterministic computations in specific scenarios, such as u32_sqrt, u32_quick_sort, etc.

Core Lib Functions

  • The ola language provides many core libraries, including assert ,print fileds_conct, encode decode, and so on.

IR Generation

  • The Ola language is processed by the front-end into a subset of LLVM IR for compilation.

Olac Back-End

The LLVM IR subset generated by the Olac compiler front-end is downgraded to OlaVM bytecode for execution by the OlaVM virtual machine.

Supported LLVM IR Subset

Type System:

  • void type
  • Function type
  • Single-value types within the first-order type support i64, i1, ptr types
  • label and token types
  • Aggregate types such as arrays and structures

Instruction Set:

  • Terminal instructions: ret, br, switch
  • Unary operation: neg
  • Binary operations: add, sub, mul
  • Logical operations: and, or, xor
  • Aggregate operations: insertvalue, extractvalue
  • Memory access and addressing: alloca, store, load, getelementptr
  • Conversion instruction: trunc
  • Other operations: icmp, phi, call

Supported IR Libs Extensions

  • Includes built-ins and prophets: assert, rangecheck, u32_sqrt, div, mod, vec_new, poseidon_hash
  • Contract storage access operations: set_storage, get_storage
  • Contract input/output access operations: get_context_data, get_tape_data, set_tape_data
  • Debugging: printf
  • Cross-contract calls: contract_call

OlaVM Assembly

  • The assembly language consists of the program and prophet parts, executed directly by the VM and interpreted by the embedded interpreter, respectively.
  • program part: Defines the assembly output format, supporting the entire OlaVM custom instruction set.
  • prophet part: Refers to the prophets set described in the IR libs extension.

Future Work

  • Introduction of a testing framework, more orderly language design, and robust compiler engineering implementation.
  • Heap memory allocation and management reconstruction, more streamlined instruction generation.
  • Optimization of code generation for front-end and back-end, higher efficiency in instruction generation and execution.
  • Design of object-oriented syntax for contracts, enhancing the language's expressive power.
  • Expansion of privacy features in contracts, supporting ZK privacy contract programming.