Skip to content

Commit

Permalink
Merge pull request #2693 from fernewelten/NC_DynamicCast
Browse files Browse the repository at this point in the history
New compiler: `as VARTYPE` clause in expressions
  • Loading branch information
ivan-mogilko authored Feb 26, 2025
2 parents 4599277 + 0706905 commit 681d19c
Show file tree
Hide file tree
Showing 8 changed files with 290 additions and 84 deletions.
4 changes: 2 additions & 2 deletions Compiler/script2/cc_internallist.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ class SectionList
: _sections(sections)
, _off2sec(off2sec)
{}
SectionList(const std::vector<std::string> &&sections,
const std::map<size_t, size_t> &&off2sec)
SectionList(std::vector<std::string> &&sections,
std::map<size_t, size_t> &&off2sec)
: _sections(std::move(sections))
, _off2sec(std::move(off2sec))
{}
Expand Down
7 changes: 4 additions & 3 deletions Compiler/script2/cc_symboltable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,8 @@ AGS::SymbolTable::SymbolTable()
// Operators
AddOperator(kKW_And, "&&", 118, kNoPrio, true, SCMD_AND);
// No compile time functions defined here; those are done with special logic.

AddOperator(kKW_As, "as", 130, kNoPrio, false, kNoOpcode);
// No compile time functions defined here; those are done with special logic.
AddOperator(kKW_BitAnd, "&", 109, kNoPrio, false, SCMD_BITAND);
OperatorCtFunctions(
kKW_BitAnd,
Expand Down Expand Up @@ -702,12 +703,12 @@ void AGS::SymbolTable::GetComponentsOfStruct(Symbol strct, std::vector<Symbol> &

// Collect the ancestors of 'struct', i.e., those structs that 'struct' extends
std::vector<Symbol> ancestors = {};
while(kKW_NoSymbol != strct)
while (kKW_NoSymbol != strct)
{
ancestors.push_back(strct);
strct = entries.at(strct).VartypeD->Parent;
}

for (auto ancestors_it = ancestors.crbegin(); ancestors_it != ancestors.crend(); ancestors_it++)
{
auto const &components = entries.at(*ancestors_it).VartypeD->Components;
Expand Down
1 change: 1 addition & 0 deletions Compiler/script2/cc_symboltable.h
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ enum Predefined : Symbol
kKW_Void, // "void"

kKW_And, // "&&"
kKW_As, // "as"
kKW_BitAnd, // "&"
kKW_BitNeg, // "~"
kKW_BitOr, // "|"
Expand Down
Loading

0 comments on commit 681d19c

Please sign in to comment.