MCPcopy Create free account
hub / github.com/albertodemichelis/squirrel / EnumStatement

Method EnumStatement

squirrel/sqcompiler.cpp:1395–1422  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1393 return val;
1394 }
1395 void EnumStatement()
1396 {
1397 Lex();
1398 SQObject id = Expect(TK_IDENTIFIER);
1399 Expect(_SC('{'));
1400
1401 SQObject table = _fs->CreateTable();
1402 SQInteger nval = 0;
1403 while(_token != _SC('}')) {
1404 SQObject key = Expect(TK_IDENTIFIER);
1405 SQObject val;
1406 if(_token == _SC('=')) {
1407 Lex();
1408 val = ExpectScalar();
1409 }
1410 else {
1411 val._type = OT_INTEGER;
1412 val._unVal.nInteger = nval++;
1413 }
1414 _table(table)->NewSlot(SQObjectPtr(key),SQObjectPtr(val));
1415 if(_token == ',') Lex();
1416 }
1417 SQTable *enums = _table(_ss(_vm)->_consts);
1418 SQObjectPtr strongid = id;
1419 enums->NewSlot(SQObjectPtr(strongid),SQObjectPtr(table));
1420 strongid.Null();
1421 Lex();
1422 }
1423 void TryCatchStatement()
1424 {
1425 SQObject exid;

Callers

nothing calls this directly

Calls 4

CreateTableMethod · 0.80
SQObjectPtrClass · 0.70
NewSlotMethod · 0.45
NullMethod · 0.45

Tested by

no test coverage detected