#include #include #include int main(int argc, char** argv) { DlangVM vm; OpenStandardLibs(&vm); if (argc == 2) { std::filesystem::path inputPath(argv[1]); auto ext = inputPath.extension().string(); if (ext == ".bdlang") vm.RunBinaryFile(argv[1]); else if (ext == ".dlang") vm.RunFile(argv[1]); else printf("Must be a .dlang or .bdlang file!"); } else if (argc == 3) { if (strcmp(argv[2], "--compile") == 0) { std::vector bytecode = {}; vm.RunFile(argv[1], &bytecode); std::filesystem::path inputPath(argv[1]); std::filesystem::path outputPath = inputPath.replace_extension(".bdlang"); std::ofstream file(outputPath, std::ios::binary); if (file.is_open()) { file.write(reinterpret_cast(bytecode.data()), bytecode.size() * sizeof(double)); file.close(); std::cout << "Compiled to: " << outputPath.string() << std::endl; } else { std::cerr << "Failed to create file: " << outputPath.string() << std::endl; } } } else { printf("%s [filename] [--compile]\n", argv[0]); } }