Enum rslua_march1917::ast::Expr
source · pub enum Expr {
}Variants§
Nil
True
False
VarArg
Float(FloatType)
Int(IntType)
String(String)
Name(String)
ParenExpr(Box<Expr>)
FuncBody(FuncBody)
Table(Table)
BinExpr(BinExpr)
UnExpr(UnExpr)
SuffixedExpr(SuffixedExpr)
Implementations§
source§impl Expr
impl Expr
sourcepub fn has_multi_ret(&self) -> bool
pub fn has_multi_ret(&self) -> bool
Examples found in repository?
src/compiler.rs (line 230)
227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244
fn adjust_assign(&mut self, num_left: usize, right_exprs: &Vec<Expr>) -> i32 {
let extra = num_left as i32 - right_exprs.len() as i32;
if let Some(last_expr) = right_exprs.last() {
if last_expr.has_multi_ret() {
// TODO : process multi return value
todo!("process mult ret")
}
}
if extra > 0 {
let context = self.context();
let from = context.get_reg_top();
context.reserve_regs(extra as u32);
context.proto.code_nil(from, extra as u32);
}
extra
}source§impl Expr
impl Expr
sourcepub fn to_assignable(self) -> Assignable
pub fn to_assignable(self) -> Assignable
Examples found in repository?
src/parser.rs (line 377)
374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397
fn exprstat(&mut self) -> ParseResult<Stat> {
let expr = self.suffixedexpr()?;
if self.test(TokenType::Assign) || self.test(TokenType::Comma) {
Ok(Stat::AssignStat(self.assignment(expr.to_assignable())?))
} else {
Ok(Stat::CallStat(CallStat {
call: expr.to_assignable(),
}))
}
}
// assignment -> ',' suffixedexp assignment
// assignment -> '=' explist
fn assignment(&mut self, first: Assignable) -> ParseResult<AssignStat> {
let mut left: Vec<Assignable> = Vec::new();
left.push(first);
while self.test_next(TokenType::Comma) {
left.push(self.suffixedexpr()?.to_assignable())
}
self.check_next(TokenType::Assign)?;
self.skip_comment();
let right = self.exprlist()?;
Ok(AssignStat { left, right })
}