1 #include "reader/module.ih"
5 Store
*Reader::readStoreOrElemStore(bool isElem
) {
6 INTEGER id
= isElem
? d_elemList
.size() : d_storeList
.size();
7 TypePath path
= readPath();
8 //std::cout << path.toString() << std::endl;
9 const std::string
&type
= path
[0];
10 INTEGER comment
= readInt();
11 std::streampos pos1
= d_rider
.tellg();
12 std::streamoff next
= readInt();
13 std::streamoff down
= readInt();
14 std::streamoff len
= readInt();
15 std::streampos pos
= d_rider
.tellg();
17 d_state
->next
= pos1
+ next
+ (std::streamoff
)4;
23 downPos
= pos1
+ down
+ (std::streamoff
)8;
25 d_state
->end
= pos
+ len
;
29 assert(d_state
->next
> pos1
);
31 assert(downPos
< d_state
->next
);
35 assert(downPos
> pos1
);
36 assert(downPos
< d_state
->end
);
39 const TypeProxyBase
*t
= TypeRegister::getInstance().get(type
); // FIXME type lookup here
42 x
= t
->newInstance(id
);
44 d_cause
= TYPENOTFOUND
;
47 if (x
!= 0) { // IF READING SUCCEEDS, INSERT MORE CHECKS HERE
48 if (true) { // samePath(x, path)
49 ReaderState
*save
= d_state
;
50 d_state
= new ReaderState();
51 x
->internalize(*this);
58 assert(d_rider
.tellg() == d_state
->end
);
59 assert(!d_rider
.eof());
61 // rd.cause := inconsistentType; AlienTypeReport(rd.cause, type);
73 d_elemList
.push_back(x
);
75 d_storeList
.push_back(x
);
78 d_rider
.seekg(pos
); // x->internalize() could have left us anywhere
80 Alien
*alien
= new Alien(id
, path
); //, d_cause); //,file
84 // join(d_store, alien)
87 d_elemList
.push_back(alien
);
89 d_storeList
.push_back(alien
);
91 ReaderState
*save
= d_state
;
92 d_state
= new ReaderState();
93 readAlien(alien
, downPos
, save
->end
);
96 assert(d_rider
.tellg() == d_state
->end
);
98 // we've just read the alien, so reset the state