Rev | Line | |
---|
[4] | 1 | #include "common.h"
|
---|
| 2 |
|
---|
| 3 |
|
---|
| 4 |
|
---|
| 5 | CConstBase::CConstBase(char *Name){
|
---|
| 6 | this->Name = (char *)malloc(lstrlen(Name)+1);
|
---|
| 7 | lstrcpy(this->Name, Name);
|
---|
| 8 | }
|
---|
| 9 | CConstBase::~CConstBase(){
|
---|
| 10 | free(Name);
|
---|
| 11 | Name=0;
|
---|
| 12 | }
|
---|
| 13 |
|
---|
| 14 |
|
---|
| 15 |
|
---|
| 16 | CConst::CConst(char *Name, char *Expression):CConstBase(Name)
|
---|
| 17 | {
|
---|
| 18 | LONG_PTR lpIndex;
|
---|
| 19 | Type = StaticCalculation(false, Expression, 0, &i64data, &lpIndex);
|
---|
| 20 | }
|
---|
| 21 | CConst::~CConst(){
|
---|
| 22 | }
|
---|
| 23 |
|
---|
[5] | 24 | CConstMacro::CConstMacro(char *Name, char *Expression):CConstBase(Name)
|
---|
| 25 | {
|
---|
| 26 | }
|
---|
| 27 | CConstMacro::~CConstMacro(){
|
---|
| 28 | }
|
---|
[4] | 29 |
|
---|
| 30 |
|
---|
[5] | 31 |
|
---|
[4] | 32 | CDBConst::CDBConst(){
|
---|
| 33 | //定数管理領域を初期化
|
---|
| 34 | ppobj_Const = (CConst **)malloc(1);
|
---|
| 35 | NumOfConst = 0;
|
---|
| 36 |
|
---|
| 37 | //定数マクロ管理領域を初期化
|
---|
| 38 | ppobj_Macro = (CConstMacro **)malloc(1);
|
---|
| 39 | NumOfMacro = 0;
|
---|
| 40 | }
|
---|
| 41 | CDBConst::~CDBConst(){
|
---|
| 42 | int i;
|
---|
| 43 | for(i=0; i<NumOfConst; i++){
|
---|
| 44 | delete ppobj_Const[i];
|
---|
| 45 | }
|
---|
| 46 | free(ppobj_Const);
|
---|
| 47 | ppobj_Const = 0;
|
---|
| 48 |
|
---|
| 49 | for(i=0; i<NumOfMacro; i++){
|
---|
| 50 | delete ppobj_Macro[i];
|
---|
| 51 | }
|
---|
| 52 | free(ppobj_Macro);
|
---|
| 53 | ppobj_Macro = 0;
|
---|
| 54 | }
|
---|
| 55 |
|
---|
| 56 | void CDBConst::Add(char *buffer){
|
---|
| 57 | int i;
|
---|
| 58 |
|
---|
| 59 | //名前を取得
|
---|
| 60 | char Name[VN_SIZE];
|
---|
| 61 | for(i=0;;i++){
|
---|
| 62 | if(buffer[i]=='\0'){
|
---|
| 63 | SetError(10,"Const",cp);
|
---|
| 64 | return;
|
---|
| 65 | }
|
---|
| 66 | if(buffer[i]=='='||buffer[i]=='('){
|
---|
| 67 | Name[i]=0;
|
---|
| 68 | break;
|
---|
| 69 | }
|
---|
| 70 | Name[i]=buffer[i];
|
---|
| 71 | }
|
---|
| 72 |
|
---|
| 73 | if(buffer[i] == '('){
|
---|
| 74 | //定数マクロ
|
---|
| 75 |
|
---|
| 76 | //未完成
|
---|
| 77 | }
|
---|
| 78 | else{
|
---|
| 79 | //一般の定数
|
---|
| 80 | char *Expression = buffer + i + 1;
|
---|
| 81 |
|
---|
| 82 | AddConst(Name,Expression);
|
---|
| 83 | }
|
---|
| 84 | }
|
---|
| 85 |
|
---|
| 86 | void CDBConst::AddConst(char *Name, char *Expression){
|
---|
| 87 | CConst *newconst = new CConst(Name, Expression);
|
---|
| 88 |
|
---|
| 89 | //管理クラスへ追加
|
---|
| 90 | ppobj_Const = (CConst **)realloc( ppobj_Const, (NumOfConst + 1) * sizeof(CConst) );
|
---|
| 91 | ppobj_Const[NumOfConst] = newconst;
|
---|
| 92 | NumOfConst++;
|
---|
| 93 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.