Related articles |
---|
Implementing types in a compiler pjmlp@students.si.fct.unl.pt (1997-01-29) |
Re: Implementing types in a compiler pertsserver!mkgardne@uunet.uu.net (1997-01-30) |
Re: Implementing types in a compiler jlilley@empathy.com (John Lilley) (1997-01-30) |
From: | pjmlp@students.si.fct.unl.pt (Paulo Jose Pinto - LEI) |
Newsgroups: | comp.compilers |
Date: | 29 Jan 1997 12:04:59 -0500 |
Organization: | Faculdade de Ciencias e Tecnologia, U.N.L., Portugal |
Keywords: | types, question |
I'm implementing an Object Pascal (Turbo Pascal v7.0 variant) compiler
in C++ and have implemented the information regarding the types in the
class Type which uses an union to represent all the kinds of types
(Pointers, Methods, Constants, etc) and I use the methods to acess the
information.
But I DON'T LIKE this design, when I look at the code it always makes
more sense to me to create an abstract class Type and then use
ProcedureType, ConstType and other for all kinds of information. After
all when we have an union in C, that should be implement in C++ as an
abstract class and all the cases as descendents of that class. But
this requires some sort of dynamic_cast so that I know which member
function I can call, after all doesn't make sense to use a member
function GetParameter (....) in ConstType.
I would like to know what solutions you may have implemented in your
code.
| Paulo Pinto, pjmlp@students.si.fct.unl.pt |
--
Return to the
comp.compilers page.
Search the
comp.compilers archives again.