Fix warning
[oota-llvm.git] / lib / ExecutionEngine / Interpreter / ExternalFunctions.cpp
1 //===-- ExternalFunctions.cpp - Implement External Functions --------------===//
2 // 
3 //  This file contains both code to deal with invoking "external" functions, but
4 //  also contains code that implements "exported" external functions.
5 //
6 //  External functions in LLI are implemented by dlopen'ing the lli executable
7 //  and using dlsym to look op the functions that we want to invoke.  If a
8 //  function is found, then the arguments are mangled and passed in to the
9 //  function call.
10 //
11 //===----------------------------------------------------------------------===//
12
13 #include "Interpreter.h"
14 #include "ExecutionAnnotations.h"
15 #include "llvm/DerivedTypes.h"
16 #include "llvm/SymbolTable.h"
17 #include "llvm/Target/TargetData.h"
18 #include <map>
19 #include <dlfcn.h>
20 #include <link.h>
21 #include <math.h>
22 #include <stdio.h>
23 using std::vector;
24 using std::cout;
25
26 extern TargetData TD;
27
28 typedef GenericValue (*ExFunc)(FunctionType *, const vector<GenericValue> &);
29 static std::map<const Function *, ExFunc> Functions;
30 static std::map<std::string, ExFunc> FuncNames;
31
32 static Interpreter *TheInterpreter;
33
34 // getCurrentExecutablePath() - Return the directory that the lli executable
35 // lives in.
36 //
37 std::string Interpreter::getCurrentExecutablePath() const {
38   Dl_info Info;
39   if (dladdr(&TheInterpreter, &Info) == 0) return "";
40   
41   std::string LinkAddr(Info.dli_fname);
42   unsigned SlashPos = LinkAddr.rfind('/');
43   if (SlashPos != std::string::npos)
44     LinkAddr.resize(SlashPos);    // Trim the executable name off...
45
46   return LinkAddr;
47 }
48
49
50 static char getTypeID(const Type *Ty) {
51   switch (Ty->getPrimitiveID()) {
52   case Type::VoidTyID:    return 'V';
53   case Type::BoolTyID:    return 'o';
54   case Type::UByteTyID:   return 'B';
55   case Type::SByteTyID:   return 'b';
56   case Type::UShortTyID:  return 'S';
57   case Type::ShortTyID:   return 's';
58   case Type::UIntTyID:    return 'I';
59   case Type::IntTyID:     return 'i';
60   case Type::ULongTyID:   return 'L';
61   case Type::LongTyID:    return 'l';
62   case Type::FloatTyID:   return 'F';
63   case Type::DoubleTyID:  return 'D';
64   case Type::PointerTyID: return 'P';
65   case Type::FunctionTyID:  return 'M';
66   case Type::StructTyID:  return 'T';
67   case Type::ArrayTyID:   return 'A';
68   case Type::OpaqueTyID:  return 'O';
69   default: return 'U';
70   }
71 }
72
73 static ExFunc lookupFunction(const Function *M) {
74   // Function not found, look it up... start by figuring out what the
75   // composite function name should be.
76   std::string ExtName = "lle_";
77   const FunctionType *MT = M->getFunctionType();
78   for (unsigned i = 0; const Type *Ty = MT->getContainedType(i); ++i)
79     ExtName += getTypeID(Ty);
80   ExtName += "_" + M->getName();
81
82   //cout << "Tried: '" << ExtName << "'\n";
83   ExFunc FnPtr = FuncNames[ExtName];
84   if (FnPtr == 0)
85     FnPtr = (ExFunc)dlsym(RTLD_DEFAULT, ExtName.c_str());
86   if (FnPtr == 0)
87     FnPtr = FuncNames["lle_X_"+M->getName()];
88   if (FnPtr == 0)  // Try calling a generic function... if it exists...
89     FnPtr = (ExFunc)dlsym(RTLD_DEFAULT, ("lle_X_"+M->getName()).c_str());
90   if (FnPtr != 0)
91     Functions.insert(std::make_pair(M, FnPtr));  // Cache for later
92   return FnPtr;
93 }
94
95 GenericValue Interpreter::callExternalMethod(Function *M,
96                                          const vector<GenericValue> &ArgVals) {
97   TheInterpreter = this;
98
99   // Do a lookup to see if the function is in our cache... this should just be a
100   // defered annotation!
101   std::map<const Function *, ExFunc>::iterator FI = Functions.find(M);
102   ExFunc Fn = (FI == Functions.end()) ? lookupFunction(M) : FI->second;
103   if (Fn == 0) {
104     cout << "Tried to execute an unknown external function: "
105          << M->getType()->getDescription() << " " << M->getName() << "\n";
106     return GenericValue();
107   }
108
109   // TODO: FIXME when types are not const!
110   GenericValue Result = Fn(const_cast<FunctionType*>(M->getFunctionType()),
111                            ArgVals);
112   return Result;
113 }
114
115
116 //===----------------------------------------------------------------------===//
117 //  Functions "exported" to the running application...
118 //
119 extern "C" {  // Don't add C++ manglings to llvm mangling :)
120
121 // Implement void printstr([ubyte {x N}] *)
122 GenericValue lle_VP_printstr(FunctionType *M, const vector<GenericValue> &ArgVal){
123   assert(ArgVal.size() == 1 && "printstr only takes one argument!");
124   cout << (char*)ArgVal[0].PointerVal;
125   return GenericValue();
126 }
127
128 // Implement 'void print(X)' for every type...
129 GenericValue lle_X_print(FunctionType *M, const vector<GenericValue> &ArgVals) {
130   assert(ArgVals.size() == 1 && "generic print only takes one argument!");
131
132   Interpreter::print(M->getParamTypes()[0], ArgVals[0]);
133   return GenericValue();
134 }
135
136 // Implement 'void printVal(X)' for every type...
137 GenericValue lle_X_printVal(FunctionType *M, const vector<GenericValue> &ArgVal) {
138   assert(ArgVal.size() == 1 && "generic print only takes one argument!");
139
140   // Specialize print([ubyte {x N} ] *) and print(sbyte *)
141   if (const PointerType *PTy = 
142       dyn_cast<PointerType>(M->getParamTypes()[0].get()))
143     if (PTy->getElementType() == Type::SByteTy ||
144         isa<ArrayType>(PTy->getElementType())) {
145       return lle_VP_printstr(M, ArgVal);
146     }
147
148   Interpreter::printValue(M->getParamTypes()[0], ArgVal[0]);
149   return GenericValue();
150 }
151
152 // Implement 'void printString(X)'
153 // Argument must be [ubyte {x N} ] * or sbyte *
154 GenericValue lle_X_printString(FunctionType *M, const vector<GenericValue> &ArgVal) {
155   assert(ArgVal.size() == 1 && "generic print only takes one argument!");
156   return lle_VP_printstr(M, ArgVal);
157 }
158
159 // Implement 'void print<TYPE>(X)' for each primitive type or pointer type
160 #define PRINT_TYPE_FUNC(TYPENAME,TYPEID) \
161   GenericValue lle_X_print##TYPENAME(FunctionType *M,\
162                                      const vector<GenericValue> &ArgVal) {\
163     assert(ArgVal.size() == 1 && "generic print only takes one argument!");\
164     assert(M->getParamTypes()[0].get()->getPrimitiveID() == Type::TYPEID);\
165     Interpreter::printValue(M->getParamTypes()[0], ArgVal[0]);\
166     return GenericValue();\
167   }
168
169 PRINT_TYPE_FUNC(SByte,   SByteTyID)
170 PRINT_TYPE_FUNC(UByte,   UByteTyID)
171 PRINT_TYPE_FUNC(Short,   ShortTyID)
172 PRINT_TYPE_FUNC(UShort,  UShortTyID)
173 PRINT_TYPE_FUNC(Int,     IntTyID)
174 PRINT_TYPE_FUNC(UInt,    UIntTyID)
175 PRINT_TYPE_FUNC(Long,    LongTyID)
176 PRINT_TYPE_FUNC(ULong,   ULongTyID)
177 PRINT_TYPE_FUNC(Float,   FloatTyID)
178 PRINT_TYPE_FUNC(Double,  DoubleTyID)
179 PRINT_TYPE_FUNC(Pointer, PointerTyID)
180
181
182 // void putchar(sbyte)
183 GenericValue lle_Vb_putchar(FunctionType *M, const vector<GenericValue> &Args) {
184   cout << Args[0].SByteVal;
185   return GenericValue();
186 }
187
188 // int putchar(int)
189 GenericValue lle_ii_putchar(FunctionType *M, const vector<GenericValue> &Args) {
190   cout << ((char)Args[0].IntVal) << std::flush;
191   return Args[0];
192 }
193
194 // void putchar(ubyte)
195 GenericValue lle_VB_putchar(FunctionType *M, const vector<GenericValue> &Args) {
196   cout << Args[0].SByteVal << std::flush;
197   return Args[0];
198 }
199
200 // void __main()
201 GenericValue lle_V___main(FunctionType *M, const vector<GenericValue> &Args) {
202   return GenericValue();
203 }
204
205 // void exit(int)
206 GenericValue lle_X_exit(FunctionType *M, const vector<GenericValue> &Args) {
207   TheInterpreter->exitCalled(Args[0]);
208   return GenericValue();
209 }
210
211 // void abort(void)
212 GenericValue lle_X_abort(FunctionType *M, const vector<GenericValue> &Args) {
213   std::cerr << "***PROGRAM ABORTED***!\n";
214   GenericValue GV;
215   GV.IntVal = 1;
216   TheInterpreter->exitCalled(GV);
217   return GenericValue();
218 }
219
220 // void *malloc(uint)
221 GenericValue lle_X_malloc(FunctionType *M, const vector<GenericValue> &Args) {
222   assert(Args.size() == 1 && "Malloc expects one argument!");
223   GenericValue GV;
224   GV.PointerVal = (PointerTy)malloc(Args[0].UIntVal);
225   return GV;
226 }
227
228 // void free(void *)
229 GenericValue lle_X_free(FunctionType *M, const vector<GenericValue> &Args) {
230   assert(Args.size() == 1);
231   free((void*)Args[0].PointerVal);
232   return GenericValue();
233 }
234
235 // int atoi(char *)
236 GenericValue lle_X_atoi(FunctionType *M, const vector<GenericValue> &Args) {
237   assert(Args.size() == 1);
238   GenericValue GV;
239   GV.IntVal = atoi((char*)Args[0].PointerVal);
240   return GV;
241 }
242
243 // double pow(double, double)
244 GenericValue lle_X_pow(FunctionType *M, const vector<GenericValue> &Args) {
245   assert(Args.size() == 2);
246   GenericValue GV;
247   GV.DoubleVal = pow(Args[0].DoubleVal, Args[1].DoubleVal);
248   return GV;
249 }
250
251 // double exp(double)
252 GenericValue lle_X_exp(FunctionType *M, const vector<GenericValue> &Args) {
253   assert(Args.size() == 1);
254   GenericValue GV;
255   GV.DoubleVal = exp(Args[0].DoubleVal);
256   return GV;
257 }
258
259 // double sqrt(double)
260 GenericValue lle_X_sqrt(FunctionType *M, const vector<GenericValue> &Args) {
261   assert(Args.size() == 1);
262   GenericValue GV;
263   GV.DoubleVal = sqrt(Args[0].DoubleVal);
264   return GV;
265 }
266
267 // double log(double)
268 GenericValue lle_X_log(FunctionType *M, const vector<GenericValue> &Args) {
269   assert(Args.size() == 1);
270   GenericValue GV;
271   GV.DoubleVal = log(Args[0].DoubleVal);
272   return GV;
273 }
274
275 // double floor(double)
276 GenericValue lle_X_floor(FunctionType *M, const vector<GenericValue> &Args) {
277   assert(Args.size() == 1);
278   GenericValue GV;
279   GV.DoubleVal = floor(Args[0].DoubleVal);
280   return GV;
281 }
282
283 // double drand48()
284 GenericValue lle_X_drand48(FunctionType *M, const vector<GenericValue> &Args) {
285   assert(Args.size() == 0);
286   GenericValue GV;
287   GV.DoubleVal = drand48();
288   return GV;
289 }
290
291 // long lrand48()
292 GenericValue lle_X_lrand48(FunctionType *M, const vector<GenericValue> &Args) {
293   assert(Args.size() == 0);
294   GenericValue GV;
295   GV.IntVal = lrand48();
296   return GV;
297 }
298
299 // void srand48(long)
300 GenericValue lle_X_srand48(FunctionType *M, const vector<GenericValue> &Args) {
301   assert(Args.size() == 1);
302   srand48(Args[0].IntVal);
303   return GenericValue();
304 }
305
306 // void srand(uint)
307 GenericValue lle_X_srand(FunctionType *M, const vector<GenericValue> &Args) {
308   assert(Args.size() == 1);
309   srand(Args[0].UIntVal);
310   return GenericValue();
311 }
312
313 // int sprintf(sbyte *, sbyte *, ...) - a very rough implementation to make
314 // output useful.
315 GenericValue lle_X_sprintf(FunctionType *M, const vector<GenericValue> &Args) {
316   char *OutputBuffer = (char *)Args[0].PointerVal;
317   const char *FmtStr = (const char *)Args[1].PointerVal;
318   unsigned ArgNo = 2;
319
320   // printf should return # chars printed.  This is completely incorrect, but
321   // close enough for now.
322   GenericValue GV; GV.IntVal = strlen(FmtStr);
323   while (1) {
324     switch (*FmtStr) {
325     case 0: return GV;             // Null terminator...
326     default:                       // Normal nonspecial character
327       sprintf(OutputBuffer++, "%c", *FmtStr++);
328       break;
329     case '\\': {                   // Handle escape codes
330       sprintf(OutputBuffer, "%c%c", *FmtStr, *(FmtStr+1));
331       FmtStr += 2; OutputBuffer += 2;
332       break;
333     }
334     case '%': {                    // Handle format specifiers
335       char FmtBuf[100] = "", Buffer[1000] = "";
336       char *FB = FmtBuf;
337       *FB++ = *FmtStr++;
338       char Last = *FB++ = *FmtStr++;
339       unsigned HowLong = 0;
340       while (Last != 'c' && Last != 'd' && Last != 'i' && Last != 'u' &&
341              Last != 'o' && Last != 'x' && Last != 'X' && Last != 'e' &&
342              Last != 'E' && Last != 'g' && Last != 'G' && Last != 'f' &&
343              Last != 'p' && Last != 's' && Last != '%') {
344         if (Last == 'l' || Last == 'L') HowLong++;  // Keep track of l's
345         Last = *FB++ = *FmtStr++;
346       }
347       *FB = 0;
348       
349       switch (Last) {
350       case '%':
351         sprintf(Buffer, FmtBuf); break;
352       case 'c':
353         sprintf(Buffer, FmtBuf, Args[ArgNo++].IntVal); break;
354       case 'd': case 'i':
355       case 'u': case 'o':
356       case 'x': case 'X':
357         if (HowLong >= 1) {
358           if (HowLong == 1) {
359             // Make sure we use %lld with a 64 bit argument because we might be
360             // compiling LLI on a 32 bit compiler.
361             unsigned Size = strlen(FmtBuf);
362             FmtBuf[Size] = FmtBuf[Size-1];
363             FmtBuf[Size+1] = 0;
364             FmtBuf[Size-1] = 'l';
365           }
366           sprintf(Buffer, FmtBuf, Args[ArgNo++].ULongVal);
367         } else
368           sprintf(Buffer, FmtBuf, Args[ArgNo++].IntVal); break;
369       case 'e': case 'E': case 'g': case 'G': case 'f':
370         sprintf(Buffer, FmtBuf, Args[ArgNo++].DoubleVal); break;
371       case 'p':
372         sprintf(Buffer, FmtBuf, (void*)Args[ArgNo++].PointerVal); break;
373       case 's': 
374         sprintf(Buffer, FmtBuf, (char*)Args[ArgNo++].PointerVal); break;
375       default:  cout << "<unknown printf code '" << *FmtStr << "'!>";
376         ArgNo++; break;
377       }
378       strcpy(OutputBuffer, Buffer);
379       OutputBuffer += strlen(Buffer);
380       }
381       break;
382     }
383   }
384 }
385
386 // int printf(sbyte *, ...) - a very rough implementation to make output useful.
387 GenericValue lle_X_printf(FunctionType *M, const vector<GenericValue> &Args) {
388   char Buffer[10000];
389   vector<GenericValue> NewArgs;
390   GenericValue GV; GV.PointerVal = (PointerTy)Buffer;
391   NewArgs.push_back(GV);
392   NewArgs.insert(NewArgs.end(), Args.begin(), Args.end());
393   GV = lle_X_sprintf(M, NewArgs);
394   cout << Buffer;
395   return GV;
396 }
397
398 // int sscanf(const char *format, ...);
399 GenericValue lle_X_sscanf(FunctionType *M, const vector<GenericValue> &args) {
400   assert(args.size() < 10 && "Only handle up to 10 args to sscanf right now!");
401
402   const char *Args[10];
403   for (unsigned i = 0; i < args.size(); ++i)
404     Args[i] = (const char*)args[i].PointerVal;
405
406   GenericValue GV;
407   GV.IntVal = sscanf(Args[0], Args[1], Args[2], Args[3], Args[4],
408                      Args[5], Args[6], Args[7], Args[8], Args[9]);
409   return GV;
410 }
411
412
413 // int clock(void) - Profiling implementation
414 GenericValue lle_i_clock(FunctionType *M, const vector<GenericValue> &Args) {
415   extern int clock(void);
416   GenericValue GV; GV.IntVal = clock();
417   return GV;
418 }
419
420 //===----------------------------------------------------------------------===//
421 // IO Functions...
422 //===----------------------------------------------------------------------===//
423
424 // getFILE - Turn a pointer in the host address space into a legit pointer in
425 // the interpreter address space.  For the most part, this is an identity
426 // transformation, but if the program refers to stdio, stderr, stdin then they
427 // have pointers that are relative to the __iob array.  If this is the case,
428 // change the FILE into the REAL stdio stream.
429 // 
430 static FILE *getFILE(PointerTy Ptr) {
431   static Module *LastMod = 0;
432   static PointerTy IOBBase = 0;
433   static unsigned FILESize;
434
435   if (LastMod != TheInterpreter->getModule()) {  // Module change or initialize?
436     Module *M = LastMod = TheInterpreter->getModule();
437
438     // Check to see if the currently loaded module contains an __iob symbol...
439     GlobalVariable *IOB = 0;
440     if (SymbolTable *ST = M->getSymbolTable()) {
441       for (SymbolTable::iterator I = ST->begin(), E = ST->end(); I != E; ++I) {
442         SymbolTable::VarMap &M = I->second;
443         for (SymbolTable::VarMap::iterator J = M.begin(), E = M.end();
444              J != E; ++J)
445           if (J->first == "__iob")
446             if ((IOB = dyn_cast<GlobalVariable>(J->second)))
447               break;
448         if (IOB) break;
449       }
450     }
451
452     // If we found an __iob symbol now, find out what the actual address it's
453     // held in is...
454     if (IOB) {
455       // Get the address the array lives in...
456       GlobalAddress *Address = 
457         (GlobalAddress*)IOB->getOrCreateAnnotation(GlobalAddressAID);
458       IOBBase = (PointerTy)(GenericValue*)Address->Ptr;
459
460       // Figure out how big each element of the array is...
461       const ArrayType *AT =
462         dyn_cast<ArrayType>(IOB->getType()->getElementType());
463       if (AT)
464         FILESize = TD.getTypeSize(AT->getElementType());
465       else
466         FILESize = 16*8;  // Default size
467     }
468   }
469
470   // Check to see if this is a reference to __iob...
471   if (IOBBase) {
472     unsigned FDNum = (Ptr-IOBBase)/FILESize;
473     if (FDNum == 0)
474       return stdin;
475     else if (FDNum == 1)
476       return stdout;
477     else if (FDNum == 2)
478       return stderr;
479   }
480
481   return (FILE*)Ptr;
482 }
483
484
485 // FILE *fopen(const char *filename, const char *mode);
486 GenericValue lle_X_fopen(FunctionType *M, const vector<GenericValue> &Args) {
487   assert(Args.size() == 2);
488   GenericValue GV;
489
490   GV.PointerVal = (PointerTy)fopen((const char *)Args[0].PointerVal,
491                                    (const char *)Args[1].PointerVal);
492   return GV;
493 }
494
495 // int fclose(FILE *F);
496 GenericValue lle_X_fclose(FunctionType *M, const vector<GenericValue> &Args) {
497   assert(Args.size() == 1);
498   GenericValue GV;
499
500   GV.IntVal = fclose(getFILE(Args[0].PointerVal));
501   return GV;
502 }
503
504 // int feof(FILE *stream);
505 GenericValue lle_X_feof(FunctionType *M, const vector<GenericValue> &Args) {
506   assert(Args.size() == 1);
507   GenericValue GV;
508
509   GV.IntVal = feof(getFILE(Args[0].PointerVal));
510   return GV;
511 }
512
513 // size_t fread(void *ptr, size_t size, size_t nitems, FILE *stream);
514 GenericValue lle_X_fread(FunctionType *M, const vector<GenericValue> &Args) {
515   assert(Args.size() == 4);
516   GenericValue GV;
517
518   GV.UIntVal = fread((void*)Args[0].PointerVal, Args[1].UIntVal,
519                      Args[2].UIntVal, getFILE(Args[3].PointerVal));
520   return GV;
521 }
522
523 // size_t fwrite(const void *ptr, size_t size, size_t nitems, FILE *stream);
524 GenericValue lle_X_fwrite(FunctionType *M, const vector<GenericValue> &Args) {
525   assert(Args.size() == 4);
526   GenericValue GV;
527
528   GV.UIntVal = fwrite((void*)Args[0].PointerVal, Args[1].UIntVal,
529                       Args[2].UIntVal, getFILE(Args[3].PointerVal));
530   return GV;
531 }
532
533 // char *fgets(char *s, int n, FILE *stream);
534 GenericValue lle_X_fgets(FunctionType *M, const vector<GenericValue> &Args) {
535   assert(Args.size() == 3);
536   GenericValue GV;
537
538   GV.PointerVal = (PointerTy)fgets((char*)Args[0].PointerVal, Args[1].IntVal,
539                                    getFILE(Args[2].PointerVal));
540   return GV;
541 }
542
543 // FILE *freopen(const char *path, const char *mode, FILE *stream);
544 GenericValue lle_X_freopen(FunctionType *M, const vector<GenericValue> &Args) {
545   assert(Args.size() == 3);
546   GenericValue GV;
547   GV.PointerVal = (PointerTy)freopen((char*)Args[0].PointerVal,
548                                      (char*)Args[1].PointerVal,
549                                      getFILE(Args[2].PointerVal));
550   return GV;
551 }
552
553 // int fflush(FILE *stream);
554 GenericValue lle_X_fflush(FunctionType *M, const vector<GenericValue> &Args) {
555   assert(Args.size() == 1);
556   GenericValue GV;
557   GV.IntVal = fflush(getFILE(Args[0].PointerVal));
558   return GV;
559 }
560
561 // int getc(FILE *stream);
562 GenericValue lle_X_getc(FunctionType *M, const vector<GenericValue> &Args) {
563   assert(Args.size() == 1);
564   GenericValue GV;
565   GV.IntVal = getc(getFILE(Args[0].PointerVal));
566   return GV;
567 }
568
569 // int fputc(int C, FILE *stream);
570 GenericValue lle_X_fputc(FunctionType *M, const vector<GenericValue> &Args) {
571   assert(Args.size() == 2);
572   GenericValue GV;
573   GV.IntVal = fputc(Args[0].IntVal, getFILE(Args[1].PointerVal));
574   return GV;
575 }
576
577 // int ungetc(int C, FILE *stream);
578 GenericValue lle_X_ungetc(FunctionType *M, const vector<GenericValue> &Args) {
579   assert(Args.size() == 2);
580   GenericValue GV;
581   GV.IntVal = ungetc(Args[0].IntVal, getFILE(Args[1].PointerVal));
582   return GV;
583 }
584
585 // int fprintf(FILE *,sbyte *, ...) - a very rough implementation to make output
586 // useful.
587 GenericValue lle_X_fprintf(FunctionType *M, const vector<GenericValue> &Args) {
588   assert(Args.size() > 2);
589   char Buffer[10000];
590   vector<GenericValue> NewArgs;
591   GenericValue GV; GV.PointerVal = (PointerTy)Buffer;
592   NewArgs.push_back(GV);
593   NewArgs.insert(NewArgs.end(), Args.begin()+1, Args.end());
594   GV = lle_X_sprintf(M, NewArgs);
595
596   fputs(Buffer, getFILE(Args[0].PointerVal));
597   return GV;
598 }
599
600 } // End extern "C"
601
602
603 void Interpreter::initializeExternalMethods() {
604   FuncNames["lle_VP_printstr"] = lle_VP_printstr;
605   FuncNames["lle_X_print"] = lle_X_print;
606   FuncNames["lle_X_printVal"] = lle_X_printVal;
607   FuncNames["lle_X_printString"] = lle_X_printString;
608   FuncNames["lle_X_printUByte"] = lle_X_printUByte;
609   FuncNames["lle_X_printSByte"] = lle_X_printSByte;
610   FuncNames["lle_X_printUShort"] = lle_X_printUShort;
611   FuncNames["lle_X_printShort"] = lle_X_printShort;
612   FuncNames["lle_X_printInt"] = lle_X_printInt;
613   FuncNames["lle_X_printUInt"] = lle_X_printUInt;
614   FuncNames["lle_X_printLong"] = lle_X_printLong;
615   FuncNames["lle_X_printULong"] = lle_X_printULong;
616   FuncNames["lle_X_printFloat"] = lle_X_printFloat;
617   FuncNames["lle_X_printDouble"] = lle_X_printDouble;
618   FuncNames["lle_X_printPointer"] = lle_X_printPointer;
619   FuncNames["lle_Vb_putchar"]     = lle_Vb_putchar;
620   FuncNames["lle_ii_putchar"]     = lle_ii_putchar;
621   FuncNames["lle_VB_putchar"]     = lle_VB_putchar;
622   FuncNames["lle_V___main"]       = lle_V___main;
623   FuncNames["lle_X_exit"]         = lle_X_exit;
624   FuncNames["lle_X_abort"]        = lle_X_abort;
625   FuncNames["lle_X_malloc"]       = lle_X_malloc;
626   FuncNames["lle_X_free"]         = lle_X_free;
627   FuncNames["lle_X_atoi"]         = lle_X_atoi;
628   FuncNames["lle_X_pow"]          = lle_X_pow;
629   FuncNames["lle_X_exp"]          = lle_X_exp;
630   FuncNames["lle_X_log"]          = lle_X_log;
631   FuncNames["lle_X_floor"]        = lle_X_floor;
632   FuncNames["lle_X_srand"]        = lle_X_srand;
633   FuncNames["lle_X_drand48"]      = lle_X_drand48;
634   FuncNames["lle_X_srand48"]      = lle_X_srand48;
635   FuncNames["lle_X_lrand48"]      = lle_X_lrand48;
636   FuncNames["lle_X_sqrt"]         = lle_X_sqrt;
637   FuncNames["lle_X_printf"]       = lle_X_printf;
638   FuncNames["lle_X_sprintf"]      = lle_X_sprintf;
639   FuncNames["lle_X_sscanf"]       = lle_X_sscanf;
640   FuncNames["lle_i_clock"]        = lle_i_clock;
641   FuncNames["lle_X_fopen"]        = lle_X_fopen;
642   FuncNames["lle_X_fclose"]       = lle_X_fclose;
643   FuncNames["lle_X_feof"]         = lle_X_feof;
644   FuncNames["lle_X_fread"]        = lle_X_fread;
645   FuncNames["lle_X_fwrite"]       = lle_X_fwrite;
646   FuncNames["lle_X_fgets"]        = lle_X_fgets;
647   FuncNames["lle_X_fflush"]       = lle_X_fflush;
648   FuncNames["lle_X_fgetc"]        = lle_X_getc;
649   FuncNames["lle_X_getc"]         = lle_X_getc;
650   FuncNames["lle_X_fputc"]        = lle_X_fputc;
651   FuncNames["lle_X_ungetc"]       = lle_X_ungetc;
652   FuncNames["lle_X_fprintf"]      = lle_X_fprintf;
653   FuncNames["lle_X_freopen"]      = lle_X_freopen;
654 }