Skip to content

Commit

Permalink
NEW: added new feature
Browse files Browse the repository at this point in the history
  • Loading branch information
HolliShake committed Dec 6, 2024
1 parent 8f66066 commit 2604b80
Show file tree
Hide file tree
Showing 8 changed files with 1,027 additions and 67 deletions.
102 changes: 99 additions & 3 deletions development.envx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ fn fact(n) {
}

fn add(a, b) {
return a - b;
return a + b;
}

println(add(50, 2));
Expand All @@ -35,7 +35,7 @@ fn bark() {
println(">>", sound, REACT_APP_API_URL);
}

const h = bark();
var h = bark();
println(h);

println(">>:", fact(5));
Expand All @@ -46,4 +46,100 @@ println(2 % 2, 4 + 1);

2 << 2;

println(2 == 2);
println(2 == 2);


fn initH() {
h = 100 + 20;
h += 100;
println(">>>>>>>>>", h);
}

println("before >>", h);
initH();
println("after >>", h);


fn jsCallTest(a, b) {
const x = "Hola!";
println(">>", x);
return a << b;
}

const REACT_API_URL = "https://optimumhr-api.ustp.edu.ph/api";

fn getApiName(a,b,c) {
return REACT_API_URL;
}

const PRIVATE_HASH = "qsdad123q3";

fn getHash() {
}


h1 = 2;
println(h1 -= 1);

var y = 10;
y *= 2;
println("y :=", y);

y /= 2;
println("y :=", y);

y %= 2;
println("y :=", y);

y += 10;
println("y :=", y);

y -= 5;
println("y :=", y);

y <<= 1;
println("y :=", y);

y >>= 1;
println("y :=", y);

y &= 1;
println("y :=", y);

y |= 1;
println("y :=", y);

y ^= 1;
println("y :=", y);

println(!2);

var i = 0;

while (i < 5) {
println("i :=", i);
i += 1;
}

println(0xff);

do {
println("i :=", i);
i -= 1;
} while (i > 0)

var qq = 0;

do {
if (qq == 2) {
qq += 1;
continue;
}
if (qq >= 5) {
{
break;
}
}
println(qq);
qq += 1;
} while(qq != 200)
5 changes: 3 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const { runBytecode, envx, envxPluginVite } = require('./src/app.js');
const { runBytecode, envx, envxCall, envxPluginVite } = require('./src/app.js');
runBytecode([ 18, 43 ]);
module.exports = {
envxPluginVite,
envx
envx,
envxCall
};
15 changes: 13 additions & 2 deletions src/app.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const { Parser } = require('./parser.js');
const { ByteComiler } = require('./bytecompiler.js');
const { runBytecode, envx } = require('./runtime.js');
const { runBytecode, envx, envxCall } = require('./runtime.js');

const EXT = 'envx';
const PLUGIN_VITE = 'envxPluginVite';
Expand Down Expand Up @@ -56,6 +56,15 @@ const runBuild = (pluginName) => {
}
}

const runTest = () => {
const envFilePrefix = getBuildEnvironment();
const envFile = `${envFilePrefix}.${EXT}`;
const file = readEnvContent(envFile, 'utf-8');
// Run the compiler
const comp = new ByteComiler(new Parser(envFile, file));
runBytecode(comp.compile());
}

/**
* @brief Vite plugin for envx
* @param {Object} options
Expand All @@ -74,6 +83,8 @@ function envxPluginVite(options = {}) {

module.exports = {
runBytecode,
runTest,
envxPluginVite,
envx
envx,
envxCall
}
Loading

0 comments on commit 2604b80

Please sign in to comment.