mirror of
https://github.com/AleoHQ/leo.git
synced 2024-12-29 20:44:52 +03:00
add circuit self keyword wip
This commit is contained in:
parent
a78d077d40
commit
36b2508de3
@ -384,7 +384,8 @@ import [package].*;
|
||||
```
|
||||
|
||||
### Local
|
||||
You can import from a local file in the `src/` directory by using its `[file].leo` as the `[package]` name.
|
||||
You can import from a local file in the same package using its direct path.
|
||||
`src/` directory by using its `[file].leo` as the `[package]` name.
|
||||
|
||||
```rust
|
||||
import [file].[name];
|
||||
|
@ -34,6 +34,8 @@ use snarkos_models::{
|
||||
},
|
||||
};
|
||||
|
||||
static SELF_KEYWORD: &'static str = "self";
|
||||
|
||||
impl<F: Field + PrimeField, G: GroupType<F>> ConstrainedProgram<F, G> {
|
||||
/// Enforce a variable expression by getting the resolved value
|
||||
pub(crate) fn evaluate_identifier(
|
||||
@ -699,6 +701,7 @@ impl<F: Field + PrimeField, G: GroupType<F>> ConstrainedProgram<F, G> {
|
||||
circuit_member: Identifier,
|
||||
span: Span,
|
||||
) -> Result<ConstrainedValue<F, G>, ExpressionError> {
|
||||
println!("access");
|
||||
let (circuit_name, members) = match self.enforce_expression_value(
|
||||
cs,
|
||||
file_scope.clone(),
|
||||
@ -725,8 +728,10 @@ impl<F: Field + PrimeField, G: GroupType<F>> ConstrainedProgram<F, G> {
|
||||
_ => {
|
||||
let circuit_scope = new_scope(file_scope.clone(), circuit_name.to_string());
|
||||
let function_scope = new_scope(circuit_scope, member.0.to_string());
|
||||
let field = new_scope(function_scope, stored_member.0.to_string());
|
||||
let self_keyword = new_scope(function_scope, SELF_KEYWORD.to_string());
|
||||
let field = new_scope(self_keyword, stored_member.0.to_string());
|
||||
|
||||
println!("storing");
|
||||
self.store(field, stored_member.1.clone());
|
||||
}
|
||||
}
|
||||
|
@ -22,6 +22,7 @@ impl<F: Field + PrimeField, G: GroupType<F>> ConstrainedProgram<F, G> {
|
||||
}
|
||||
|
||||
pub(crate) fn store(&mut self, name: String, value: ConstrainedValue<F, G>) {
|
||||
println!("{}", name);
|
||||
self.identifiers.insert(name, value);
|
||||
}
|
||||
|
||||
|
@ -13,7 +13,7 @@ pub struct Identifier {
|
||||
|
||||
impl Identifier {
|
||||
pub fn is_self(&self) -> bool {
|
||||
self.name == "Self"
|
||||
self.name == "Self" || self.name == "self"
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user