Removed javascript virtual machine "tryit" from website, added some documentation

This commit is contained in:
Dale Weiler 2012-11-23 21:41:45 +00:00
parent e7c628cdc9
commit 7e1985d0a9
9 changed files with 323 additions and 31798 deletions

316
doc.html Normal file
View file

@ -0,0 +1,316 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="chrome=1">
<title>GMQCC by graphitemaster</title>
<link rel="stylesheet" href="stylesheets/styles.css">
<link rel="stylesheet" href="stylesheets/pygment_trac.css">
<script src="javascripts/scale.fix.js"></script>
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
</head>
<body>
<a href="https://github.com/graphitemaster/gmqcc"><div class="fork"></div></a>
<div class="wrapper">
<header>
<h1 class="header">GMQCC</h1>
<p class="header">An Improved Quake C Compiler</p>
<ul>
<li class="download"><a href="https://github.com/graphitemaster/gmqcc/zipball/master">Download ZIP</a></li>
<li class="download"><a href="https://github.com/graphitemaster/gmqcc/tarball/master">Download TAR</a></li>
<li class="buttons"><a href="https://github.com/graphitemaster/gmqcc/issues">Issues</a></li>
<li class="buttons"><a href="doc.html">Documentation</a></li>
<li class="buttons"><a href="https://github.com/graphitemaster/gmqcc">View On GitHub</a></li>
</ul>
</header>
<section>
<h2>Defaults Flag</h2>
<p>
The <i>-show-defaults</i> flag instructs the compiler to print out the defaults used related to
the standard, optimization, and code generation. When this flag is specified, the compiler
will just print the defaults and quit. No compilation is performed.
</p>
<pre>$ gmqcc -show-defautls</pre>
<h2>Compiling for an alternitive standard</h2>
To compile with a different dialect of the QuakeC programming language the <i>-std</i>
flag can be instructed to select one of the following options:
<table border="0">
<tr>
<td>gmqcc</td>
<td>default standard</td>
</tr>
<tr>
<td>fteqcc</td>
<td>fteqcc standard</td>
</tr>
<tr>
<td>qcc</td>
<td>vanila QuakeC standard</td>
</tr>
</table>
<h2>Common compiler options</h2>
<table border="0">
<tr>
<td>Options</td>
<td>What it does</td>
</tr>
<tr>
<td>-l&lt;path&gt;</td>
<td>Adds &lt;path&gt; to the directories searched by the preprocessor for include file resolution.</td>
</tr>
<tr>
<td>-o &lt;file&gt;</td>
<td>Generates the named executable (progs.src) file (when not specified default is progs.src).</td>
</tr>
<tr>
<td>-O&lt;level&gt;</td>
<td>Specified the optimize level: highest being 3, lowest being 0 (not optimization).</td>
</tr>
<tr>
<td>-E</td>
<td>Instructs the compiler to only preprocess the input, writing the preprocessed source to stdout</td>
</tr>
<tr>
<td>-Wall</td>
<td>Enables all compiled warnings for the selcted standard</td>
</tr>
<tr>
<td>-Werror</td>
<td>Instruct the compiler to treat all warnings as errors</td>
</tr>
<tr>
<td>-std=&lt;standard&gt;</td>
<td>Selects the standard dialect</td>
</tr>
</table>
<h2>Predefined Macros</h2>
<table border="0">
<tr>
<td>Macro</td>
<td>What it represents</td>
</tr>
<tr>
<td>__STD_GMQCC__</td>
<td>Specifies the current selected standard is gmqcc.</td>
</tr>
<tr>
<td>__STD_FTEQCC__</td>
<td>Specifies the current selected standard is fteqcc.</td>
</tr>
<tr>
<td>__STD_QCC__</td>
<td>Specifies the current selected standard is qcc.</td>
</tr>
</table>
<h2>Unsupported compatability options</h2>
<p>
GMQCC strives hard for compatability with standard dialects, but not all
features of those standards might be implemented. The unsupported features
are presented below:
<table border="0">
<tr>
<td>Feature</td>
<td>Standard</td>
</tr>
<tr>
<td>Inline Assembly</td>
<td>FTEQCC</td>
</tr>
<tr>
<td>Macro expansion in strings</td>
<td>FTEQCC</td>
</tr>
</table>
</p>
<h1>Less common compiler options</h1>
<h2>Code generation options</h2>
<table border="0">
<tr>
<td>Option</td>
<td>What it does</td>
</tr>
<tr>
<td>-foverlap-locals</td>
<td>Reduces codesize by overlapping locals where possible</td>
</tr>
<tr>
<td>-fdarkplaces-string-table-bug</td>
<td>Works around a bug in older Darkplaces engine builds where the stringtable size is computed wrong</td>
</tr>
<tr>
<td>-fadjust-vector-fields</td>
<td>corrects assignment of vector field pointers (STORE_V instead of STORE_FLD)</td>
</tr>
<tr>
<td>-fftepp</td>
<td>Enables FTEQ preprocessor</td>
</tr>
<tr>
<td>-frelaxted-switch</td>
<td>Relaxes switch statement semantics</td>
</tr>
<tr>
<td>-fshort-logic</td>
<td>Enables short circut evaluation/logic</td>
</tr>
<tr>
<td>-fperl-logic</td>
<td>Enabled perl evalutaion/logic</td>
</tr>
</table>
<h2>Warning options</h2>
<table border="0">
<tr>
<td>Option</td>
<td>What it does</td>
</tr>
<tr>
<td>-Wunused-uninitialized</td>
<td>Enables warnings about unused or uninitialized variables</td>
</tr>
<tr>
<td>-Wunknwon-control-sequence</td>
<td>Enables warnings about unknown control sequence</td>
</tr>
<tr>
<td>-Wextension</td>
<td>Enables warnings about the use of (an) extension(s)</td>
</tr>
<tr>
<td>-Wfield-redeclared</td>
<td>Enables warnings about redeclared fields</td>
</tr>
<tr>
<td>-Wmissing-return-values</td>
<td>Enables warnings about missing return values</td>
</tr>
<tr>
<td>-Wtoo-few-paramaters</td>
<td>Enables warnings about missing paramaters for function calls</td>
</tr>
<tr>
<td>-Wlocal-shadows</td>
<td>Enables warnings about locals shadowing paramaters or other locals</td>
</tr>
<tr>
<td>-Wlocal-constants</td>
<td>Enables warnings about constants specified as locals</td>
</tr>
<tr>
<td>-Wvoid-variables</td>
<td>Enables warnings about variables declared as type void</td>
</tr>
<tr>
<td>-Wimplicit-function-pointer</td>
<td>Enables warnings about implicitly declared function pointers</td>
</tr>
<tr>
<td>-Wvariadic-function</td>
<td>Enables warnings for use of varadics for non-builtin functions</td>
</tr>
<tr>
<td>-Wframe-macros</td>
<td>Enables warnings about duplicated frame macros</td>
</tr>
<tr>
<td>-Weffectless-statement</td>
<td>Enables warnings about effectiveless statements</td>
</tr>
<tr>
<td>-Wend-sys-field</td>
<td>Enables warnings of end_sys_fields being declared a field</td>
</tr>
<tr>
<td>-Wassign-function-types</td>
<td>Enables warnings for incompatible function pointer signatures used in assignment</td>
</tr>
<tr>
<td>-Wpreprocessor</td>
<td>Enables warnings about redefined macros</td>
</tr>
<tr>
<td>-Wmultifile-if</td>
<td>Enables warnings about multifile if statements</td>
</tr>
</table>
<p>
Individual warnings may be disabled with &nbsp;-Wno&lt;warning&gt;
<pre>$ gmqcc -Wno-frame-macros # disables frame duplication warning</pre>
</p>
<h2>Miscellaneous options</h2>
<table border="0">
<tr>
<td>Option</td>
<td>What it does</td>
</tr>
<tr>
<td>-force-crc=&lt;num&gt;</td>
<td>Forces a specific checsum into the header</td>
</tr>
<tr>
<td>-debug</td>
<td>Turns on compiler debug messages</td>
</tr>
<tr>
<td>-memchk</td>
<td>Turns on compiler memory leak checker</td>
</tr>
</table>
<h3>Support or Contact</h3>
<p>Having trouble with GMQCC? Join our IRC channel at #kf-engine on irc.freenode.net or contact <a href="mailto:cube2killfild@gmail.com">Us</a>
</section>
<footer>
<script type="text/javascript" src="http://www.ohloh.net/p/602517/widgets/project_partner_badge.js"></script>
</footer>
</div>
<!--[if !IE]><script>fixScale(document);</script><![endif]-->
</body>
</html>

