[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [DotGNU]A request for help ... a mass effort

From: James Michael DuPont
Subject: Re: [DotGNU]A request for help ... a mass effort
Date: Tue, 19 Nov 2002 02:05:15 -0800 (PST)

> *parent = ILNode_<Something>_create() features many times in a lot
> of places in pnet/cscc/csharp/ ... The problem is that such
> replacements
> are totally synthetic and don't know the filename or linenum of the
> error if it occurs on that node ... Here's the generic solution ..
>               yysetfilename(*parent, yygetfilename(node));
>               yysetlinenum(*parent, yygetlinenum(node));

Let me see if I understand you correctly.
you want to add in the linenumbers and filenames to all the nodes.
*parent is the name of the created node. 

This is a problem because you dont have the parameter node at the 
time of the calling of the create function. 

I guess that you cannot always assume that the name of the node that
contains the file numbers is in *node*?  If so, you could intercept the
calls to create via a macro that will look like this :

#define TC_CONCAT3(a,b,c)        a##b##c

// really simple
struct ILNode__ {
        void *vtable__;
        int kind__;
        char *filename__;
        long linenum__;

typedef struct ILNode__ ILNode;

// the original
ILNode *ILNode_Field_create(int i)
  // foo
  return 0;

// rename the original
#define ILNode_Field_create ILNode_Field_create_orig
#undef  ILNode_Field_create

#define CreateNodeType(V,T,N,A)                                        
                  *V = (ILNode *)TC_CONCAT3(ILNode_,T,_create_orig(A)); \
                  yysetfilename(*V, yygetfilename(N));                   \
                  yysetlinenum(*V, yygetlinenum(N));                     

#define CreateNodeTypeSimple(T) CreateNodeType(parent,T,node,/*args*/)
#define CreateNodeTypeSimpleArg(T,A) CreateNodeType(parent,T,node,A)

#define ILNode_Field_create(F) CreateNodeType(parent,Field,node,F)

void foo(ILNode * node, ILNode ** parent)
 int field=0;

int main()
  ILNode parent_o;
  ILNode node_o;
  ILNode * pparent=&parent_o;
  ILNode ** ppparent=&pparent;
  ILNode * pnode=&node_o;
  return 0;

It would also be too much to assume that you could store this in a
static variable in the parser, because the line might be from a
different time. 

This is a problem because you have to reach into the caller.
This sounds like a job for a macro, this could be the beginnings of

The next step would be to create a separate function for handling this
so that is can be called in an Lval context. Then you would just have
to get the parameters correct.

Tell me if that is what you want, I will put some time into it, 
but only if you need it.


James Michael DuPont

Do you Yahoo!?
Yahoo! Web Hosting - Let the expert host your site

reply via email to

[Prev in Thread] Current Thread [Next in Thread]