Skip to content

Commit 681d19c

Browse files
authored
Merge pull request #2693 from fernewelten/NC_DynamicCast
New compiler: `as VARTYPE` clause in expressions
2 parents 4599277 + 0706905 commit 681d19c

File tree

8 files changed

+290
-84
lines changed

8 files changed

+290
-84
lines changed

Compiler/script2/cc_internallist.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ class SectionList
3838
: _sections(sections)
3939
, _off2sec(off2sec)
4040
{}
41-
SectionList(const std::vector<std::string> &&sections,
42-
const std::map<size_t, size_t> &&off2sec)
41+
SectionList(std::vector<std::string> &&sections,
42+
std::map<size_t, size_t> &&off2sec)
4343
: _sections(std::move(sections))
4444
, _off2sec(std::move(off2sec))
4545
{}

Compiler/script2/cc_symboltable.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,8 @@ AGS::SymbolTable::SymbolTable()
176176
// Operators
177177
AddOperator(kKW_And, "&&", 118, kNoPrio, true, SCMD_AND);
178178
// No compile time functions defined here; those are done with special logic.
179-
179+
AddOperator(kKW_As, "as", 130, kNoPrio, false, kNoOpcode);
180+
// No compile time functions defined here; those are done with special logic.
180181
AddOperator(kKW_BitAnd, "&", 109, kNoPrio, false, SCMD_BITAND);
181182
OperatorCtFunctions(
182183
kKW_BitAnd,
@@ -702,12 +703,12 @@ void AGS::SymbolTable::GetComponentsOfStruct(Symbol strct, std::vector<Symbol> &
702703

703704
// Collect the ancestors of 'struct', i.e., those structs that 'struct' extends
704705
std::vector<Symbol> ancestors = {};
705-
while(kKW_NoSymbol != strct)
706+
while (kKW_NoSymbol != strct)
706707
{
707708
ancestors.push_back(strct);
708709
strct = entries.at(strct).VartypeD->Parent;
709710
}
710-
711+
711712
for (auto ancestors_it = ancestors.crbegin(); ancestors_it != ancestors.crend(); ancestors_it++)
712713
{
713714
auto const &components = entries.at(*ancestors_it).VartypeD->Components;

Compiler/script2/cc_symboltable.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ enum Predefined : Symbol
136136
kKW_Void, // "void"
137137

138138
kKW_And, // "&&"
139+
kKW_As, // "as"
139140
kKW_BitAnd, // "&"
140141
kKW_BitNeg, // "~"
141142
kKW_BitOr, // "|"

0 commit comments

Comments
 (0)