could you give me some advice ?

lizhuo,ÄúºÃ£¡

  ²»ÊǺÜÃ÷°×ÄãµÄÒâ˼£¬ºÃÏñÄãÏë´ÓÒ»¸öConstantExpr::getPtrPtrFromArrayPtr Ö¸ÕëµÃµ½Õâ¸öConstantExpr µÄÄÚÈÝ£¬

µ«ÄãµÄÀ§ÄÑÔÚÄÄÀ

======= 2006-03-25 22:04:14 ÄúÔÚÀ´ÐÅÖÐдµÀ£º=======

hi
I have one llvm program like this :
..
; define ConstantArray
"E1$str" = internal constant [3 x sbyte] c"E1\00"

; use getPtrPtrFromArrayPtr to define SByte* from ConstantArray
"E1$entry" = internal constant sbyte* getelementptr ([3 x sbyte]* "E1$str", uint 0, uint 0)
..

when i want to get std::string object from this declaration in another program

Module* m = loadModule("XXX.bc");
Constant* c = findValue(m,"E1$entry");
GlobalVariable* gv = cast<GlobalVariable>(c->getOperand(0));
ConstantArray* ca = cast<ConstantArray>(gv->getOperand(0));
  std::string str = ca->getAsString();

now str = "E1"
these code looks a little ugly , could you tell me better solution ?
In another word , I want to know the reverse operation of ConstantExpr::getPtrPtrFromArrayPtr .

thanks

_______________________________________________
LLVM Developers mailing list
LLVMdev@cs.uiuc.edu http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev

= = = = = = = = = = = = = = = = = = = =
      
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ÖÂ
Àñ£¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Yimin Xia
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ymxia@nudt.edu.cn
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡2006-03-26