Skip to content

Commit 0040a30

Browse files
Merge pull request #24 from SujalChoudhari/dev
Project cleanup
2 parents 1aafe81 + 5831dc8 commit 0040a30

File tree

5 files changed

+12
-69
lines changed

5 files changed

+12
-69
lines changed

Application/Application.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,6 @@ namespace Coda {
2727

2828
std::string subCommand = argParser.getSubCommand();
2929

30-
#if _DEBUG
31-
return repl();
32-
33-
#else
34-
3530
if (subCommand == "repl") {
3631
return repl();
3732
}
@@ -83,7 +78,6 @@ namespace Coda {
8378
}
8479
return EXIT_SUCCESS;
8580
}
86-
#endif
8781
}
8882

8983

Application/Application.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ namespace Coda {
1919
dddddddd \n\
2020
CCCCCCCCCCCCC d::::::d \n\
2121
CCC::::::::::::C d::::::d \n\
22-
CC:::::::::::::::C d::::::d \033[0mv0.3\033[1;96m \n\
22+
CC:::::::::::::::C d::::::d \033[0mv1.0.1\033[1;96m \n\
2323
C:::::CCCCCCCC::::C d:::::d \n\
2424
C:::::C CCCCCC ooooooooooo ddddddddd:::::d aaaaaaaaaaaaa \n\
2525
C:::::C oo:::::::::::oo dd::::::::::::::d a::::::::::::a \n\

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [1.0.1] - 04-10-2023
9+
- Code cleaning
10+
- Removed `Linux` support.
11+
812
## [1.0] - 02-10-2023
913

1014
### Added

Frontend/Importer/Importer.cpp

Lines changed: 1 addition & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,7 @@
11
#include "Importer.h"
22
#include <algorithm>
3-
4-
#if _WIN32
53
#include <Windows.h>
6-
#else
7-
#include <unistd.h>
8-
#include <linux/limits.h>
9-
#endif
4+
105

116
#include "../../Error/Error.h"
127

@@ -90,9 +85,6 @@ namespace Coda {
9085
Error::Importer::raise("Imported file not found: " + importString);
9186
}
9287

93-
94-
#if _WIN32 // Check if the platform is Windows
95-
9688
std::string Importer::getExecutablePath() {
9789
wchar_t buffer[MAX_PATH];
9890
GetModuleFileNameW(NULL, buffer, MAX_PATH);
@@ -108,37 +100,10 @@ namespace Coda {
108100
return narrowExecutablePath;
109101
}
110102

111-
#else // Assuming Unix-like system (Linux, macOS, etc.)
112-
std::string Importer::getExecutablePath() {
113-
char buffer[PATH_MAX];
114-
ssize_t len = readlink("/proc/self/exe", buffer, sizeof(buffer) - 1);
115-
if (len != -1) {
116-
buffer[len] = '\0';
117-
std::string executablePath(buffer);
118-
size_t lastSlashIndex = executablePath.rfind("/");
119-
if (lastSlashIndex != std::string::npos) {
120-
executablePath = executablePath.substr(0, lastSlashIndex + 1);
121-
}
122-
return executablePath;
123-
}
124-
else {
125-
throw "failed to get path of executable file"
126-
return "";
127-
}
128-
}
129-
#endif
130-
131-
#if _WIN32
132103
bool Importer::fileExists(const std::string& filePath) {
133104
std::wstring wideFilePath(filePath.begin(), filePath.end());
134105
DWORD fileAttributes = GetFileAttributes(wideFilePath.c_str());
135106
return (fileAttributes != INVALID_FILE_ATTRIBUTES && !(fileAttributes & FILE_ATTRIBUTE_DIRECTORY));
136107
}
137-
#else
138-
bool fileExists(const std::string& filePath) {
139-
std::wstring wideFilePath(filePath.begin(), filePath.end());
140-
return access(wideFilePath, F_OK) == 0;
141-
}
142-
#endif
143108
}
144109
}

Runtime/Interpreter/EvaluateObjectType.cpp

Lines changed: 6 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
#include "Interpreter.h"
2-
#ifdef _WIN32
32
#include <Windows.h>
4-
#else
5-
#include <dlcfn.h>
6-
#endif // _WIN32
3+
74

85

96
namespace Coda {
@@ -65,7 +62,7 @@ namespace Coda {
6562
IF_ERROR_RETURN_VALUE_PTR;
6663
Value args = Value();
6764
ValuePtr name = interpret(*callExpression.left.get(), env);
68-
65+
6966
Position pos = callExpression.left->endPosition;
7067
pos.scope = name->value;
7168
Interpreter::callStack.push(pos);
@@ -137,14 +134,9 @@ namespace Coda {
137134

138135
typedef void (*FunctionType) (IValuePtr, IValuePtr, IEnvironment*);
139136

140-
#ifdef _WIN32
141137
dllFilename += ".dll";
142138
std::wstring s(dllFilename.begin(), dllFilename.end());
143139
HMODULE lib = LoadLibrary(s.c_str());
144-
#else
145-
dllFilename += ".so";
146-
void* lib = dlopen(dllFilename, RTLD_LAZY);
147-
#endif
148140

149141

150142
if (!lib) {
@@ -153,19 +145,12 @@ namespace Coda {
153145
}
154146

155147
FunctionType myFunction;
156-
#ifdef _WIN32
157148
myFunction = (FunctionType)GetProcAddress(lib, functionName.c_str());
158-
#else
159-
myFunction = (FunctionType)dlsym(lib, functionName.c_str());
160-
#endif
149+
161150

162151
if (!myFunction) {
163152
Error::Runtime::raise("Cannot find function " + functionName + " at, ", Interpreter::callStack, callExpression.startPosition, callExpression.endPosition);
164-
#ifdef _WIN32
165153
FreeLibrary(lib);
166-
#else
167-
dlclose(lib);
168-
#endif
169154
return nullptr;
170155
}
171156

@@ -178,14 +163,9 @@ namespace Coda {
178163
Error::Runtime::raise("Error in running '" + functionName + "': " + s);
179164
}
180165

181-
// Unload the library
182-
#ifdef _WIN32
183166
FreeLibrary(lib);
184-
#else
185-
dlclose(lib);
186-
#endif
187167
return std::dynamic_pointer_cast<Value>(result);
188-
}
168+
}
189169

190170

191171
ValuePtr Interpreter::evaluateMemberExpression(const Frontend::Node& astNode, Environment& env)
@@ -237,5 +217,5 @@ namespace Coda {
237217
IF_ERROR_RETURN_VALUE_PTR;
238218
return env.addFunction(astNode.value, astNode, env);
239219
}
240-
} // namespace Runtime
241-
} // namespace Coda
220+
} // namespace Runtime
221+
} // namespace Coda

0 commit comments

Comments
 (0)