mirror of
https://github.com/AleoHQ/leo.git
synced 2024-11-24 02:42:21 +03:00
update revs and examples
This commit is contained in:
parent
f505eb57ab
commit
a35606f628
937
Cargo.lock
generated
937
Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
@ -57,12 +57,12 @@ version = "1.5.3"
|
||||
|
||||
[dependencies.aleo]
|
||||
git = "https://github.com/AleoHQ/aleo.git"
|
||||
rev = "3911fd6"
|
||||
rev = "220e56"
|
||||
|
||||
[dependencies.snarkvm]
|
||||
#path = "../snarkVM"
|
||||
git = "https://github.com/AleoHQ/snarkVM.git"
|
||||
rev = "40972da"
|
||||
rev = "5657881"
|
||||
features = ["circuit", "console"]
|
||||
|
||||
[dependencies.backtrace]
|
||||
|
@ -156,7 +156,14 @@ impl<'a> CodeGenerator<'a> {
|
||||
fn visit_circuit_init(&mut self, input: &'a CircuitExpression) -> (String, String) {
|
||||
// Lookup circuit or record.
|
||||
let name = if let Some(type_) = self.composite_mapping.get(&input.name.name) {
|
||||
format!("{}.{}", input.name.to_string().to_lowercase(), type_)
|
||||
let name = input.name.to_string().to_lowercase();
|
||||
if name.eq("record") {
|
||||
// record.private;
|
||||
format!("{}.{}", name, type_)
|
||||
} else {
|
||||
// foo; // no visibility for interfaces
|
||||
format!("{}", name)
|
||||
}
|
||||
} else {
|
||||
unreachable!("All composite types should be known at this phase of compilation")
|
||||
};
|
||||
|
@ -1,3 +1,7 @@
|
||||
// The program input for message/src/main.leo
|
||||
// To pass "m" into the "main" function we
|
||||
// 1. Define the "Message" type.
|
||||
// 2. Use brackets `{ }` to enclose the circuit members.
|
||||
// 3. Define each circuit member `name : value`.
|
||||
[main]
|
||||
a: Message = Message { first: 2field, second: 3field };
|
||||
m: Message = Message { first: 2field, second: 3field };
|
||||
|
@ -1,10 +0,0 @@
|
||||
program message.aleo;
|
||||
interface message:
|
||||
first as field;
|
||||
second as field;
|
||||
|
||||
function main:
|
||||
input r0 as message.private;
|
||||
cast r0.first r0.second into r1 as message;
|
||||
add r1.first r1.second into r2;
|
||||
output r2 as field.private;
|
@ -1,13 +1,27 @@
|
||||
// The 'message' main function.
|
||||
// This example demonstrates the definition and initialization of a "circuit" type in Leo.
|
||||
// Circuit types are similar to composite types in other languages such as "struct".
|
||||
|
||||
// The "Message" circuit type.
|
||||
circuit Message {
|
||||
// A circuit member named "first" with type "field".
|
||||
first: field,
|
||||
// A circuit member named "second" with type "field".
|
||||
second: field,
|
||||
}
|
||||
|
||||
// The "main" function of this Leo program takes a "Message" circuit type as input.
|
||||
// To see how to input variable "m" is passed in open up `inputs/message.in`.
|
||||
function main(m: Message) -> field {
|
||||
|
||||
// 1. Define the "Message" type.
|
||||
// 2. Use brackets `{ }` to enclose the circuit members.
|
||||
// 3. Define each circuit member `name : value`.
|
||||
let m1: Message = Message {
|
||||
first: m.first,
|
||||
second: m.second,
|
||||
};
|
||||
|
||||
// Access the members of a circuit with dot syntax.
|
||||
// `circuit_name.member`
|
||||
return m1.first + m1.second;
|
||||
}
|
||||
|
@ -1,10 +0,0 @@
|
||||
program token.aleo;
|
||||
record token:
|
||||
owner as address.private;
|
||||
balance as u64.private;
|
||||
token_amount as u64.private;
|
||||
|
||||
function main:
|
||||
input r0 as token.record;
|
||||
add r0.token_amount r0.token_amount into r1;
|
||||
output r1 as u64.private;
|
@ -1,21 +0,0 @@
|
||||
program transfer.aleo;
|
||||
record token:
|
||||
owner as address.private;
|
||||
balance as u64.private;
|
||||
amount as u64.private;
|
||||
|
||||
function main:
|
||||
input r0 as address.private;
|
||||
input r1 as u64.private;
|
||||
token r0 0u64 r1 into r2;
|
||||
output r2 as token.record;
|
||||
|
||||
function transfer:
|
||||
input r0 as token.record;
|
||||
input r1 as address.private;
|
||||
input r2 as u64.private;
|
||||
sub r0.amount r2 into r3;
|
||||
token r1 0u64 r2 into r4;
|
||||
token r0.owner r0.balance r3 into r5;
|
||||
output r4 as token.record;
|
||||
output r5 as token.record;
|
Loading…
Reference in New Issue
Block a user