Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Arnaud Kress
easea
Commits
dfbde2df
Commit
dfbde2df
authored
Jun 12, 2014
by
Joseph Pallamidessi
Browse files
Correct user classes declaration/definition and serialization
parent
53686f45
Changes
1
Hide whitespace changes
Inline
Side-by-side
compiler/EaseaSym.cpp
View file @
dfbde2df
...
...
@@ -19,6 +19,9 @@
#include
"EaseaSym.h"
#include
"debug.h"
using
std
::
cout
;
using
std
::
endl
;
void
debug
(
char
*
s
)
{
#ifdef _DEBUG
...
...
@@ -55,7 +58,7 @@ template <class T> CListItem<T> *CLList<T>::walkToNextItem()
/////////////////////////////////////////////////////////////////////////////
// symbol construction/destruction
CSymbol
::
CSymbol
(
char
*
s
)
CSymbol
::
CSymbol
(
const
char
*
s
)
{
assert
(
s
!=
NULL
);
...
...
@@ -256,9 +259,16 @@ void CSymbol::print(FILE *fp)
fprintf
(
fpOutputFile
,
"
\t\t\t
EASEA_Line <<
\"
NULL
\"
<<
\"
\"
;
\n
"
);
fprintf
(
fpOutputFile
,
"}
\n
"
);
}
// it's a classical array
else
if
(
pSym
->
Object
->
ObjectType
==
oArray
)
{
fprintf
(
fpOutputFile
,
"
\t
for(int EASEA_Ndx=0; EASEA_Ndx<%d; EASEA_Ndx++)
\n
"
,
pSym
->
Object
->
nSize
/
pSym
->
Object
->
pType
->
nSize
);
fprintf
(
fpOutputFile
,
"
\t\t
EASEA_Line << this->%s[EASEA_Ndx] <<
\"
\"
;
\n
"
,
pSym
->
Object
->
sName
);
}
else
{
// it's
not an array of pointer
s
// it's
a pointer to an user-defined cla
s
fprintf
(
fpOutputFile
,
"
\t
if(this->%s != NULL){
\n
"
,
pSym
->
Object
->
sName
);
fprintf
(
fpOutputFile
,
"
\t\t
EASEA_Line <<
\"\\
a
\"
;
\n
"
);
fprintf
(
fpOutputFile
,
"
\t\t
EASEA_Line << this->%s->serializer() <<
\"
\"
;
\n
"
,
pSym
->
Object
->
sName
);
...
...
@@ -317,7 +327,7 @@ void CSymbol::print(FILE *fp)
fprintf
(
fpOutputFile
,
"
\t
if(strcmp(line.c_str(),
\"
NULL
\"
)==0)
\n
"
);
fprintf
(
fpOutputFile
,
"
\t\t
this->%s = NULL;
\n
"
,
pSym
->
Object
->
sName
);
fprintf
(
fpOutputFile
,
"
\t
else{
\n
"
);
fprintf
(
fpOutputFile
,
"
\t\t
this->%s = new %s;
\n
"
,
pSym
->
Object
->
sName
,
pSym
->
Object
->
pType
->
sName
);
fprintf
(
fpOutputFile
,
"
\t\t
this->%s = new %s;
\n
"
,
pSym
->
Object
->
sName
,
sName
);
fprintf
(
fpOutputFile
,
"
\t\t
this->%s->deserializer(EASEA_Line);
\n
"
,
pSym
->
Object
->
sName
);
fprintf
(
fpOutputFile
,
"
\t
}"
);
}
...
...
@@ -559,6 +569,18 @@ void CSymbol::serializeIndividual(FILE *fp, char* sCompleteName)
fprintf
(
fpOutputFile
,
"}
\n
"
);
}
// it's a classical array
else
if
(
pSym
->
Object
->
ObjectType
==
oArray
)
{
fprintf
(
fpOutputFile
,
"
\t
for(int EASEA_Ndx=0; EASEA_Ndx<%d; EASEA_Ndx++)
\n
"
,
pSym
->
Object
->
nSize
);
fprintf
(
fpOutputFile
,
"
\t\t
EASEA_Line << this->%s[EASEA_Ndx].serialize() <<
\"
\"
;
\n
"
,
pSym
->
Object
->
sName
);
}
else
if
(
pSym
->
Object
->
ObjectType
==
oObject
)
{
fprintf
(
fpOutputFile
,
"
\t
EASEA_Line <<
\"\\
a
\"
;
\n
"
);
fprintf
(
fpOutputFile
,
"
\t
EASEA_Line << this->%s.serializer() <<
\"
\"
;
\n
"
,
pSym
->
Object
->
sName
);
}
else
{
// if it's not an array of pointers
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment