Code cleaning, fixed makefile project errors for CLion

This commit is contained in:
Bobby Lucero 2023-05-26 21:05:03 -04:00
parent 7b59f1f596
commit 00cbc056c8
9 changed files with 80 additions and 19 deletions

4
.gitignore vendored
View File

@ -1,3 +1,3 @@
.vscode/
/.vscode
build/
.idea

8
.idea/.gitignore generated vendored Normal file
View File

@ -0,0 +1,8 @@
# Default ignored files
/shelf/
/workspace.xml
# Editor-based HTTP Client requests
/httpRequests/
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml

18
.idea/misc.xml generated Normal file
View File

@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ExternalStorageConfigurationManager" enabled="true" />
<component name="MakefileSettings">
<option name="linkedExternalProjectsSettings">
<MakefileProjectSettings>
<option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="modules">
<set>
<option value="$PROJECT_DIR$" />
</set>
</option>
<option name="version" value="2" />
</MakefileProjectSettings>
</option>
</component>
<component name="MakefileWorkspace" PROJECT_DIR="$PROJECT_DIR$" />
</project>

6
.idea/vcs.xml generated Normal file
View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="" vcs="Git" />
</component>
</project>

18
headers/TypeWrapper.h Normal file
View File

@ -0,0 +1,18 @@
#pragma once
#include <string>
struct Object
{
virtual ~Object(){};
};
struct Number : public Object
{
double value;
explicit Number(double value) : value(value) {}
};
struct String : public Object
{
std::string value;
explicit String(std::string str) : value(str) {}
};

View File

@ -7,6 +7,7 @@
#include "../headers/Expression.h"
#include "../headers/Lexer.h"
#include "../headers/ASTPrinter.h"
#include "../headers/TypeWrapper.h"
int main(){
Bob bobLang;
@ -39,5 +40,15 @@ int main(){
//bobLang.runPrompt();
std::shared_ptr<Object> object = std::make_shared<String>(String{"Hi"});
if(auto num = std::dynamic_pointer_cast<Number>(object))
{
std::cout << num->value << std::endl;
}else if(auto str = std::dynamic_pointer_cast<String>(object))
{
std::cout << str->value << std::endl;
}
return 0;
}