For MVP initial version:
- must support basic programming logic, math, functions, variables, collections etc
- must support json - encoding / decoding / traversal
- must have http client capability
- must have crypto capability, openssl
- should support usage of C libraries for general extension of capabilities
- does not need any disk / filesystem capability
- Should compile to LLVM IR -> native machine code
- Should executable via JIT and via native machine code
-
Identifiers
-
Newline characters
-
Value Declarations and definitions
-
Classes and Objects
-
Expressions
-
Top level definitions
-
Collections
-
Assets
-
Equality
-
Enums
-
Packages
-
Whitespace & Comments
-
Literals
-
Assignment
-
Local variables
-
Control expression
-
Requiring files
-
Types and methods
-
Exception handling
-
Type grammar
-
Low level primitives
asset Sword {
property attack : Int32 = 10
property defence : Int32 = 8
property health : Int32 = 20
expose property name : String = "Shining Sword"
-- special attacks
record SpecialAttack1(name : String, description : String, value : Int32)
record SpecialAttack2(name : String, description : String)
immutable special_attack_1 : SpecialAttack1 = SpecialAttack1("Destroy Health", "reduces health by 10", 10)
immutable special_attack_2 : SpecialAttack2 = SpecialAttack2("Mad Swapper", "swaps defence and health")
-- sends a transaction to update the attack property
expose def increase_attack(caller : Wallet, from_asset_id : Option(AssetId)) : Void {
Asset.update(caller, Sword.asset_id, :attack, @attack += 1)
}
expose def decrease_attack(caller : Wallet, from_asset_id : Option(AssetId)) : Void {
Asset.update(caller, Sword.asset_id, :attack, @attack -= 1)
}
-- invokes the specified asset with the function to invoke
-- and any properties marked with expose
expose def execute_special_attack_1(caller : Wallet, opponent_asset_id : AssetId, from_asset_id : Option(AssetId)) : Void {
Asset.invoke(caller, opponent_asset_id, :receive_special_attack_1, Asset.encode(self))
}
}
asset Shield {
property health : Int32 = 30
expose property name : String = "Golden Shield"
expose def receive_special_attack_1(caller : Wallet, from_asset_id : AssetId, asset_data : EncodedAssetData) : Void {
from_asset : Sword = Asset.decode(asset_data)
name = from_asset.name
health = @health - from_asset(:special_attack_1).value
Asset.update(caller, Shield.asset_id, :health, health)
}
}