1
dump Normal file
View file

@ -0,0 +1 @@

View file

@ -24,7 +24,7 @@
<li class="download"><a href="https://github.com/graphitemaster/gmqcc/zipball/master">Download ZIP</a></li>
<li class="download"><a href="https://github.com/graphitemaster/gmqcc/tarball/master">Download TAR</a></li>
<li class="buttons"><a href="https://github.com/graphitemaster/gmqcc/issues">Issues</a></li>
<li class="buttons"><a href="test.html">Try it</a></li>
<li class="buttons"><a href="doc.html">Documentation</a></li>
<li class="buttons"><a href="https://github.com/graphitemaster/gmqcc">View On GitHub</a></li>
</ul>
</header>
@ -54,10 +54,10 @@
<h3>Obtain The Development Repository</h3
<p>If you're interested on used the latest, you may obtain the development
repository as such</p>
<pre><code>$ git clone git://github.com/graphitemaster/gmqcc.git
$ cd gmqcc
$ make
</code></pre>
<pre><code>$ git clone git://github.com/graphitemaster/gmqcc.git
$ cd gmqcc
$ make
</code></pre>
<h3>Support or Contact</h3>

View file

@ -1,220 +0,0 @@
/*
* Some example programs as strings: Javascript is so lame I wanted to
* just reference these as files, aparently that's not possible, w/e
*/
var examples = new Array();
var eargs = new Array();
/* example code */
examples[0] = 'void(string) print = #1;\nvoid(string what) main = {\n\tprint(what);\n\tprint("\\n");\n};\n';
eargs[0] = '-string "Hello World"';
examples[1] = '\
void(string, ...) print = #1;\n\
string(float) ftos = #2;\n\
\n\
float(float x, float y, float z) sum = {\n\
\treturn x + y + z;\n\
};\n\
\n\
void(float a, float b, float c) main = {\n\
\tlocal float f;\n\
\tf = sum(sum(a, sum(a, b, c), c),\n\
\tsum(sum(sum(a, b, c), b, sum(a, b, c)), b, sum(a, b, sum(a, b, c))),\n\
\tsum(sum(a, b, c), b, c));\n\
\tprint(ftos(f), \"\\n\");\n\
};\n';
eargs[1] = '-float 100 -float 200 -float 300';
examples[2] = '\
void(string, ...) print = #1;\n\
string(float) ftos = #2;\n\
\n\
void(float a, float b) main = {\n\
\tif (a == b) print("eq\\n");\n\
\tif (a != b) print("ne\\n");\n\
\tif (a > b) print("gt\\n");\n\
\tif (a < b) print("lt\\n");\n\
\tif (a >= b) print("ge\\n");\n\
\tif (a <= b) print("le\\n");\n\
};\n';
eargs[2] = '-float 1000 -float 2000';
examples[3] = '\
void(string, string) print = #1;\n\
entity() spawn = #3;\n\
\n\
.string a;\n\
.string b;\n\
\n\
void(entity e, .string s) callout = {\n\
\tprint(e.s, "\\n");\n\
};\n\
\n\
void() main = {\n\
\tlocal entity e;\n\
\te = spawn();\n\
\te.a = "foo";\n\
\te.b = "bar";\n\
\tcallout(e, b);\n\
};\n';
eargs[3] = '';
examples[4] = '\
.float globf;\n\
.vector globv;\n\
.string globs;\n\
.void() globfunc;\n';
examples[5] = '\
void(string, ...) print = #1;\n\
string(float) ftos = #2;\n\
entity() spawn = #3;\n\
string(vector) vtos = #5;\n\
void(string, ...) error = #6;\n\
\n\
entity self;\n\
\n\
.vector origin;\n\
.vector view;\n\
\n\
entity() make = {\n\
\tlocal entity e;\n\
\te = spawn();\n\
\te.view = \'0 0 25\';\n\
\treturn e;\n\
};\n\
\n\
float(entity targ) visible = {\n\
\tlocal vector spot1, spot2;\n\
\tspot1 = self.origin + self.view;\n\
\tspot2 = targ.origin + targ.view;\n\
\n\
\tprint("spot1 = ", vtos(spot1), "\\n");\n\
\tprint("spot2 = ", vtos(spot2), "\\n");\n\
\treturn 0;\n\
};\n;\
\n\
void(vector a, vector b) main = {\n\
\tlocal entity targ;\n\
\n\
\tself = make();\n\
\ttarg = make();\n\
\tif (self == targ)\n\
\t\terror("ERROR, self == targ\\n");\n\
\n\
\tself.origin = a;\n\
\ttarg.origin = b;\n\
\n\
\tprint("vis: ", ftos(visible(targ)), "\\n");\n\
};\n';
eargs[5] = "-vector '100 200 0' -vector '2000 1 10'";
examples[6] = '\
void(string, string) print = #1;\n\
\n\
string() getter = {\n\
\treturn "correct";\n\
};\n\
\n\
void(string() f) printer = {\n\
\tprint(f(), "\\n");\n\
};\n\
\n\
void() main = {\n\
\tprinter(getter);\n\
};\n';
eargs[6] = '';
examples[7] = '\
.float globf;\n\
.vector globv;\n\
.string globs;\n\
.void() globfunc;\n';
examples[8] = '\
void(string, ...) print = #1;\n\
\n\
void(float c) main = {\n\
\tif (c == 1)\n\
\t\tprint("One\\n");\n\
\telse if (c == 2)\n\
\t\tprint("Two\\n");\n\
\telse if (c == 3)\n\
\t\tprint("Three\\n");\n\
\telse\n\
\t\tprint("Else\\n");\n\
};\n';
eargs[8] = '-float 1000.45f';
examples[9] = '\
void(string, ...) print = #1;\n\
string(float) ftos = #2;\n\
\n\
void(float n) main = {\n\
\tlocal float i;\n\
\n\
\tfor (i = 0; i < n; i += 1) {\n\
\t\tprint("for ", ftos(i), "\\n");\n\
\t}\n\
\n\
\ti = 0;\n\
\twhile (i < n) {\n\
\t\tprint("while ", ftos(i), "\\n");\n\
\t\ti += 1;\n\
\t}\n\
\n\
\ti = 0;\n\
\tdo {\n\
\t\tprint("do ", ftos(i), "\\n");\n\
\t\ti += 1;\n\
\t} while (i < n);\n\
};\n';
eargs[9] = '-float 10';
examples[10] ='\
void(string, ...) print = #1;\n\
string(float) ftos = #2;\n\
string(vector) vtos = #5;\n\
\n\
void(float a, float b) main = {\n\
\tprint("input: ", ftos(a), " and ", ftos(b), "\\n");\n\
\tprint("+ ", ftos(a+b), "\\n");\n\
\tprint("* ", ftos(a*b), "\\n");\n\
\tprint("/ ", ftos(a/b), "\\n");\n\
\tprint("& ", ftos(a&b), "\\n");\n\
\tprint("| ", ftos(a|b), "\\n");\n\
\tprint("&& ", ftos(a&&b), "\\n");\n\
\tprint("|| ", ftos(a||b), "\\n");\n\
};\n';
eargs[10] = '-float 10 -float 20';
examples[11] = '\
void(string, string) print = %:1;\n\
\n\
void() main = ??<\n\
\tprint("??=??\'??(??)??!??<??>??-??/??/%>", "??/n");\n\
\tprint("#^[]|{}~\\%>", "\\n");\n\
%>;\n';
eargs[11] = '-string "Hello " -string "World!"';
examples[12] = '\
void(string, ...) print = #1;\n\
\n\
void(string what) main = {\n\
\tprint(what, "\\n");\n\
};\n';
eargs[12] = '-string "Pizza!"';
/* ad-hoc eh? */
function update() {
var sel = document.getElementById("eg");
var doc = document.getElementById("input");
doc.value = examples[sel[sel.selectedIndex].value - 1];
document.getElementById("args").value = eargs[sel[sel.selectedIndex].value - 1];
}
function compile() {
var args;
//document.getElementById("args").value.split(' ').concat();
args = document.getElementById("args").value;
args += ' dat/' + document.getElementById("eg").selectedIndex.toString() + '.dat';
document.getElementById("output").value = "Executing " + args + '\n';
run (args.match(/(".*?"|[^" \s]+)(?=\s* |\s*$)/g));
}
/* set initial */
document.getElementById("eg").selectedIndex = 0;
update();

Binary file not shown.

File diff suppressed because it is too large Load diff

View file

@ -225,7 +225,7 @@ th {
td {
padding: 10px;
background: #ccc;
background: #FDFDFB;
}

View file

@ -1,90 +0,0 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="chrome=1">
<title>GMQCC by graphitemaster</title>
<link rel="stylesheet" href="stylesheets/styles.css">
<link rel="stylesheet" href="stylesheets/pygment_trac.css">
<script src="javascripts/scale.fix.js"></script>
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
</head>
<body>
<a href="https://github.com/graphitemaster/gmqcc"><div class="fork"></div></a>
<div class="wrapper">
<header>
<h1 class="header">GMQCC</h1>
<p class="header">An Improved Quake C Compiler</p>
<ul>
<li class="download"><a href="https://github.com/graphitemaster/gmqcc/zipball/master">Download ZIP</a></li>
<li class="download"><a href="https://github.com/graphitemaster/gmqcc/tarball/master">Download TAR</a></li>
<li class="buttons"><a href="https://github.com/graphitemaster/gmqcc/issues">Issues</a></li>
<li class="Buttons"><a href="test.html">Try it</a></li>
<li class="buttons"><a href="https://github.com/graphitemaster/gmqcc">View On GitHub</a></li>
</ul>
</header>
<section>
<h3>Try it from your browser</h3>
Load Program:
<select id="eg" onchange="update()">
<option selected value="1">Builtins</option>
<option value="2">Calls</option>
<option value="3">Equality</option>
<option value="4">Field Parameters</option>
<option value="5">Field Definitions</option>
<option value="6">Fields</option>
<option value="7">Functions As Paramaters</option>
<option value="8">Global Definitions</option>
<option value="9">If</option>
<option value="10">Loops</option>
<option value="11">Math</option>
<option value="12">Digraphs and Trigraphs</option>
<option value="13">Variadic Arguments</option>
</select>
<textarea id="input" rows="25" cols="100%" disabled="disabled"></textarea>
<textarea id="args" rows="1" cols="100%"></textarea>
<br>
<button onclick="compile()" width="10%">Execute</button>
<h4>Execution Output:</h4>
<textarea id="output" rows="25", cols="100%"></textarea>
</section>
<footer>
<!--<script type="text/javascript" src="http://www.ohloh.net/p/602517/widgets/project_partner_badge.js"></script>-->
</footer>
</div>
<script>
var Module = {
preRun: [],
noInitialRun: true,
postRun: [],
print: (function() {
var element = document.getElementById('output');
element.value = ''; // clear browser cache
return function(text) {
// These replacements are necessary if you render to raw HTML
//text = text.replace(/&/g, "&amp;");
//text = text.replace(/</g, "&lt;");
//text = text.replace(/>/g, "&gt;");
//text = text.replace('\n', '<br>', 'g');
element.value += text + "\n";
element.scrollTop = 99999; // focus on bottom
};
})(),
printErr: function(text) {
if (0) { // XXX disabled for safety typeof dump == 'function') {
dump(text + '\n'); // fast, straight to the real console
} else {
console.log(text);
}
}
};
</script>
<script src="javascripts/compiler.js"></script>
<script src="javascripts/vm.js"></script>
<!--[if !IE]><script>fixScale(document);</script><![endif]-->
</body>
</html>

BIN
vm.data

Binary file not shown.