Panduan pengembangan bahasa pemrograman RiQi — smart contract language yang dirancang security-first untuk blockchain Skylum, mencakup compiler, VM, static analyzer, dan optimization engine.
Skill ini memberikan panduan lengkap untuk pengembangan bahasa pemrograman RiQi — bahasa smart contract kustom yang dirancang dengan prinsip keamanan-pertama (security-first) untuk blockchain Skylum.
riqi_compiler/ — Compiler utama (lexer, parser, codegen)riqi_code/ — Runtime & opcode definitionsriqi-lang/compiler/ — Compiler frontendriqi-lang/vm/ — Virtual Machineriqi-lang/static-analyzer/ — Static analysis toolsriqi-lang/optimization-engine/ — Bytecode optimizationriqi-lang/vscode-extension/ — VS Code language supportriqi-lang/examples/ — Contoh kode RiQi| Fitur | Detail |
|---|---|
| Immutability Default | let x = 5; → immutable. let mut x = 5; → mutable |
| View/Exec Separation | fn get() view { } vs fn set() exec { } |
| No While Loops | Hanya for item in collection — mencegah infinite loop |
| Checked Arithmetic | Integer overflow/underflow detection bawaan |
| Re-entrancy Guard | Ownership model mencegah re-entrancy attack |
Source Code (.rq)
│
▼
┌──────────┐
│ Lexer │ → Token stream
└──────────┘
│
▼
┌──────────┐
│ Parser │ → AST (Abstract Syntax Tree)
└──────────┘
│
▼
┌────────────────┐
│ Static Analyzer│ → Warnings, errors, security checks
└────────────────┘
│
▼
┌──────────────────┐
│ Optimization │ → Optimized AST
│ Engine │
└──────────────────┘
│
▼
┌──────────────┐
│ Code Generator│ → Bytecode for Skylum VM
└──────────────┘
│
▼
┌──────────────┐
│ Skylum VM │ → Execution on-chain
└──────────────┘
// Immutable (default, aman)
let nama_proyek: string = "Proyek Skylum";
let versi: uint = 1;
// Mutable (harus eksplisit)
let mut counter: uint = 0;
counter = counter + 1; // Valid
struct InfoRoyalti {
penerima: Alamat,
persentase: uint16
}
struct AsetUnik {
id: uint,
pemilik: Alamat,
royalti: InfoRoyalti
}
// Read-only function (tidak bisa mengubah state)
fn dapatkan_info(id: uint) -> AsetUnik view {
// ... hanya baca state ...
}
// State-changing function
fn transfer_aset(id: uint, pemilik_baru: Alamat) -> bool exec {
// ... bisa mengubah state ...
}
// If/Else
if (kondisi) {
// ...
} else {
// ...
}
// For loop (SATU-SATUNYA jenis loop yang diizinkan)
for item in koleksi {
// ...
}
Span (posisi dalam source)OP_PUSH, OP_POP — Stack manipulationOP_ADD, OP_SUB, OP_MUL, OP_DIV — ArithmeticOP_SSTORE, OP_SLOAD — State storage (PRIORITAS FASE 8)OP_JUMP, OP_JUMPI — Control flowOP_CALL — External contract callOP_RETURN — Return valueOP_REVERT — Revert transactionOP_MINT_ASSET — Native asset minting (protocol integration)view functionsriqi-lang/examples/ harus bisa dikompilasi dan dijalankanOP_SSTORE / OP_SLOAD — State storage opcodesif/else logic di VM levelmut dan view/exec di level compilerOP_CALL)ASSET_SALE_TRANSFER di level bahasa