[cfe-dev] TreeTransform and Clang
Vassil Vassilev
vasil.georgiev.vasilev at cern.ch
Sat Aug 7 00:28:45 PDT 2010
Hello,
Hm, Is the error handling in the semantic analysis, too?
I need the following
For example (I am skipping the pointers and other ugly things that
made it less readable):
funtion F(int x, float y,string z) {
int i = objX.GetValue(x); //compile time object and method
invocation
TFile t = new TFile("MyFile.hhh"); //here goes the interpreter,but
it needs addresses of the variables from the compiler
i = t.DoSomething(i, x, y, z);
Console.WriteLine(i.ToString());
}
Here the semantic analyzer should say undeclared variable and so on.
Before that happens I want to change the AST and to convert it in something like:
funtion F(int x, float y,string z) {
int i = objX->GetValue(x); //compile time object and method invocation
TFile t = new TFile("MyFile.hhh"); //here goes the interpreter,but it needs addresses of the variables from the compiler
Context c = new Context();
c.AddVariable(i.GetDeclaration()) ; //here we should use some kind of reflection or we can insert just the variable address and the proper mapping.
c.AddArgument(x.GetDeclaration());
...
Interpreter.Interpret("t->DoSomething(i,x,y,z)", c);
i = t.DoSomething(i, x, y, z);
Console.WriteLine(i.ToString());
}
I know I can modify the Sema and/or put something in the symbol table
to achieve the goal but I am looking for more elegant solution. I know
that probably I can make second pass of the invalid AST but it is not
the most efficient way of solving the problem.
Do you see better solution? (I decided to ask here because I am not
very familiar with the LLVM infrastructure)
Regards,
V. Vassilev
On Fri, 2010-08-06 at 15:56 -0700, John McCall wrote:
> On Aug 6, 2010, at 6:00 AM, Vassil Vassilev wrote:
>
> > Hello,
> > I need to transform the generated AST just before it is passed to the
> > Sema. I know that I have to use (inherit) the TreeTransform class but it
> > is difficult for me to find where to put the new transformation (I want
> > to preserve the architecture of LLVM). Where I can call the new
> > transformer so that it will be able to transform the tree before the
> > semantic analysis?
>
> I think you're confused; semantic analysis is what builds the AST. We don't
> build separate parse trees and semantic trees.
>
> John.
More information about the cfe-dev
mailing list