Stabel

Check-in [f465c04492]
Login
Overview
Comment:A default function to be executed with 'stabel run' can now be specified in the stabel.json file.
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: f465c04492c99aec935bca3027aac86609574a98ec1ecc9ac2a67fd5e72fc7c6
User & Date: robin.hansen on 2021-09-09 11:08:27
Other Links: manifest | tags
Context
2021-09-11
09:42
elm-review fixes. check-in: 7c41ddbc55 user: robin.hansen tags: trunk
2021-09-09
11:08
A default function to be executed with 'stabel run' can now be specified in the stabel.json file. check-in: f465c04492 user: robin.hansen tags: trunk
10:58
Fixed bug where reliance on string module was not inferred when encountering a string literal. check-in: 6fd8ec29cf user: robin.hansen tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Modified bin/cli.js from [61c21a98f0] to [8b85ca8ded].

25
26
27
28
29
30
31

32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49


50
51
52





53
54





55
56
57
58
59
60
61
62
...
155
156
157
158
159
160
161

162
163
164
165
166
167
168

    fs.mkdirSync(path.join(cwd, "src"));

    const stabelJson = {
        name: subCmdFlags[0],
        version: "0.1.0",
        "language-version": "0.2.0",

        "exposed-modules": [
            "main"
        ],
        dependencies: {
            "stabel/standard_library": "0.2.1"
        },
        "package-paths": []
    };

    fs.writeFileSync(path.join(cwd, "stabel.json"), JSON.stringify(stabelJson, null, 4));

    fs.writeFileSync(path.join(cwd, "src", "main.stbl"), `
def: execute
: 0
`.trim());
}

function runProject() {


    if (subCmdFlags.length !== 1) {
        console.error("'run' requires exactly one argument: the function to run.");
        return;





    }






    compileProject(subCmdFlags[0]);
}

function compileProject(entryPoint) {
    const rootJsonMetaPath = path.join(cwd, "stabel.json");
    if (!fs.existsSync(rootJsonMetaPath)) {
        console.error("No 'stabel.json' file found in this directory.");
        return;
................................................................................
function printHelp() {
    console.log(`
Stabel v0.2.1-alpha

Possible options are:
* init <package_name>: initialize a new project in the current directory.
* compile: compile the project.

* run <function_name>: compile the project and execute the given function.
* help: print this help message.
    `);
}

async function executeWat(wat, entryPointName, isStringReturned) {
    const wabt = await wabtInit();







>













|




>
>
|


>
>
>
>
>
|

>
>
>
>
>
|







 







>







25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
...
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182

    fs.mkdirSync(path.join(cwd, "src"));

    const stabelJson = {
        name: subCmdFlags[0],
        version: "0.1.0",
        "language-version": "0.2.0",
        "execute": `/${subCmdFlags[0]}/main/execute`,
        "exposed-modules": [
            "main"
        ],
        dependencies: {
            "stabel/standard_library": "0.2.1"
        },
        "package-paths": []
    };

    fs.writeFileSync(path.join(cwd, "stabel.json"), JSON.stringify(stabelJson, null, 4));

    fs.writeFileSync(path.join(cwd, "src", "main.stbl"), `
def: execute
: "hello, world!"
`.trim());
}

function runProject() {
    let entryPoint = null;

    if (subCmdFlags.length > 1) {
        console.error("'run' requires exactly one argument: the function to run.");
        return;
    } else if (subCmdFlags.length !== 1) {
        const stabelConfig = JSON.parse(fs.readFileSync(path.join(cwd, "stabel.json")));
        if (typeof stabelConfig.execute === "undefined") {
            console.error("what function should be run? Nothing found in 'execute' property in stabel.json, nor was any function provided on the command line.");
            return;
        }

        entryPoint = stabelConfig.execute;
    } else {
        entryPoint = subCmdFlags[0];
    }

    compileProject(entryPoint);
}

function compileProject(entryPoint) {
    const rootJsonMetaPath = path.join(cwd, "stabel.json");
    if (!fs.existsSync(rootJsonMetaPath)) {
        console.error("No 'stabel.json' file found in this directory.");
        return;
................................................................................
function printHelp() {
    console.log(`
Stabel v0.2.1-alpha

Possible options are:
* init <package_name>: initialize a new project in the current directory.
* compile: compile the project.
* run: compile the project and execute the default function.
* run <function_name>: compile the project and execute the given function.
* help: print this help message.
    `);
}

async function executeWat(wat, entryPointName, isStringReturned) {
    const wabt = await wabtInit();