This repository has been archived by the owner on Oct 28, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathUtils.cpp
669 lines (592 loc) · 20.8 KB
/
Utils.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
/*
* Copyright (C) 2020 Zilliqa
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#include <boost/config/warning_disable.hpp>
#include <boost/lexical_cast.hpp>
#include <boost/process.hpp>
#include <boost/spirit/include/phoenix.hpp>
#include <boost/spirit/include/qi.hpp>
#include <fstream>
#include <json/reader.h>
#include <json/value.h>
#include <json/writer.h>
#include <memory>
#include "ScillaRTL/Errors.h"
#include "ScillaRTL/Utils.h"
#include "ScillaTypes.h"
namespace {
// TODO: Use JsonUtils.h from the blockchain code. That is thread-safe.
Json::CharReaderBuilder ReadBuilder;
std::unique_ptr<Json::CharReader> JsonReader(ReadBuilder.newCharReader());
Json::StreamWriterBuilder WriteBuilder;
std::unique_ptr<Json::StreamWriter> JsonWriter(WriteBuilder.newStreamWriter());
} // namespace
namespace ScillaRTL {
namespace bf = boost::filesystem;
namespace bp = boost::process;
std::string readFile(const std::string &Filename) {
std::ifstream IfsFile(Filename);
std::string FileStr((std::istreambuf_iterator<char>(IfsFile)),
(std::istreambuf_iterator<char>()));
return FileStr;
}
Json::Value parseJSONString(const std::string &JS) {
Json::Value Ret;
std::string Error;
try {
JsonReader->parse(JS.c_str(), JS.c_str() + JS.length(), &Ret, &Error);
} catch (const std::exception &e) {
CREATE_ERROR(std::string(e.what()) + ": " + Error);
}
return Ret;
}
Json::Value parseJSONFile(const std::string &Filename) {
return parseJSONString(readFile(Filename));
}
std::string serializeJSON(const Json::Value &J) {
std::ostringstream Oss;
JsonWriter->write(J, &Oss);
return Oss.str();
}
std::string prettyPrintJSON(const Json::Value &J) {
std::ostringstream Oss;
auto SettingsSaved = WriteBuilder.settings_;
WriteBuilder.settings_["indentation"] = " ";
std::unique_ptr<Json::StreamWriter> Writer(WriteBuilder.newStreamWriter());
Writer->write(J, &Oss);
WriteBuilder.settings_ = SettingsSaved;
return Oss.str();
}
// Find "vname" in the input JSON array and return its "value".
// Typical Scilla state JSON format is expected as input.
std::optional<Json::Value> vNameValue(const Json::Value &Vs,
const std::string &VName) {
if (!Vs.isArray())
return {};
for (const auto &P : Vs) {
Json::Value VNameJ, TypeJ, ValueJ;
if (!P.isObject() ||
(VNameJ = P.get("vname", Json::nullValue)) == Json::nullValue ||
(TypeJ = P.get("type", Json::nullValue)) == Json::nullValue ||
(ValueJ = P.get("value", Json::nullValue)) == Json::nullValue ||
!VNameJ.isString() || !TypeJ.isString()) {
return {};
}
if (VNameJ == VName)
return ValueJ;
}
return {};
}
void parseBlockchainJSON(
const Json::Value &BC,
std::unordered_map<std::string,
std::unordered_map<std::string, std::string>> &BCInfo) {
auto CurBlockS = vNameValue(BC, "BLOCKNUMBER");
if (!CurBlockS || !CurBlockS->isString()) {
CREATE_ERROR("BLOCKNUMBER not found or invalid in JSON");
}
BCInfo["BLOCKNUMBER"][""] = CurBlockS->asString();
auto TS = vNameValue(BC, "TIMESTAMP");
if (TS) {
if (!TS->isObject()) {
CREATE_ERROR("TIMESTAMP not found or invalid in JSON");
}
for (auto TSi = TS->begin(); TSi != TS->end(); TSi++) {
if (!TSi->isString()) {
CREATE_ERROR(
"Invalid TIMESTAMP in blockchain JSON. Expected string values.");
}
BCInfo["TIMESTAMP"][TSi.key().asString()] = TSi->asString();
}
}
auto CID = vNameValue(BC, "CHAINID");
if (CID) {
if (!CID->isString()) {
CREATE_ERROR("CHAINID invalid in JSON");
}
BCInfo["CHAINID"][""] = CID->asString();
}
auto RC = vNameValue(BC, "REPLICATE_CONTRACT");
if (RC) {
if (!RC->isObject()) {
CREATE_ERROR("REPLICATE_CONTRACT invalid in JSON");
}
for (auto RCi = RC->begin(); RCi != RC->end(); RCi++) {
if (!RCi->isString()) {
CREATE_ERROR("Invalid REPLICATE_CONTRACT in blockchain JSON. Expected "
"string values.");
}
// The key is a JSON in itself. Let's parse and canonical print it as key.
Json::Value Key = parseJSONString(RCi.key().asString());
BCInfo["REPLICATE_CONTRACT"][prettyPrintJSON(Key)] = RCi->asString();
}
}
}
void compileLLVMToSO(const std::string &InputFile,
const std::string &OutputFile) {
try {
auto ExecP = bp::search_path("clang-13");
#if defined(__APPLE__)
if (bp::system(ExecP, "-Wno-override-module", "-fPIC", "-shared",
"-undefined", "dynamic_lookup", InputFile, "-o",
OutputFile)) {
CREATE_ERROR("Compilation of " + InputFile + " failed.");
}
#else
if (bp::system(ExecP, "-Wno-override-module", "-fPIC", "-shared", InputFile,
"-o", OutputFile)) {
CREATE_ERROR("Compilation of " + InputFile + " failed.");
}
#endif
} catch (std::system_error &E) {
CREATE_ERROR(E.what());
}
}
CompileLLVMToTempSO::CompileLLVMToTempSO(const std::string &Filename)
: SOFile(bf::temp_directory_path() / bf::unique_path()),
InputFile(Filename) {}
std::string CompileLLVMToTempSO::compile() const {
compileLLVMToSO(InputFile, SOFile.native());
return SOFile.native();
}
CompileLLVMToTempSO::~CompileLLVMToTempSO() {
boost::filesystem::remove(SOFile);
}
std::optional<int> mapDepthOfTypeString(const std::string &TypeStr) {
typedef std::pair<std::string, int> FieldTypePair;
namespace qi = boost::spirit::qi;
namespace ascii = boost::spirit::ascii;
namespace px = boost::phoenix;
qi::rule<std::string::const_iterator, std::string(), ascii::space_type>
Ident_R, TByStr_R, QualifiedTypeName_R;
qi::rule<std::string::const_iterator, std::string(), ascii::space_type>
HexQual, FilenameQual, NoQual;
qi::rule<std::string::const_iterator, FieldTypePair, ascii::space_type>
FieldTypePair_R;
qi::rule<std::string::const_iterator, int, ascii::space_type> T_R;
qi::rule<std::string::const_iterator, int, ascii::space_type> TArg_R;
qi::rule<std::string::const_iterator, int, ascii::space_type> Start_R;
// An identifier is "[a-z][a-zA-Z0-9_]*"
Ident_R =
qi::lexeme[qi::char_('a', 'z') >> *((ascii::alnum) | qi::char_('_'))];
// ByStr and ByStrX are primitive types
TByStr_R = qi::lexeme[qi::string("ByStr") >> *(ascii::digit)];
// Qualified type names. The keyword "Map" is not accepted.
// https://stackoverflow.com/questions/38039237/parsing-identifiers-except-keywords
HexQual =
qi::lexeme[qi::string("0x") >> *(ascii::xdigit) >> qi::char_('.') >>
((qi::char_('A', 'Z') >> *((ascii::alnum) | qi::char_('_'))) -
(qi::string("Map") >> !((ascii::alnum) | qi::char_('_'))))];
FilenameQual =
qi::lexeme[*((ascii::alnum) | qi::char_('-') | qi::char_('_')) >>
qi::char_('.') >>
((qi::char_('A', 'Z') >> *((ascii::alnum) | qi::char_('_'))) -
(qi::string("Map") >> !((ascii::alnum) | qi::char_('_'))))];
NoQual =
qi::lexeme[(qi::char_('A', 'Z') >> *((ascii::alnum) | qi::char_('_'))) -
(qi::string("Map") >> !((ascii::alnum) | qi::char_('_')))];
auto IdFun = [](const std::string &I) { return I; };
QualifiedTypeName_R = (HexQual)[qi::_val = px::bind(IdFun, qi::_1)] |
(FilenameQual)[qi::_val = px::bind(IdFun, qi::_1)] |
(NoQual)[qi::_val = px::bind(IdFun, qi::_1)];
;
// clang-format off
T_R =
// Rule-0: Parse non-contract addresses
(qi::lit("ByStr20") >> qi::lit("with") >>
-(qi::lit("_codehash") | qi::lit("library")) >>
qi::lit("end"))
[qi::_val = px::bind
(
[] () {
return 0;
}
)
]
// Rule-1: Parse contract addresses into an optional non-empty list of
// comma-separated FieldTypePairs. That's just another way of
// specifying a comma-separated list of 0 or more FieldTypePairs.
| (qi::lit("ByStr20") >> qi::lit("with") >> qi::lit("contract") >>
-((qi::lit("field") >> FieldTypePair_R) % ',') >> qi::lit("end"))
[qi::_val = px::bind
(
[](const boost::optional<std::vector<FieldTypePair> > &) {
return 0;
},
qi::_1
)
]
// Rule-2 Get all the PrimTyps.
| (qi::string("Int32") | qi::string("Int64")
| qi::string("Int128") | qi::string("Int256")
| qi::string("Uint32") | qi::string("Uint64")
| qi::string("Uint128") | qi::string("Uint256")
| qi::string("String") | qi::string("BNum")
| TByStr_R)
[qi::_val = px::bind
(
[](const std::string &) {
return 0;
},
qi::_1
)
]
| (qi::lit("Map") >> T_R >> T_R) // Rule-3 for Map
[qi::_val = px::bind
(
[](int, int VDepth) {
return VDepth + 1;
},
qi::_1, qi::_2
)
]
| (QualifiedTypeName_R >> *TArg_R) // Rule-4 for ADTs
[qi::_val = px::bind
(
[](const std::string &, const std::vector<int> &) {
return 0;
},
qi::_1, qi::_2
)
]
| ('(' >> T_R >> ')') // Rule-5 for "( typ )"
[qi::_val = px::bind
(
[](int Depth) {
return Depth;
},
qi::_1
)
]
;
TArg_R =
('(' >> T_R >> ')')
[qi::_val = px::bind
(
[](int Depth) {
return Depth;
},
qi::_1
)
]
| QualifiedTypeName_R
[qi::_val = px::bind
(
[](const std::string &) {
return 0;
},
qi::_1
)
]
;
FieldTypePair_R =
(Ident_R >> ':' >> T_R)
[qi::_val = px::bind
(
[](const std::string &FName, int FDepth) {
return FieldTypePair(FName, FDepth);
}, qi::_1, qi::_2
)
]
;
// clang-format on
Start_R %= T_R >> qi::eoi;
int Depth = 0;
if (!phrase_parse(TypeStr.begin(), TypeStr.end(), Start_R, ascii::space,
Depth))
return {};
return Depth;
}
bool MemStateServer::fetchStateValue(const ScillaParams::StateQuery &Query,
std::any &RetVal, bool &Found) {
std::string Type;
return fetchRemoteStateValue(ThisAddress, Query, RetVal, Found, Type);
}
bool MemStateServer::fetchRemoteStateValue(
const std::string &Addr, const ScillaParams::StateQuery &Query,
std::any &RetVal, bool &Found, std::string &Type) {
Found = false;
using MapValueT = ScillaParams::MapValueT;
auto ContrItr = BCState.find(Addr);
if (ContrItr == BCState.end())
return true;
std::string FieldName = Query.Name;
auto &ContractState = ContrItr->second;
auto FieldItr = ContractState.find(FieldName);
if (FieldItr == ContractState.end())
return true;
std::any &Field = FieldItr->second;
Type = FieldTypes[Addr][FieldName];
ASSERT_MSG(!Type.empty(),
"Type not found for " + FieldName + " but value exists.");
if (Query.MapDepth > 0) {
std::any *Val = &Field;
for (size_t I = 0; I < Query.Indices.size(); I++) {
if (!Val->has_value()) {
return true;
}
MapValueT &Map = (std::any_cast<MapValueT &>(*Val));
auto IVal = Map.find(Query.Indices[I]);
if (IVal == Map.end()) {
// not found
return true;
}
Val = &(IVal->second);
}
Found = true;
if (Query.Indices.size() == (size_t)Query.MapDepth) {
// complete access
if (Query.IgnoreVal) {
return true;
}
RetVal = std::any_cast<std::string>(*Val);
return true;
}
// partial access
MapValueT &Mdb = std::any_cast<MapValueT &>(*Val);
RetVal = Mdb;
return true;
}
Found = true;
if (!Query.IgnoreVal) {
RetVal = std::any_cast<std::string>(Field);
}
return true;
}
bool MemStateServer::updateStateValue(const ScillaParams::StateQuery &Query,
const std::any &Value) {
return updateRemoteStateValue(ThisAddress, Query, Value);
}
bool MemStateServer::updateRemoteStateValue(
const std::string &Addr, const ScillaParams::StateQuery &Query,
const std::any &Value) {
using MapValueT = ScillaParams::MapValueT;
std::string FieldName = Query.Name;
std::any &Field = BCState[Addr][FieldName];
if (Query.MapDepth > 0) {
// Map field
std::any *Val = &Field;
for (size_t I = 0; I < Query.Indices.size(); I++) {
if (!Val->has_value()) {
if (Query.IgnoreVal) {
// Key doesn't exist. Don't create one.
return true;
}
*Val = MapValueT();
}
MapValueT &Map = (std::any_cast<MapValueT &>(*Val));
auto IVal = Map.find(Query.Indices[I]);
if (Query.IgnoreVal) {
if (IVal == Map.end()) {
// Key doesn't exist. Don't create one.
return true;
}
if (I == Query.Indices.size() - 1) {
// we're at the last index provided, and it's a delete value.
Map.erase(IVal);
return true;
}
}
Val = &Map[Query.Indices[I]];
}
if (Query.Indices.size() == (size_t)Query.MapDepth) {
// complete access
*Val = std::any_cast<std::string>(Value);
} else {
// partial access
*Val = std::any_cast<MapValueT>(Value);
}
} else {
// Not a map value.
// ignoreval is only for map entries.
ASSERT(!Query.IgnoreVal);
Field = std::any_cast<std::string>(Value);
}
return true;
}
void MemStateServer::clear() {
BCState.clear();
FieldTypes.clear();
ThisAddress.clear();
BCInfo.clear();
}
// Initialize the server with only field types and no values.
// The contract-info JSON is parsed to get the field types.
void MemStateServer::initFieldTypes(const Json::Value &InitJ,
const Json::Value &CIJ) {
auto TAOpt = vNameValue(InitJ, "_this_address");
if (!TAOpt || !TAOpt->isString()) {
CREATE_ERROR("Init JSON doesn't contain proper _this_address entry");
}
ThisAddress = TAOpt->asString();
if (!CIJ.isMember("contract_info") ||
!CIJ["contract_info"].isMember("fields") ||
!CIJ["contract_info"]["fields"].isArray()) {
CREATE_ERROR("Incorrect format of contract info JSON");
}
auto &Fields = CIJ["contract_info"]["fields"];
for (auto &Field : Fields) {
if (!Field.isObject() || !Field.isMember("vname") ||
!Field.isMember("type") || !Field.isMember("depth")) {
CREATE_ERROR("Incorrect field format in contract info");
} else {
auto FieldName = Field["vname"].asString();
if (FieldName == "_balance")
continue;
auto FieldType = Field["type"].asString();
FieldTypes[ThisAddress][FieldName] = FieldType;
}
}
}
std::string MemStateServer::initState(const Json::Value &InitJ,
const Json::Value &StateJ,
const Json::Value &BIJ) {
auto TAOpt = vNameValue(InitJ, "_this_address");
if (!TAOpt || !TAOpt->isString()) {
CREATE_ERROR("Init JSON doesn't contain proper _this_address entry");
}
ThisAddress = TAOpt->asString();
std::function<std::string(const std::string &, const Json::Value &)>
recurser = [&recurser, this](const std::string &Addr,
const Json::Value &StateJ) {
std::string Balance = "0";
if (!StateJ.isArray()) {
CREATE_ERROR("Expected state JSON to be array");
}
for (auto &VJ : StateJ) {
Json::Value VNameJ, VTypJ, VValJ;
if (!VJ.isObject() ||
(VNameJ = VJ.get("vname", Json::nullValue)) == Json::nullValue ||
(VTypJ = VJ.get("type", Json::nullValue)) == Json::nullValue ||
(VValJ = VJ.get("value", Json::nullValue)) == Json::nullValue ||
!VNameJ.isString() || !VTypJ.isString()) {
CREATE_ERROR("Invalid state JSON variable");
}
std::string VName = VNameJ.asString();
if (VName == "_balance") {
Balance = VValJ.asString();
}
if (VName == "_external") {
if (!VValJ.isArray()) {
CREATE_ERROR("External fields must be an array");
}
for (const auto &ES : VValJ) {
Json::Value AddrJ, StateJ;
if (!ES.isObject() ||
(AddrJ = ES.get("address", Json::nullValue)) ==
Json::nullValue ||
(StateJ = ES.get("state", Json::nullValue)) ==
Json::nullValue ||
!AddrJ.isString() || !StateJ.isArray()) {
CREATE_ERROR("External contract data malformed.");
}
recurser(AddrJ.asString(), StateJ);
}
continue;
}
auto DepthOpt = mapDepthOfTypeString(VTypJ.asString());
if (!DepthOpt) {
CREATE_ERROR("Error computing map depth of type " +
VTypJ.asString());
}
auto Depth = *DepthOpt;
std::any V;
std::function<void(int, std::any &, const Json::Value &)> jsonToSV =
[&jsonToSV, &VName](int Depth, std::any &SV,
const Json::Value &JSONV) -> void {
if (Depth == 0) {
SV = serializeJSON(JSONV);
return;
}
if (!JSONV.isArray()) {
CREATE_ERROR("At depth " + std::to_string(Depth) + " expected " +
VName + " to be JSON array");
}
// If SV doesn't hold a value yet, create one.
if (!SV.has_value())
SV = ScillaParams::MapValueT();
ASSERT(std::has_type<ScillaParams::MapValueT>(SV));
auto &MapV = std::any_cast<ScillaParams::MapValueT &>(SV);
for (auto &Entry : JSONV) {
if (!Entry.isObject() || !Entry.isMember("key") ||
!Entry.isMember("val")) {
CREATE_ERROR(VName + " has malformed map structure");
}
auto &SubV = MapV[serializeJSON(Entry["key"])];
jsonToSV(Depth - 1, SubV, Entry["val"]);
}
};
jsonToSV(Depth, V, VValJ);
ScillaParams::StateQuery Query = {VName, Depth,
std::vector<std::string>(), false};
updateRemoteStateValue(Addr, Query, V);
FieldTypes[Addr][VName] = VTypJ.asString();
}
return Balance;
};
parseBlockchainJSON(BIJ, BCInfo);
return recurser(ThisAddress, StateJ);
}
bool MemStateServer::fetchBlockchainInfo(const std::string &QueryName,
const std::string &QueryArg,
std::string &RetVal) {
auto Itr1 = BCInfo.find(QueryName);
if (Itr1 == BCInfo.end()) {
return false;
}
auto Itr2 = Itr1->second.find(QueryArg);
if (Itr2 == Itr1->second.end()) {
return false;
}
RetVal = Itr2->second;
return true;
}
Json::Value MemStateServer::dumpToJSON() {
Json::Value RetVal(Json::arrayValue);
for (auto &Field : BCState[ThisAddress]) {
auto FieldName = Field.first;
// Balance here may not be updated. It must be taken from Scilla output.
if (FieldName == "_balance")
continue;
std::function<Json::Value(std::any &)> svToJSON =
[&svToJSON](std::any &SV) -> Json::Value {
if (std::has_type<std::string>(SV)) {
return parseJSONString(std::any_cast<std::string>(SV));
} else {
Json::Value MapVal = Json::arrayValue;
auto &SVMap = std::any_cast<ScillaParams::MapValueT &>(SV);
for (auto &KV : SVMap) {
Json::Value KVJ(Json::objectValue);
KVJ["key"] = parseJSONString(KV.first);
KVJ["val"] = svToJSON(KV.second);
MapVal.append(KVJ);
}
return MapVal;
}
};
auto AddrFieldTypes = FieldTypes[ThisAddress];
auto Value = svToJSON(Field.second);
auto TypeItr = AddrFieldTypes.find(FieldName);
auto Type = TypeItr == AddrFieldTypes.end() ? "<unknown>" : TypeItr->second;
Json::Value J(Json::objectValue);
J["vname"] = FieldName;
J["type"] = Type;
J["value"] = Value;
RetVal.append(J);
}
return RetVal;
}
} // namespace ScillaRTL