-
- Downloads
Macroprocessor: replace naked pointers by smart pointers
- use std::unique_ptr for MacroDriver::lexer - use std::shared_ptr for MacroValue objects constructed by the parser This is made possible using Bison 3.0 variant value type. Using non-pointer type is not possible since MacroValue is polymorphic. Using std::unique_ptr is not possible since the value type must be copyable (see https://lists.gnu.org/archive/html/bug-bison/2015-03/msg00004.html). Define a new type MacroValuePtr == shared_ptr<const MacroValue> for code clarity. Use the following convention for shared_ptr arguments to functions: + if pass-by-value, means that the callee acquires ownership + if pass-by-const-reference, the callee does not acquire ownership - naked pointers are still used for tracking the filename in Bison's location type, since we don't have control over that Also, by the way: - arrays can now contain elements of any type - simplify MacroDriver::loop_stack using std::tuple - toArray() method now fails on function objects - no need to use const qualifiers, since all MacroValue objects are immutable - use an exception for detecting division by zero
Showing
- src/macro/MacroBison.yy 50 additions, 57 deletionssrc/macro/MacroBison.yy
- src/macro/MacroDriver.cc 41 additions, 72 deletionssrc/macro/MacroDriver.cc
- src/macro/MacroDriver.hh 11 additions, 21 deletionssrc/macro/MacroDriver.hh
- src/macro/MacroFlex.ll 7 additions, 6 deletionssrc/macro/MacroFlex.ll
- src/macro/MacroValue.cc 293 additions, 335 deletionssrc/macro/MacroValue.cc
- src/macro/MacroValue.hh 86 additions, 265 deletionssrc/macro/MacroValue.hh
Loading
Please register or sign in to comment