Skip to content

Commit

Permalink
Linked to my new LangDev StackExchange question
Browse files Browse the repository at this point in the history
  • Loading branch information
FlatAssembler committed Dec 14, 2024
1 parent eb4950e commit 231d403
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
5 changes: 4 additions & 1 deletion TreeNode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,10 @@ class TreeNode {
Associativity associativity);

protected:
std::set<std::string> getStringsInSubnodes() const {
std::set<std::string> getStringsInSubnodes()
const { // This will need to be significantly modified if we want to
// implement the `typeid` operator. You can read more about that
// here: https://langdev.stackexchange.com/q/4189/330
auto setToBeReturned = std::set<std::string>();
if (text == "asm(" or text == "asm_i32(" or text == "asm_i64(" or
text == "asm_f32(" or
Expand Down
9 changes: 7 additions & 2 deletions TreeRootNode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,12 @@ class TreeRootNode : public TreeNode // Sets up the compilation context, rather
<< std::endl;
throw std::runtime_error("Invalid compilation target!");
}
auto allTheStrings = getStringsInSubnodes();
auto allTheStrings =
getStringsInSubnodes(); // TODO: To implement the `typeid` operator,
// we'd probably need to pass the compilation
// context to the `getStringsInSubnodes` method.
// You can read more about that problem here:
// https://langdev.stackexchange.com/q/4189/330
for (auto string : allTheStrings) {
context.globalVariables[string] = context.globalVariablePointer;
context.variableTypes[string] = "CharacterPointer";
Expand All @@ -170,7 +175,7 @@ class TreeRootNode : public TreeNode // Sets up the compilation context, rather
context.globalVariablePointer += string.size() - 1;
}
for (auto childNode : children) {
if (basicDataTypeSizes.count(childNode.text) ||
if (basicDataTypeSizes.count(childNode.text) or
isPointerType(childNode.text)) { // Global variable declaration
for (auto variableName : childNode.children) {
if (!isValidVariableName(variableName.text) or
Expand Down

0 comments on commit 231d403

Please sign in to comment.