mirror of
https://github.com/RustPython/Parser.git
synced 2025-07-18 18:45:23 +00:00
Don't use a wildcard to prevent future mistakes
This commit is contained in:
parent
38c4c14ee3
commit
df41efed8a
1 changed files with 28 additions and 15 deletions
|
@ -36,25 +36,38 @@ impl CodeInfo {
|
||||||
// this is a little bit hacky, as until now the data stored inside Labels in
|
// this is a little bit hacky, as until now the data stored inside Labels in
|
||||||
// Instructions is just bookkeeping, but I think it's the best way to do this
|
// Instructions is just bookkeeping, but I think it's the best way to do this
|
||||||
// XXX: any new instruction that uses a label has to be added here
|
// XXX: any new instruction that uses a label has to be added here
|
||||||
let label = match instruction {
|
match instruction {
|
||||||
Jump { target } => target,
|
Jump { target: l }
|
||||||
JumpIfTrue { target } => target,
|
| JumpIfTrue { target: l }
|
||||||
JumpIfFalse { target } => target,
|
| JumpIfFalse { target: l }
|
||||||
JumpIfTrueOrPop { target } => target,
|
| JumpIfTrueOrPop { target: l }
|
||||||
JumpIfFalseOrPop { target } => target,
|
| JumpIfFalseOrPop { target: l }
|
||||||
ForIter { target } => target,
|
| ForIter { target: l }
|
||||||
|
| SetupFinally { handler: l }
|
||||||
|
| SetupExcept { handler: l }
|
||||||
|
| SetupWith { end: l }
|
||||||
|
| SetupAsyncWith { end: l } => {
|
||||||
|
*l = label_map[l.0].expect("label never set");
|
||||||
|
}
|
||||||
SetupLoop { start, end } => {
|
SetupLoop { start, end } => {
|
||||||
*start = label_map[start.0].expect("label never set");
|
*start = label_map[start.0].expect("label never set");
|
||||||
*end = label_map[end.0].expect("label never set");
|
*end = label_map[end.0].expect("label never set");
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
SetupFinally { handler } => handler,
|
|
||||||
SetupExcept { handler } => handler,
|
#[rustfmt::skip]
|
||||||
SetupWith { end } => end,
|
Import { .. } | ImportStar | ImportFrom { .. } | LoadName { .. } | StoreName { .. }
|
||||||
SetupAsyncWith { end } => end,
|
| DeleteName { .. } | Subscript | StoreSubscript | DeleteSubscript
|
||||||
_ => continue,
|
| StoreAttr { .. } | DeleteAttr { .. } | LoadConst { .. } | UnaryOperation { .. }
|
||||||
};
|
| BinaryOperation { .. } | LoadAttr { .. } | CompareOperation { .. } | Pop
|
||||||
*label = label_map[label.0].expect("label never set");
|
| Rotate { .. } | Duplicate | GetIter | Continue | Break | MakeFunction
|
||||||
|
| CallFunction { .. } | ReturnValue | YieldValue | YieldFrom | SetupAnnotation
|
||||||
|
| EnterFinally | EndFinally | WithCleanupStart | WithCleanupFinish | PopBlock
|
||||||
|
| Raise { .. } | BuildString { .. } | BuildTuple { .. } | BuildList { .. }
|
||||||
|
| BuildSet { .. } | BuildMap { .. } | BuildSlice { .. } | ListAppend { .. }
|
||||||
|
| SetAdd { .. } | MapAdd { .. } | PrintExpr | LoadBuildClass | UnpackSequence { .. }
|
||||||
|
| UnpackEx { .. } | FormatValue { .. } | PopException | Reverse { .. }
|
||||||
|
| GetAwaitable | BeforeAsyncWith | GetAIter | GetANext | MapAddRev { .. } => {}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
code
|
code
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue