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

Method self_

aiscript-vm/src/parser/mod.rs:2256–2272  ·  view source on GitHub ↗
(&mut self, _can_assign: bool)

Source from the content-addressed store, hash-verified

2254 }
2255
2256 fn self_(&mut self, _can_assign: bool) -> Option<Expr<'gc>> {
2257 let is_in_static_method = if let Some(class_compiler) = self.class_compiler.as_ref() {
2258 class_compiler.current_method_type.is_static_method() || self.fn_type.is_static_method()
2259 } else {
2260 self.error("Can't use 'self' outside of a class or enum.");
2261 return None;
2262 };
2263
2264 if is_in_static_method {
2265 self.error("Can't use 'self' in static method.");
2266 return None;
2267 }
2268
2269 Some(Expr::Self_ {
2270 line: self.previous.line,
2271 })
2272 }
2273
2274 fn prompt(&mut self, _can_assign: bool) -> Option<Expr<'gc>> {
2275 if !self.fn_type.is_ai_function() && self.fn_type != FunctionType::Script {

Callers

nothing calls this directly

Calls 3

is_static_methodMethod · 0.80
as_refMethod · 0.45
errorMethod · 0.45

Tested by

no test coverage detected