MCPcopy Index your code
hub / github.com/aiscriptdev/aiscript / method_declaration

Method method_declaration

aiscript-vm/src/parser/mod.rs:694–722  ·  view source on GitHub ↗
(&mut self)

Source from the content-addressed store, hash-verified

692 }
693
694 fn method_declaration(&mut self) -> Option<Stmt<'gc>> {
695 let method_vis = if self.match_token(TokenType::Pub) {
696 Visibility::Public
697 } else {
698 Visibility::Private
699 };
700 let method = if self.match_token(TokenType::AI) {
701 self.consume(TokenType::Fn, "Expect 'fn' after 'ai'.");
702 self.func_declaration(
703 FunctionType::Method {
704 is_ai: true,
705 is_static: false,
706 },
707 method_vis,
708 )?
709 } else if self.match_token(TokenType::Fn) {
710 self.func_declaration(
711 FunctionType::Method {
712 is_ai: false,
713 is_static: false,
714 },
715 method_vis,
716 )?
717 } else {
718 self.error_at_current("Expect 'fn' or 'ai fn' modifier for method.");
719 return None;
720 };
721 Some(method)
722 }
723
724 fn func_declaration(
725 &mut self,

Callers 2

enum_declarationMethod · 0.80
class_declarationMethod · 0.80

Calls 4

match_tokenMethod · 0.80
func_declarationMethod · 0.80
error_at_currentMethod · 0.80
consumeMethod · 0.45

Tested by

no test coverage detected