[pure-lang-svn] SF.net SVN: pure-lang: [177] pure/trunk
Status: Beta
Brought to you by:
agraef
From: <ag...@us...> - 2008-06-04 23:58:48
|
Revision: 177 http://pure-lang.svn.sourceforge.net/pure-lang/?rev=177&view=rev Author: agraef Date: 2008-06-04 16:58:56 -0700 (Wed, 04 Jun 2008) Log Message: ----------- Provide host system information in the interpreter. Modified Paths: -------------- pure/trunk/interpreter.cc pure/trunk/interpreter.hh pure/trunk/pure.1 pure/trunk/pure.cc Modified: pure/trunk/interpreter.cc =================================================================== --- pure/trunk/interpreter.cc 2008-06-04 23:35:22 UTC (rev 176) +++ pure/trunk/interpreter.cc 2008-06-04 23:58:56 UTC (rev 177) @@ -297,9 +297,10 @@ } void interpreter::init_sys_vars(const string& version, + const string& host, const list<string>& argv) { - // command line arguments and version information + // command line arguments, system and version information pure_expr *args = pure_const(symtab.nil_sym().f); for (list<string>::const_reverse_iterator it = argv.rbegin(); it != argv.rend(); it++) { @@ -311,6 +312,7 @@ defn("argc", pure_int(argv.size())); defn("argv", args); defn("version", pure_cstring_dup(version.c_str())); + defn("sysinfo", pure_cstring_dup(host.c_str())); } // Errors and warnings. Modified: pure/trunk/interpreter.hh =================================================================== --- pure/trunk/interpreter.hh 2008-06-04 23:35:22 UTC (rev 176) +++ pure/trunk/interpreter.hh 2008-06-04 23:58:56 UTC (rev 177) @@ -245,6 +245,7 @@ virtual ~interpreter(); // Populate the global environment with some useful variables. void init_sys_vars(const string& version = "", + const string& host = "", const list<string>& argv = list<string>()); // Option data. You can modify these according to your needs. Modified: pure/trunk/pure.1 =================================================================== --- pure/trunk/pure.1 2008-06-04 23:35:22 UTC (rev 176) +++ pure/trunk/pure.1 2008-06-04 23:58:56 UTC (rev 177) @@ -67,7 +67,9 @@ .B argv variables. Moreover, the .B version -variable is set to the Pure interpreter version. +variable is set to the Pure interpreter version, and the +.B sysinfo +variable provides information about the host system. .PP If available, the prelude script .B prelude.pure @@ -902,8 +904,9 @@ > \fBlist\fP -lv argc var argc = 0; argv var argv = []; +sysinfo var sysinfo = "i686-pc-linux-gnu"; version var version = "0.1"; -3 variables +4 variables .fi .PP If you're like me then you'll frequently have to look up how some operations Modified: pure/trunk/pure.cc =================================================================== --- pure/trunk/pure.cc 2008-06-04 23:35:22 UTC (rev 176) +++ pure/trunk/pure.cc 2008-06-04 23:58:56 UTC (rev 177) @@ -18,6 +18,9 @@ using namespace std; +#ifndef HOST +#define HOST "unknown" +#endif #ifndef PACKAGE_VERSION #define PACKAGE_VERSION "0.0" #endif @@ -190,7 +193,8 @@ list<string> myargs; for (char **args = ++argv; *args; ++args) if (*args == string("-h")) { - cout << "Pure " << PACKAGE_VERSION << " " << COPYRIGHT << endl << USAGE; + cout << "Pure " << PACKAGE_VERSION << " (" << HOST << ") " + << COPYRIGHT << endl << USAGE; return 0; } else if (*args == string("-i")) force_interactive = true; @@ -212,7 +216,7 @@ interp.error(prog + ": invalid option " + *args); return 1; } - interp.init_sys_vars(PACKAGE_VERSION, myargs); + interp.init_sys_vars(PACKAGE_VERSION, HOST, myargs); if (want_prelude) { // load the prelude if we can find it FILE *fp = fopen("prelude.pure", "r"); @@ -252,7 +256,8 @@ interp.interactive = true; if (isatty(fileno(stdin))) { // connected to a terminal, print sign-on and initialize readline - cout << "Pure " << PACKAGE_VERSION << " " << COPYRIGHT << endl << LICENSE; + cout << "Pure " << PACKAGE_VERSION << " (" << HOST << ") " + << COPYRIGHT << endl << LICENSE; if (have_prelude) cout << "Loaded prelude from " << prelude << ".\n\n"; rl_readline_name = "Pure"; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |