Skip to content

Commit

Permalink
Merge pull request #19 from deleterium/develop
Browse files Browse the repository at this point in the history
Preparing release 2.0
  • Loading branch information
deleterium authored Jul 3, 2022
2 parents 81a6c8f + b3b7466 commit f9c30d6
Show file tree
Hide file tree
Showing 84 changed files with 10,028 additions and 1,794 deletions.
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
## [v2.0](https://github.com/deleterium/SmartC/tree/v2.0) (2022-07-03)

[Commits](https://github.com/deleterium/SmartC/commits/v2.0)

- **Support all new features from Signum Rainbow Hard Fork**
- New 42 built-in functions: **easy use of Signum API**
- Documentation updated with refactored examples, devs must read it again
- **Fixed point numbers** to handle balance, much easier in calculations
- Checks for **type castings** are stronger and issuing warnings for implicit conversions
- Optimization level 3 uses VM to trace variables values (beta version, not default)
- Showing many errors after failed compilations (if possible)
- Many changes in `#pragma` and `#program` to allow **integration with SC-Simulator**

## [v1.0](https://github.com/deleterium/SmartC/tree/v1.0) (2022-01-16)

[Commits](https://github.com/deleterium/SmartC/commits/v1.0)
Expand Down
17 changes: 10 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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:
Expand All @@ -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.

Expand Down
106 changes: 106 additions & 0 deletions debug.html
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>
Loading

0 comments on commit f9c30d6

Please sign in to comment.