diff options
author | Emilio Cobos Álvarez <me@emiliocobos.me> | 2016-07-04 20:33:44 -0700 |
---|---|---|
committer | Emilio Cobos Álvarez <me@emiliocobos.me> | 2016-07-05 09:54:58 -0700 |
commit | ac9faa67da8464b7a735cd2c3832f31ad8704192 (patch) | |
tree | 43c8108bd289bffe91df16a1896972cfb083c6f6 | |
parent | f834d96edab642d403d8a1d5446d6047bd97dd83 (diff) |
parser: Simplify macro-parsing logic.
-rw-r--r-- | src/parser.rs | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/src/parser.rs b/src/parser.rs index 307e7e1d..3004eb40 100644 --- a/src/parser.rs +++ b/src/parser.rs @@ -1353,20 +1353,20 @@ fn visit_top(cursor: &Cursor, } CXCursor_MacroDefinition => { let val = parse_int_literal_tokens(cursor, &ctx.current_translation_unit, 1); - if val.is_none() { - // Not an integer literal. - return CXChildVisit_Continue; - } + let val = match val { + None => return CXChildVisit_Continue, // Not an integer literal. + Some(v) => v, + }; let var = decl_name(ctx, cursor); let vi = var.varinfo(); let mut vi = vi.borrow_mut(); - vi.ty = match val { - None => TVoid, - Some(v) if v.abs() > u32::max_value() as i64 => TInt(IULongLong, Layout::new(8, 8)), - _ => TInt(IUInt, Layout::new(4, 4)), + vi.ty = if val.abs() > u32::max_value() as i64 { + TInt(IULongLong, Layout::new(8, 8)) + } else { + TInt(IUInt, Layout::new(4, 4)) }; vi.is_const = true; - vi.val = val; + vi.val = Some(val); ctx.current_module_mut().globals.push(var); return CXChildVisit_Continue; |