From: Grzegorz J. <ja...@he...> - 2003-02-14 00:55:22
|
On Thu, 13 Feb 2003, stan wrote: > I am using OpenC++ ver 2.5.12 > I am calling Environment::GetLineNumber > at various instances, with p being class declarations: > > int line; > Ptree* file = e->GetLineNumber(p, line); > > and I always get: > > file = unknown > line = 0 > > why does this not work? I think that might be a feature some time ago, but today it is a bug :-) OpenC++ stores parse tree in a lisp-like tree data structure. Roughly speaking this structure has nodes of two kinds --- leafs and non-leafs. Only leafs are associated with pieces of source code. GetLineNumber() will give you the result you expect only when called on leaf node. For non-leaf, you have to descend through the leftmost path until you reach a leaf. I think that this descending was not put into GetLineNumber() for efficiency reasons. Putting efficiency concerns aside (which are not so important today, as they used to be when OpenC++ has been created), I do not see a reasonable use for GetLineNumber() returning unknown/0, thus today I would call this behaviour a bug. If you manage to find a minute to fix it, please check out the latest source code version from CVS. Let me know if I can be of any help. Best regards Grzegorz ################################################################## # Grzegorz Jakacki Huada Electronic Design # # Senior Engineer, CAD Dept. 1 Gaojiayuan, Chaoyang # # tel. +86-10-64365577 x2074 Beijing 100015, China # # Copyright (C) 2002 Grzegorz Jakacki, HED. All Rights Reserved. # ################################################################## |