[fpc-devel] String cases development
florian at freepascal.org
Sat Apr 18 14:07:37 CEST 2009
Mike Denisenko schrieb:
> Hello everyone, I'm a student of FESU, Russia. I've started to
> develop a feature - string cases (Topic: Easiest way to "case"
> and now some questions appear:
> Existing method of parsing and generating assembly code doesn't
> process any constants but ordinal type, so the class holding case
> data, TCaseNode, contains labelinfo as object of TCaseLabel record.
For string case nodes, I see no need to generate assembler directly. It
should be sufficient to generate an appropriate node tree so the whole
implementation is portable
> And TCaseLabel contains two fields: _low and _high representing the
> low and high bounds of interval signed as case label. These fields
> are of TConstExprInt type, so if we want to process the string label
> we get a problem: how it's better to hold its value? Should we simply
> add two string-type fields to TCaseLabel, or it should be solved by
> creating a base class with some virtual procedures and refactoring
> all modules having procedures operating with this type?
Make TCaseLabel a variant record.
More information about the fpc-devel