Skip to content

Commit 673e287

Browse files
committed
feat: add build_order function, refactor and test it
1 parent c4a78a9 commit 673e287

7 files changed

Lines changed: 405 additions & 70 deletions

File tree

examples/modules/main.simf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
pub use temp::get_five::get_five;
1+
pub use temp::funcs::get_five;
22

33
fn seven() -> u32 {
44
7

src/ast.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use simplicity::jet::Elements;
1111
use crate::debug::{CallTracker, DebugSymbols, TrackedCallName};
1212
use crate::error::{Error, RichError, Span, WithSpan};
1313
use crate::num::{NonZeroPow2Usize, Pow2Usize};
14-
use crate::parse::{MatchPattern, UseDecl};
14+
use crate::parse::{MatchPattern, UseDecl, Visibility};
1515
use crate::pattern::Pattern;
1616
use crate::str::{AliasName, FunctionName, Identifier, ModuleName, WitnessName};
1717
use crate::types::{
@@ -307,6 +307,7 @@ pub enum CallName {
307307
/// Definition of a custom function.
308308
#[derive(Clone, Debug, Eq, PartialEq, Hash)]
309309
pub struct CustomFunction {
310+
visibility: Visibility,
310311
params: Arc<[FunctionParam]>,
311312
body: Arc<Expression>,
312313
}
@@ -780,6 +781,7 @@ impl AbstractSyntaxTree for Function {
780781
assert!(scope.is_topmost(), "Items live in the topmost scope only");
781782

782783
if from.name().as_inner() != "main" {
784+
let visibility = from.visibility().clone();
783785
let params = from
784786
.params()
785787
.iter()
@@ -803,7 +805,11 @@ impl AbstractSyntaxTree for Function {
803805
let body = Expression::analyze(from.body(), &ret, scope).map(Arc::new)?;
804806
scope.pop_scope();
805807
debug_assert!(scope.is_topmost());
806-
let function = CustomFunction { params, body };
808+
let function = CustomFunction {
809+
visibility,
810+
params,
811+
body,
812+
};
807813
scope
808814
.insert_function(from.name().clone(), function)
809815
.with_span(from)?;

0 commit comments

Comments
 (0)