pub enum AccessKind {
    Name,
    Attr,
    Method,
}

Variants§

§

Name

§

Attr

§

Method

Implementations§

Examples found in repository?
codegen.rs (line 793)
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
    fn emit_store_instr(&mut self, ident: Identifier, acc_kind: AccessKind) {
        log!(info "entered {} ({ident})", fn_name!());
        let escaped = escape_ident(ident);
        let name = self.local_search(&escaped, acc_kind).unwrap_or_else(|| {
            if acc_kind.is_local() {
                self.register_name(escaped)
            } else {
                self.register_attr(escaped)
            }
        });
        let instr = self.select_store_instr(name.kind, acc_kind);
        self.write_instr(instr);
        self.write_arg(name.idx);
        self.stack_dec();
        if instr == STORE_ATTR as u8 {
            if self.py_version.minor >= Some(11) {
                self.write_bytes(&[0; 8]);
            }
            self.stack_dec();
        }
    }
More examples
Hide additional examples
context/inquire.rs (line 357)
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
    pub(crate) fn rec_get_var_info(
        &self,
        ident: &Identifier,
        acc_kind: AccessKind,
        input: &Input,
        namespace: &Str,
    ) -> SingleTyCheckResult<VarInfo> {
        if let Some(vi) = self.get_current_scope_var(&ident.inspect()[..]) {
            match self.validate_visibility(ident, vi, input, namespace) {
                Ok(()) => {
                    return Ok(vi.clone());
                }
                Err(err) => {
                    if !acc_kind.is_local() {
                        return Err(err);
                    }
                }
            }
        } else if let Some((name, _vi)) = self
            .future_defined_locals
            .get_key_value(&ident.inspect()[..])
        {
            return Err(TyCheckError::access_before_def_error(
                input.clone(),
                line!() as usize,
                ident.loc(),
                namespace.into(),
                ident.inspect(),
                name.ln_begin().unwrap_or(0),
                self.get_similar_name(ident.inspect()),
            ));
        } else if let Some((name, _vi)) = self.deleted_locals.get_key_value(&ident.inspect()[..]) {
            return Err(TyCheckError::access_deleted_var_error(
                input.clone(),
                line!() as usize,
                ident.loc(),
                namespace.into(),
                ident.inspect(),
                name.ln_begin().unwrap_or(0),
                self.get_similar_name(ident.inspect()),
            ));
        }
        if let Some(parent) = self.get_outer().or_else(|| self.get_builtins()) {
            match parent.rec_get_var_info(ident, acc_kind, input, namespace) {
                Ok(vi) => Ok(vi),
                Err(err) if err.core.kind == ErrorKind::DummyError => {
                    Err(TyCheckError::no_var_error(
                        input.clone(),
                        line!() as usize,
                        ident.loc(),
                        namespace.into(),
                        ident.inspect(),
                        self.get_similar_name(ident.inspect()),
                    ))
                }
                Err(err) => Err(err),
            }
        } else {
            Err(TyCheckError::dummy(
                self.cfg.input.clone(),
                line!() as usize,
            ))
        }
    }

    pub(crate) fn rec_get_decl_info(
        &self,
        ident: &Identifier,
        acc_kind: AccessKind,
        input: &Input,
        namespace: &Str,
    ) -> SingleTyCheckResult<VarInfo> {
        if let Some(vi) = self.decls.get(&ident.inspect()[..]) {
            match self.validate_visibility(ident, vi, input, namespace) {
                Ok(()) => {
                    return Ok(vi.clone());
                }
                Err(err) => {
                    if !acc_kind.is_local() {
                        return Err(err);
                    }
                }
            }
        }
        if let Some(parent) = self.get_outer().or_else(|| self.get_builtins()) {
            return parent.rec_get_decl_info(ident, acc_kind, input, namespace);
        }
        Err(TyCheckError::no_var_error(
            input.clone(),
            line!() as usize,
            ident.loc(),
            namespace.into(),
            ident.inspect(),
            self.get_similar_name(ident.inspect()),
        ))
    }

Trait Implementations§

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
This method tests for self and other values to be equal, and is used by ==.
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.