Skip to content
This repository has been archived by the owner on Oct 12, 2024. It is now read-only.

Commit

Permalink
Add a thing
Browse files Browse the repository at this point in the history
  • Loading branch information
dylanbeattie committed Jul 16, 2024
1 parent c53c591 commit 39640c3
Show file tree
Hide file tree
Showing 65 changed files with 258 additions and 2 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,5 +59,5 @@ I've done this using `mklink`, provided with the Windows `cmd` interpreter:
D:\Rockstar2\codewithrockstar.com\> mklink /D examples ..\Starship\Rockstar.Test\programs\examples
```

This is incredibly fragile - moving or renaming folders breaks the link and you just end up with two disconnected copies of everything.
This is incredibly fragile - moving or renaming folders breaks the link and you just end up with two disconnected copies of everything. Bizarrely, it works just fine on the GitHub Actions checkout.

5 changes: 4 additions & 1 deletion codewithrockstar.com/02-values-and-variables.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@ Rockstar uses a similar type system to that defined by the [ECMAScript type sys
- **Mysterious** - the value of any variable that hasn’t been assigned a value, denoted by the keyword `mysterious`.

## Literals
String literals in Rockstar use double quotes:

String literals in Rockstar use double quotes. To include a


## Variables

Rockstar supports three different kinds of variables.
Expand Down
30 changes: 30 additions & 0 deletions codewithrockstar.com/wasm-demo/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<!DOCTYPE html>
<html>
<head>
<title>Rockstar in WASM</title>
<style>
textarea, pre {
width: 100%;
font-family: Consolas, monospace;
border: 1px solid #000;
min-height: 100px;
font-size: 16px;
padding: 8px;
box-sizing: border-box;
}
</style>
</head>
<body>
<h1>A Rockstar Interpreter in WASM</h1>
<h2>Source:</h2>
<textarea id="source">shout "hello world"
</textarea>
<input id="runButton" type="button" value="Run" />
<h2>Output:</h2>
<pre id="output"></pre>
</pre>
<script src="wasm.js" type="module">

</script>
</body>
</html>
24 changes: 24 additions & 0 deletions codewithrockstar.com/wasm-demo/wasm.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { dotnet } from '/wasm/wwwroot/_framework/dotnet.js'

const { setModuleImports, getAssemblyExports, getConfig } = await dotnet
.withDiagnosticTracing(false)
.withApplicationArgumentsFromQuery()
.create();

const config = getConfig();
const exports = await getAssemblyExports(config.mainAssemblyName);
await dotnet.run();
var runButton = document.getElementById("runButton");
var sourceTextArea = document.getElementById("source");
var outputPre = document.getElementById("output");

runButton.addEventListener("click", function() {
var source = sourceTextArea.value;
console.log(source);
try {
var result = exports.Rockstar.Wasm.RockstarRunner.Run(source);
outputPre.innerText = result;
} catch(e) {
outputPre.innerText = e;
}
});
42 changes: 42 additions & 0 deletions codewithrockstar.com/wasm/Rockstar.Wasm.runtimeconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
"runtimeOptions": {
"tfm": "net8.0",
"includedFrameworks": [
{
"name": "Microsoft.NETCore.App",
"version": "8.0.7"
}
],
"wasmHostProperties": {
"perHostConfig": [
{
"name": "browser",
"host": "browser"
}
]
},
"configProperties": {
"Microsoft.Extensions.DependencyInjection.VerifyOpenGenericServiceTrimmability": true,
"System.AggressiveAttributeTrimming": true,
"System.ComponentModel.TypeConverter.EnableUnsafeBinaryFormatterInDesigntimeLicenseContextSerialization": false,
"System.Diagnostics.Debugger.IsSupported": false,
"System.Diagnostics.Tracing.EventSource.IsSupported": false,
"System.Globalization.Invariant": true,
"System.Globalization.PredefinedCulturesOnly": true,
"System.Net.Http.EnableActivityPropagation": false,
"System.Reflection.Metadata.MetadataUpdater.IsSupported": false,
"System.Reflection.NullabilityInfoContext.IsSupported": false,
"System.Resources.ResourceManager.AllowCustomResourceTypes": false,
"System.Resources.UseSystemResourceKeys": true,
"System.Runtime.InteropServices.BuiltInComInterop.IsSupported": false,
"System.Runtime.InteropServices.EnableConsumingManagedCodeFromNativeHosting": false,
"System.Runtime.InteropServices.EnableCppCLIHostActivation": false,
"System.Runtime.InteropServices.Marshalling.EnableGeneratedComInterfaceComImportInterop": false,
"System.Runtime.Serialization.EnableUnsafeBinaryFormatterSerialization": false,
"System.StartupHookProvider.IsSupported": false,
"System.Text.Encoding.EnableUnsafeUTF7Encoding": false,
"System.Text.Json.JsonSerializer.IsReflectionEnabledByDefault": false,
"System.Threading.Thread.EnableAutoreleasePool": false
}
}
}
10 changes: 10 additions & 0 deletions codewithrockstar.com/wasm/runtimeconfig.template.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"wasmHostProperties": {
"perHostConfig": [
{
"name": "browser",
"host": "browser"
}
]
}
}
44 changes: 44 additions & 0 deletions codewithrockstar.com/wasm/web.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<staticContent>
<remove fileExtension=".blat" />
<remove fileExtension=".dat" />
<remove fileExtension=".dll" />
<remove fileExtension=".webcil" />
<remove fileExtension=".json" />
<remove fileExtension=".wasm" />
<remove fileExtension=".woff" />
<remove fileExtension=".woff2" />
<mimeMap fileExtension=".blat" mimeType="application/octet-stream" />
<mimeMap fileExtension=".dll" mimeType="application/octet-stream" />
<mimeMap fileExtension=".webcil" mimeType="application/octet-stream" />
<mimeMap fileExtension=".dat" mimeType="application/octet-stream" />
<mimeMap fileExtension=".json" mimeType="application/json" />
<mimeMap fileExtension=".wasm" mimeType="application/wasm" />
<mimeMap fileExtension=".woff" mimeType="application/font-woff" />
<mimeMap fileExtension=".woff2" mimeType="application/font-woff" />
</staticContent>
<httpCompression>
<dynamicTypes>
<add mimeType="application/octet-stream" enabled="true" />
<add mimeType="application/wasm" enabled="true" />
</dynamicTypes>
</httpCompression>
<rewrite>
<rules>
<rule name="Serve subdir">
<match url=".*" />
<action type="Rewrite" url="wwwroot\{R:0}" />
</rule>
<rule name="SPA fallback routing" stopProcessing="true">
<match url=".*" />
<conditions logicalGrouping="MatchAll">
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
</conditions>
<action type="Rewrite" url="wwwroot\" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
34 changes: 34 additions & 0 deletions codewithrockstar.com/wasm/wwwroot/_framework/blazor.boot.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"mainAssemblyName": "Rockstar.Wasm",
"resources": {
"hash": "sha256-SpSq2QbwQmg/j1y5jWzff4XQm6/EFalxfte3cDJuIkM=",
"jsModuleNative": {
"dotnet.native.8.0.7.xhyoor67pm.js": "sha256-1k6bcrS4MgkZNRphPacvYZq5VfAhOqAIEwrGJUzyydA="
},
"jsModuleRuntime": {
"dotnet.runtime.8.0.7.urcsr75yt5.js": "sha256-soZyw6XWXOLKhA26AOyzSpCP5cAsw1wvhdPHSYNTMfQ="
},
"wasmNative": {
"dotnet.native.wasm": "sha256-nPJc70WzLZNN2jkBuF9OUu4AmCh8yOJK7yypx/UFvAo="
},
"assembly": {
"netstandard.wasm": "sha256-uq25ZvhoKtVHJOv9ajFhuamTvw38wLURg2hmblDtnm0=",
"Pegasus.Common.wasm": "sha256-xSlRrX2nMn5SrIR3xGrPOzgDC+qXmmspahL0S6RY4MY=",
"Rockstar.Engine.wasm": "sha256-yyLKXaRoxjW49q2i98AzgYLPqYSn8t+9qsD6BgyYjoY=",
"Rockstar.Wasm.wasm": "sha256-vKqdP1BwvIYMwlRbchBr6sVRd5IvFeDWl/H6EN2YejE=",
"System.Collections.wasm": "sha256-RZKT1wortBCb29GdjtlJA6uYPylFAZKkmIn9/UFU64w=",
"System.Console.wasm": "sha256-yz+imPPmqM1nwL65iUzBOQcfnvZnGkdxvM55Ev5IvSU=",
"System.Diagnostics.TraceSource.wasm": "sha256-qCITXq4k5eMAtY/TJygflctfz+WbYV07bqAqXoLgBkc=",
"System.Linq.Expressions.wasm": "sha256-m+NHI0HBpQfOUXdOAbjX+k14QfOQmn5t+HiHlz1gXek=",
"System.Linq.wasm": "sha256-69JfjMpq/LvToz/SaVAfbnoXB3LHL5vAda12x0N2L0o=",
"System.Private.CoreLib.wasm": "sha256-eBSqHYAMWFJL0GeqqkeBujF9lXNFbveAKHTIi4xfC0Q=",
"System.Runtime.InteropServices.JavaScript.wasm": "sha256-7/0IqBEqaX1BeMKtgJQ1x3hmHk5BaCC9VSdGhqpaOSc=",
"System.Runtime.wasm": "sha256-q87HuWRNfdsIyuU7imlbeOP9FFklpguqVVClpS0ZqtA=",
"System.Text.RegularExpressions.wasm": "sha256-qBclGbmt/JTu9aSXE2bRLQxI8tiJ86zDyAj7ZZdiTMo="
}
},
"cacheBootResources": true,
"debugLevel": 0,
"linkerEnabled": true,
"globalizationMode": "invariant"
}
Binary file not shown.
Binary file not shown.
4 changes: 4 additions & 0 deletions codewithrockstar.com/wasm/wwwroot/_framework/dotnet.js

Large diffs are not rendered by default.

Binary file not shown.
Binary file not shown.

Large diffs are not rendered by default.

Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

Large diffs are not rendered by default.

Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
29 changes: 29 additions & 0 deletions codewithrockstar.com/wasm/wwwroot/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<!DOCTYPE html>
<html>
<head>
<title>Rockstar.Wasm</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
<textarea rows="20" cols="72" id="source">shout "hello world"
shout 1 + 2 + 3
shout "foo" plus "bar"</textarea>
<br />
<button id="run">Run</button>
<pre id="output"></pre>
<script type="module">
import { RunRockstarProgram } from './main.js';
const textarea = document.getElementById('source');
document.getElementById("run").addEventListener('click', () => {
let source = document.getElementById('source').value;
try {
let result = RunRockstarProgram(source);
document.getElementById('output').textContent = result;
} catch (err) {
document.getElementById('output').textContent = err;
}
});
</script>
</body>
</html>
15 changes: 15 additions & 0 deletions codewithrockstar.com/wasm/wwwroot/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { dotnet } from './_framework/dotnet.js'

const { setModuleImports, getAssemblyExports, getConfig } = await dotnet
.withDiagnosticTracing(false)
.withApplicationArgumentsFromQuery()
.create();

const config = getConfig();
const exports = await getAssemblyExports(config.mainAssemblyName);
console.log(exports);
await dotnet.run();

export function RunRockstarProgram(source) {
return exports.Rockstar.Wasm.RockstarRunner.Run(source);
}

0 comments on commit 39640c3

Please sign in to comment.