00001
00002
00003
#include <stdlib.h>
00004
#include <unistd.h>
00005
#include <iostream>
00006
00007
#include <qstring.h>
00008
#include <qstringlist.h>
00009
#include <qfile.h>
00010
#include <qregexp.h>
00011
00012
#include <kdebug.h>
00013
00014
#include "ada_utils.hpp"
00015
#include "adasupport.hpp"
00016
00017 QString qtext (
const RefAdaAST& n)
00018 {
00019
return QString::fromLatin1 (
text (n).c_str ());
00020 }
00021
00022 QStringList qnamelist (
const RefAdaAST& n)
00023 {
00024
QString txt =
qtext (n);
00025
00026
return QStringList::split (
'.', txt);
00027 }
00028
00029 QString ada_spec_filename (
const QString& comp_unit_name)
00030 {
00031
QString fn (comp_unit_name.lower ());
00032
00033 fn.replace (
QRegExp(
"."),
"-");
00034 fn +=
".ads";
00035
return fn;
00036 }
00037
00038 QString fq_specfilename (
const QString& comp_unit_name)
00039 {
00040
QString fname =
ada_spec_filename (comp_unit_name);
00041
00042
if (QFile::exists (fname))
00043
return fname;
00044
00045
QString adaincpath = getenv (
"ADA_INCLUDE_PATH");
00046
if (adaincpath.isNull ())
00047
return QString::null;
00048
00049
QStringList dirs = QStringList::split (
':', adaincpath);
00050
QString fq_filename;
00051
for (QStringList::Iterator it = dirs.begin (); it != dirs.end (); it++) {
00052 fq_filename = *it;
00053
if (! fq_filename.endsWith (
"/"))
00054 fq_filename +=
"/";
00055 fq_filename += fname;
00056
if (QFile::exists (fq_filename))
00057
return fq_filename;
00058 }
00059
if (fname.startsWith (
"ada-") ||
00060 fname.startsWith (
"text_io") ||
00061 fname.startsWith (
"system") ||
00062 fname.startsWith (
"unchecked_")) {
00063
kdDebug () <<
"resolution of Ada predefined library is TBD" <<
endl;
00064 }
else {
00065
kdDebug () <<
"Cannot find file " << fname <<
endl;
00066 }
00067
return QString::null;
00068 }
00069