| 1 |
#include <iostream> |
| 2 |
#include <stdexcept> |
| 3 |
#include <sstream> |
| 4 |
using namespace std; |
| 5 |
|
| 6 |
#include "name.h" |
| 7 |
|
| 8 |
extern "C"{ |
| 9 |
#include <ascend/general/dstring.h> |
| 10 |
#include <ascend/general/platform.h> |
| 11 |
|
| 12 |
#include <ascend/compiler/expr_types.h> |
| 13 |
#include <ascend/compiler/symtab.h> |
| 14 |
#include <ascend/compiler/nameio.h> |
| 15 |
} |
| 16 |
|
| 17 |
Nam::Nam(){ |
| 18 |
throw runtime_error("Can't create new Nam objects"); |
| 19 |
} |
| 20 |
|
| 21 |
Nam::Nam(struct Name *name) : name(name){ |
| 22 |
// nothing else |
| 23 |
} |
| 24 |
|
| 25 |
Nam::Nam(const SymChar &sym){ |
| 26 |
//cerr << "CREATING NAME from SymChar '" << sym << "'" << endl; |
| 27 |
name = CreateIdName(sym.getInternalType()); |
| 28 |
} |
| 29 |
|
| 30 |
Nam::~Nam(){ |
| 31 |
// cerr << "DESTROY NAME" << endl; |
| 32 |
DestroyName(name); |
| 33 |
} |
| 34 |
|
| 35 |
const string |
| 36 |
Nam::getName() const{ |
| 37 |
/// @TODO Make this more efficient... |
| 38 |
stringstream ss; |
| 39 |
char *longname = WriteNameString(name); |
| 40 |
ss << longname; |
| 41 |
return ss.str(); |
| 42 |
} |
| 43 |
|
| 44 |
struct Name * |
| 45 |
Nam::getInternalType() const{ |
| 46 |
return name; |
| 47 |
} |
| 48 |
|