diff --git a/src/main.cpp b/src/main.cpp index c92a703..b8c2281 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -75,13 +75,18 @@ std::ostream& logo(std::ostream& out) { << " / \\/ / _` / __|/ _` | |\n" << " / /\\ / (_| \\__ \\ (_| | |\n" << " \\_\\ \\/ \\__,_|___/\\__,_|_|\n" - << "ver : " << __nasver << " (" << __DATE__ << " " << __TIME__ << ")\n" + << "\n" + << "ver : " << __nasver__ + << " " << nasal::get_platform() << " " << nasal::get_arch() + << " (" << __DATE__ << " " << __TIME__ << ")\n" << "std : c++ " << __cplusplus << "\n" << "core : " << std::thread::hardware_concurrency() << " core(s)\n" << "repo : https://github.com/ValKmjolnir/Nasal-Interpreter\n" << "repo : https://gitee.com/valkmjolnir/Nasal-Interpreter\n" << "wiki : https://wiki.flightgear.org/Nasal_scripting_language\n" << "\n" + << "presented by fgprc members - http://fgprc.org\n" + << "\n" << "input to get help .\n\n"; return out; } @@ -95,7 +100,8 @@ std::ostream& version(std::ostream& out) { if (num<0.01) { nasal::parse::easter_egg(); } - out << "nasal interpreter version " << __nasver; + out << "nasal interpreter version " << __nasver__; + out << " " << nasal::get_platform() << " " << nasal::get_arch(); out << " (" << __DATE__ << " " << __TIME__ << ")\n"; return out; } diff --git a/src/nasal.h b/src/nasal.h index ccfd9b7..e458572 100644 --- a/src/nasal.h +++ b/src/nasal.h @@ -1,7 +1,7 @@ #pragma once -#ifndef __nasver -#define __nasver "11.1" +#ifndef __nasver__ +#define __nasver__ "11.1" #endif #include @@ -34,7 +34,8 @@ bool is_aarch64(); bool is_ia64(); bool is_powerpc(); bool is_superh(); - +const char* get_platform(); +const char* get_arch(); // virtual machine stack depth, both global depth and value stack depth const u32 STACK_DEPTH = 4096; diff --git a/src/nasal_builtin.cpp b/src/nasal_builtin.cpp index e3bc834..39332bb 100644 --- a/src/nasal_builtin.cpp +++ b/src/nasal_builtin.cpp @@ -447,35 +447,11 @@ var builtin_sleep(context* ctx, gc* ngc) { } var builtin_platform(context* ctx, gc* ngc) { - if (is_windows()) { - return ngc->newstr("windows"); - } else if (is_linux()) { - return ngc->newstr("linux"); - } else if (is_macos()) { - return ngc->newstr("macOS"); - } - return ngc->newstr("unknown"); + return ngc->newstr(get_platform()); } var builtin_arch(context* ctx, gc* ngc) { - if (is_x86()) { - return ngc->newstr("x86"); - } else if (is_x86_64()) { - return ngc->newstr("x86-64"); - } else if (is_amd64()) { - return ngc->newstr("amd64"); - } else if (is_arm()) { - return ngc->newstr("arm"); - } else if (is_aarch64()) { - return ngc->newstr("aarch64"); - } else if (is_ia64()) { - return ngc->newstr("ia64"); - } else if (is_powerpc()) { - return ngc->newstr("powerpc"); - } else if (is_superh()) { - return ngc->newstr("superh"); - } - return ngc->newstr("unknown"); + return ngc->newstr(get_arch()); } // md5 related functions diff --git a/src/nasal_misc.cpp b/src/nasal_misc.cpp index 11f8297..13f7f30 100644 --- a/src/nasal_misc.cpp +++ b/src/nasal_misc.cpp @@ -97,6 +97,38 @@ bool is_superh() { #endif } +const char* get_platform() { + if (is_windows()) { + return "windows"; + } else if (is_linux()) { + return "linux"; + } else if (is_macos()) { + return "macOS"; + } + return "unknown platform"; +} + +const char* get_arch() { + if (is_x86()) { + return "x86"; + } else if (is_x86_64()) { + return "x86-64"; + } else if (is_amd64()) { + return "amd64"; + } else if (is_arm()) { + return "arm"; + } else if (is_aarch64()) { + return "aarch64"; + } else if (is_ia64()) { + return "ia64"; + } else if (is_powerpc()) { + return "powerpc"; + } else if (is_superh()) { + return "superh"; + } + return "unknown arch"; +} + f64 hex_to_f64(const char* str) { f64 ret = 0; for(; *str; ++str) { diff --git a/src/repl.cpp b/src/repl.cpp index fe6c9f5..6aa54e6 100644 --- a/src/repl.cpp +++ b/src/repl.cpp @@ -120,7 +120,7 @@ void repl::execute() { std::cout << "[nasal-repl] Initialization complete.\n\n"; // finish initialization, output version info - std::cout << "Nasal REPL interpreter version " << __nasver; + std::cout << "Nasal REPL interpreter version " << __nasver__; std::cout << " (" << __DATE__ << " " << __TIME__ << ")\n"; help();