Re: Switch statement code generation

Hans-Peter Diettrich <DrDiettrich1@aol.com>
Sun, 08 Nov 2009 20:09:24 +0100

          From comp.compilers

Related articles
[5 earlier articles]
Re: Switch statement code generation gah@ugcs.caltech.edu (glen herrmannsfeldt) (2009-11-04)
Re: Switch statement code generation anton@mips.complang.tuwien.ac.at (2009-11-04)
Re: Switch statement code generation Pidgeot18@verizon.invalid (Joshua Cranmer) (2009-11-04)
Re: Switch statement code generation walter@bytecraft.com (Walter Banks) (2009-11-05)
Re: Switch statement code generation bartc@freeuk.com (bartc) (2009-11-05)
Re: Switch statement code generation nathan.mccauley@gmail.com (nathan.mccauley@gmail.com) (2009-11-07)
Re: Switch statement code generation DrDiettrich1@aol.com (Hans-Peter Diettrich) (2009-11-08)
Re: Switch statement code generation bear@sonic.net (Ray) (2009-11-09)
Re: Switch statement code generation DrDiettrich1@aol.com (Hans-Peter Diettrich) (2009-11-11)
Re: Switch statement code generation derek@knosof.co.uk (Derek M. Jones) (2009-11-11)
Re: Switch statement code generation anton@mips.complang.tuwien.ac.at (2009-11-11)
Re: Switch statement code generation idbaxter@semdesigns.com (Ira Baxter) (2009-11-14)
Re: Switch statement code generation cfc@shell01.TheWorld.com (Chris F Clark) (2009-11-15)
[2 later articles]
| List of all articles for this month |
From: Hans-Peter Diettrich <DrDiettrich1@aol.com>
Newsgroups: comp.compilers
Date: Sun, 08 Nov 2009 20:09:24 +0100
Organization: Compilers Central
References: 09-11-002 09-11-014 09-11-023
Keywords: code
Posted-Date: 11 Nov 2009 00:59:10 EST

nathan.mccauley@gmail.com schrieb:


>>> I'm trying to put together a list of various methods to do code generate
>>> for switch statements. ...
>
> Has anyone seen tries used for the string-based switch statements?


What dou you expect?


Visual Basic had such a feature, implemented as a series of string
compares and jumps.


The typical solution is a lookup in a (sorted, hashed...) string list,
followed by an "ordinary" switch with the index of the found string. The
target address could be attached to every string in that list, so that a
second switch is not required.


A string tree might give the best lookup performance.


DoDi


[If there's a lot of strings, a patricia trie might be faster than
hashing or binary search since it doesn't require repeated scans of
the string during the match process. -John]



Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.