Skip to content

feat(interpreter): add initial built-in function call path - #100

Open
Franklin-Qi wants to merge 1 commit into
uutils:mainfrom
Franklin-Qi:feature-task#96-Interpreter-initial-built-in-functions
Open

feat(interpreter): add initial built-in function call path#100
Franklin-Qi wants to merge 1 commit into
uutils:mainfrom
Franklin-Qi:feature-task#96-Interpreter-initial-built-in-functions

Conversation

@Franklin-Qi

Copy link
Copy Markdown
Collaborator

Lower BuiltinCall to IntrinsicCall carrying BuiltinFunction, dispatch via Registers::get_range(), and implement trivial math/string/bitwise helpers with placeholders for the rest. Also accept builtins in expression context and load ImmF consts.

Closes: #96

Lower BuiltinCall to IntrinsicCall carrying BuiltinFunction, dispatch
via Registers::get_range(), and implement trivial math/string/bitwise
helpers with placeholders for the rest. Also accept builtins in
expression context and load ImmF consts.

Closes: uutils#96

@Alonely0 Alonely0 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this quite a bit :)

I have a couple of small comments, other than that I'd ask if you can add some small tests for the fixmes, and annotate them with #[ignore] for the time being. Also, I'll be mostly unavailable until Tuesday or Wednesday, so feel free to take your time and merge this if my review comments are addressed okay.

Comment thread interpreter/src/vm.rs
Comment on lines +570 to +576
Err(crate::builtins::BuiltinError::Arity { expected, given }) => {
return Err(InterpreterError::ArityMismatch(
self.get_span(metadata),
expected,
given,
));
}

@Alonely0 Alonely0 Jul 31, 2026

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This has me missing Haskell's currying hahah. I think it would be cleaner to implement a conversion method for BuiltinError that takes the AriadneSpan.

}
}

fn require_args<'a, 'b>(

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting combinator. I like it.

Comment on lines +29 to +33
pub(crate) fn call<'a>(
fun: BuiltinFunction,
args: &[Value<'a>],
symbols: &SymbolTable<'a>,
) -> Result<Value<'a>, BuiltinError> {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is likely we will need to access more properties from the interpreter (like ExecMode) and perform I/O in the future. The latter needs not be addressed for now (tho I'd guess we'll just use Either) , but I think we would benefit from implementing this as a method of the Interpreter. What do you think?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

interpreter: initial built-in functions

2 participants