Merge branch 'feat/codegen-for-function-calls' of github.com:AleoHQ/leo into feat/codegen-for-function-calls

This commit is contained in:
collin 2022-08-05 18:32:20 -07:00
commit c2b53f6d55
6 changed files with 44 additions and 7 deletions

View File

@ -33,7 +33,7 @@ Contains the Circuit's name, as well as its members.
The members are a function, or a variable, or a constant.
For all of them the Circuit preserves their names.
#### [Decorators](./src/functions/annotation.rs)
#### [Annotations](./src/functions/annotation.rs)
An annotation node is a decorator that can be applied to a function.
Stored on the function themselves despite being a top-level node.

View File

@ -83,10 +83,10 @@ impl<'a> CodeGenerator<'a> {
closures.push_str(&function_string);
closures.push('\n');
}
});
// Unset the `is_program_function` flag.
self.is_program_function = false;
// Unset the `is_program_function` flag.
self.is_program_function = false;
});
// Closures must precede functions in the Aleo program.
program_string.push_str(&closures);
@ -187,9 +187,6 @@ impl<'a> CodeGenerator<'a> {
let block_string = self.visit_block(&function.block);
function_string.push_str(&block_string);
// Unset `is_program_function` after visiting `function`.
self.is_program_function = false;
function_string
}
}

View File

@ -0,0 +1,28 @@
---
namespace: Parse
expectation: Pass
outputs:
- name: ""
network: ""
expected_input: []
imports: {}
functions:
"{\"name\":\"test\",\"span\":\"{\\\"lo\\\":94,\\\"hi\\\":98}\"}":
annotations:
- identifier: "{\"name\":\"test\",\"span\":\"{\\\"lo\\\":79,\\\"hi\\\":83}\"}"
span:
lo: 78
hi: 83
identifier: "{\"name\":\"test\",\"span\":\"{\\\"lo\\\":94,\\\"hi\\\":98}\"}"
input: []
output: U8
core_mapping: ~
block:
statements: []
span:
lo: 107
hi: 109
span:
lo: 85
hi: 109
circuits: {}

View File

@ -0,0 +1,5 @@
---
namespace: Parse
expectation: Fail
outputs:
- "Error [EPAR0370028]: Illegal spacing in the annotation declaration.\n --> test:3:1\n |\n 3 | @ test\n | ^^^^^^\n |\n = Remove whitespace between the `@` symbol and the identifier."

View File

@ -0,0 +1,7 @@
/*
namespace: Parse
expectation: Fail
*/
@ test
function test() -> u8 {}