Struct erg_compiler::ty::codeobj::CodeObj
source · pub struct CodeObj {Show 18 fields
pub argcount: u32,
pub posonlyargcount: u32,
pub kwonlyargcount: u32,
pub nlocals: u32,
pub stacksize: u32,
pub flags: u32,
pub code: Vec<u8>,
pub consts: Vec<ValueObj>,
pub names: Vec<Str>,
pub varnames: Vec<Str>,
pub freevars: Vec<Str>,
pub cellvars: Vec<Str>,
pub filename: Str,
pub name: Str,
pub qualname: Str,
pub firstlineno: u32,
pub lnotab: Vec<u8>,
pub exceptiontable: Vec<u8>,
}
Expand description
Implementation of PyCodeObject
, see Include/cpython/code.h in CPython for details.
各属性をErg側のObjに変換すると遅くなりそうなので、アクサスされたときのみ変換して提供する
Fields
argcount: u32
posonlyargcount: u32
kwonlyargcount: u32
nlocals: u32
stacksize: u32
flags: u32
code: Vec<u8>
consts: Vec<ValueObj>
names: Vec<Str>
varnames: Vec<Str>
freevars: Vec<Str>
cellvars: Vec<Str>
filename: Str
name: Str
qualname: Str
firstlineno: u32
lnotab: Vec<u8>
exceptiontable: Vec<u8>
Implementations
sourceimpl CodeObj
impl CodeObj
pub fn empty<S: Into<Str>, T: Into<Str>>(
params: Vec<Str>,
filename: S,
name: T,
firstlineno: u32
) -> Self
pub fn from_pyc<P: AsRef<Path>>(path: P) -> DeserializeResult<Self>
pub fn from_bytes(
v: &mut Vec<u8>,
python_ver: PythonVersion
) -> DeserializeResult<Self>
pub fn into_bytes(self, python_ver: PythonVersion) -> Vec<u8>
pub fn dump_as_pyc<P: AsRef<Path>>(
self,
path: P,
py_magic_num: Option<u32>
) -> Result<()>
pub fn code_info(&self, py_ver: Option<PythonVersion>) -> String
Trait Implementations
impl Eq for CodeObj
impl StructuralEq for CodeObj
impl StructuralPartialEq for CodeObj
Auto Trait Implementations
impl !RefUnwindSafe for CodeObj
impl !Send for CodeObj
impl !Sync for CodeObj
impl Unpin for CodeObj
impl !UnwindSafe for CodeObj
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more