Code cleaning, fixed makefile project errors for CLion
This commit is contained in:
parent
7b59f1f596
commit
00cbc056c8
4
.gitignore
vendored
4
.gitignore
vendored
@ -1,3 +1,3 @@
|
|||||||
.vscode/
|
/.vscode
|
||||||
build/
|
build/
|
||||||
.idea
|
|
||||||
|
|||||||
8
.idea/.gitignore
generated
vendored
Normal file
8
.idea/.gitignore
generated
vendored
Normal 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
18
.idea/misc.xml
generated
Normal 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
6
.idea/vcs.xml
generated
Normal 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
18
headers/TypeWrapper.h
Normal 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) {}
|
||||||
|
};
|
||||||
@ -7,6 +7,7 @@
|
|||||||
#include "../headers/Expression.h"
|
#include "../headers/Expression.h"
|
||||||
#include "../headers/Lexer.h"
|
#include "../headers/Lexer.h"
|
||||||
#include "../headers/ASTPrinter.h"
|
#include "../headers/ASTPrinter.h"
|
||||||
|
#include "../headers/TypeWrapper.h"
|
||||||
int main(){
|
int main(){
|
||||||
|
|
||||||
Bob bobLang;
|
Bob bobLang;
|
||||||
@ -39,5 +40,15 @@ int main(){
|
|||||||
|
|
||||||
//bobLang.runPrompt();
|
//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;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user