Skip to content

Commit

Permalink
correctly handle contexts for Aleo functions
Browse files Browse the repository at this point in the history
  • Loading branch information
mikebenfield committed Dec 16, 2024
1 parent bb1226a commit e589128
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 15 deletions.
19 changes: 4 additions & 15 deletions interpreter/src/cursor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ impl ContextStack {
self.current_len += 1;
}

fn pop(&mut self) {
pub fn pop(&mut self) {
// We never actually pop the underlying Vec
// so we can reuse the storage of the hash
// tables.
Expand Down Expand Up @@ -418,12 +418,7 @@ impl<'a> Cursor<'a> {
false
}
1 if function_body => {
if self.contexts.is_async() {
let future = self.contexts.get_future();
self.values.push(Value::Future(future));
} else {
self.values.push(Value::Unit);
}
self.values.push(Value::Unit);
self.contexts.pop();
true
}
Expand Down Expand Up @@ -1022,14 +1017,8 @@ impl<'a> Cursor<'a> {
Element::DelayedCall(_gid) => {
assert_eq!(*step, 1);
let value = self.values.pop();
let Some(Value::Future(future)) = value else {
panic!("Delayed calls should always be to async functions");
};
if !future.0.is_empty() {
self.futures.push(future.clone());
}
self.frames.pop();
Ok(StepResult { finished: true, value: Some(Value::Future(future)) })
Ok(StepResult { finished: true, value })
}
}
}
Expand All @@ -1052,7 +1041,7 @@ impl<'a> Cursor<'a> {
} else {
self.signer
};
if self.really_async && matches!(function.variant, Variant::AsyncFunction | Variant::AsyncTransition) {
if self.really_async && function.variant == Variant::AsyncFunction {
// Don't actually run the call now.
let async_ex = AsyncExecution {
function: GlobalId { name: function_name, program: function_program },
Expand Down
1 change: 1 addition & 0 deletions interpreter/src/cursor_aleo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -952,6 +952,7 @@ impl Cursor<'_> {
if self.execution_complete() {
let mut outputs = self.outputs();
self.frames.pop();
self.contexts.pop();
if outputs.len() > 1 {
self.values.push(Value::Tuple(outputs));
} else {
Expand Down
8 changes: 8 additions & 0 deletions notes
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@

call deposit(100u64), type failure

cannot print register credits.aleo/transfer_public

after set_program, message or print out symbols

set self.signer

0 comments on commit e589128

Please sign in to comment.