-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #19 from deleterium/develop
Preparing release 2.0
- Loading branch information
Showing
84 changed files
with
10,028 additions
and
1,794 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,7 +15,16 @@ This library can be obtained through npm: | |
npm install smartc-signum-compiler | ||
``` | ||
|
||
The stable version is released under tag `@latest` and the development under `@next`. | ||
|
||
# Usage | ||
|
||
## Web User Interface | ||
A web user interface project is available at https://github.com/deleterium/smartc-web-ui If you want just to code with SmartC use https://deleterium.info/SmartC/ | ||
|
||
## Documentation / FAQ / Lessons | ||
Docs files can be found in this repo, at `doc` folder. | ||
|
||
## Node | ||
```ts | ||
import { SmartC } from 'smartc-signum-compiler'; | ||
|
@@ -38,7 +47,7 @@ try { | |
## Browser | ||
Import the minified javascript file. SmartC will be imported as global. | ||
```html | ||
<script src="https://cdn.jsdelivr.net/npm/smartc-[email protected]/dist/smartc.min.js"></script> | ||
<script src="https://cdn.jsdelivr.net/npm/smartc-signum-compiler@latest/dist/smartc.min.js"></script> | ||
``` | ||
|
||
Then in your javascript file, just use it: | ||
|
@@ -58,12 +67,6 @@ try { | |
} | ||
``` | ||
|
||
## Web User Interface | ||
To be done | ||
|
||
## Documentation / FAQ / Lessons | ||
Docs files can be found in this repo, at `doc` folder. | ||
|
||
## Changelog | ||
Find [here](https://deleterium.github.io/SmartC/CHANGELOG) major upgrades between releases. | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<script src="dist/smartc.dev.js"></script> | ||
<script> | ||
|
||
function compileCode () { | ||
document.getElementById('assembly').innerHTML = ''; | ||
document.getElementById('debug-info').innerHTML = ''; | ||
const sourceCode = document.getElementById('sourcecode').value; | ||
const t0 = new Date(); | ||
try { | ||
const compiler = new SmartC({ language: 'C', sourceCode }); | ||
compiler.compile(); | ||
const asmCode = compiler.getAssemblyCode(); | ||
const bcode = compiler.getMachineCode(); | ||
const t1 = new Date(); | ||
let compileMessage = `<span class='msg_success'>Compile sucessfull!!!</span> Done at ${t1.getHours()}:${t1.getMinutes()}:${t1.getSeconds()} in ${t1 - t0} ms.`; | ||
if (bcode.Warnings.length != 0) { | ||
compileMessage += `<br>${bcode.Warnings}`; | ||
} | ||
document.getElementById('status').innerHTML = compileMessage; | ||
document.getElementById('assembly').innerText = asmCode; | ||
document.getElementById('debug-info').innerHTML = JSON.stringify(bcode, null, ' '); | ||
} catch (e) { | ||
document.getElementById('status').innerHTML = `<span class='msg_failure'>Compile failed</span><br>${e.message}` | ||
document.getElementById('debug-info').innerHTML = e.stack | ||
} | ||
} | ||
|
||
function startUpTest () { | ||
const startUpTest = new SmartC({ | ||
language: 'C', | ||
sourceCode: '#pragma version dev\n#pragma maxAuxVars 1\nlong a, b, c; a=b/~c;' | ||
}) | ||
try { | ||
startUpTest.compile() | ||
if (startUpTest.getMachineCode().MachineCodeHashId === '7488355358104845254') { | ||
document.getElementById('status').innerHTML = '<span class="msg_success">Start up test done!</span>' | ||
} else { | ||
document.getElementById('status').innerHTML = '<span class="msg_failure">Start up test failed...</span>' | ||
} | ||
} catch (e) { | ||
document.getElementById('status').innerHTML = '<span class="msg_failure">Start up test crashed...</span>' | ||
} | ||
} | ||
|
||
window.onload = () => { | ||
document.getElementById("compile").addEventListener('click', compileCode); | ||
startUpTest(); | ||
} | ||
</script> | ||
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | ||
<meta name="viewport" content="width=800, initial-scale=1.0"> | ||
<title>Simple debugger page</title> | ||
<style type="text/css" media="all"> | ||
body { | ||
font-family: 'Courier New', Courier, monospace; | ||
font-size: 14pt; | ||
box-sizing: border-box; | ||
} | ||
textarea { | ||
padding: 1ch; | ||
height: 75vh; | ||
font-size: inherit; | ||
width: calc(50vw - 2ch); | ||
} | ||
td { | ||
vertical-align: top; | ||
} | ||
pre { | ||
padding: 1ch; | ||
border: 1px black solid; | ||
word-wrap: anywhere; | ||
white-space: pre-wrap; | ||
margin: 0; | ||
} | ||
.msg_failure { | ||
font-weight: bold; | ||
color: red; | ||
} | ||
.msg_success { | ||
font-weight: bold; | ||
color: green; | ||
} | ||
</style> | ||
|
||
</head> | ||
<body> | ||
<header>Simple debugger page</header> | ||
<p>Use this page to debug or inspect SmartC process, using a browser.</p> | ||
<main> | ||
<div style="width: 100%;"> | ||
<div style="width: 50vw; float: left;"> | ||
<textarea id="sourcecode" spellcheck="false"></textarea><br><button id="compile" accesskey="c">Compile</button> | ||
</div> | ||
<div style="margin-left: 53vw;"> | ||
<pre id="status"></pre> | ||
<pre id="assembly"></pre> | ||
<pre id="debug-info"></pre> | ||
</div> | ||
</div> | ||
</main> | ||
</body> | ||
</html> |
Oops, something went wrong.