代码拉取完成,页面将自动刷新
同步操作将从 NULL/JavaScript-compiler 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
(function (factory) {
if (typeof module === "object" && typeof module.exports === "object") {
var v = factory(require, exports);
if (v !== undefined) module.exports = v;
}
else if (typeof define === "function" && define.amd) {
define(["require", "exports"], factory);
}
})(function (require, exports) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
class Expr {
constructor(op, left, right) {
this.op = op;
this.left = left;
this.right = right;
}
print(level = 0) {
const pad = ''.padStart(level * 2);
console.log(pad + this.op);
this.left && this.left.print(level + 1);
this.right && this.right.print(level + 1);
}
//代码生成
gen(il, scope) {
if (this.left && this.left.gen) {
this.left.gen(il, scope);
}
if (this.right && this.right.gen) {
this.right.gen(il, scope);
}
const tempVar = scope.bindTempVar();
il.add(`set ${tempVar} ${this.left.rvalue()} ${this.op} ${this.right.rvalue()}`);
this._rval = tempVar;
}
//获取临时标识符名
rvalue() {
return this._rval;
}
//绑定词法作用域
bindLexicalScope(scope) {
if (this.left && this.left.bindLexicalScope) {
this.left.bindLexicalScope(scope);
}
if (this.right && this.right.bindLexicalScope) {
this.right.bindLexicalScope(scope);
}
}
}
exports.Expr = Expr;
//函数调用表达式
class FunctionCallExpr extends Expr {
constructor(id, args) {
super('call', id, args);
this.id = id;
this.args = args;
}
gen(il, scope) {
this.right.gen(il, scope);
const tempVar = scope.bindTempVar();
il.add(`call ${scope.getLexemeName(this.left.lvalue())}`);
this._rval = tempVar;
}
}
exports.FunctionCallExpr = FunctionCallExpr;
class AssignExpr extends Expr {
constructor(id, expr) {
super('=', id, expr);
this.id = id;
this.expr = expr;
}
gen(il, scope) {
il.add(`declare ${scope.getLexemeName(this.id.lvalue())}`);
this.expr.gen(il, scope);
il.add(`${scope.getLexemeName(this.id.lvalue())}=${this.expr.rvalue()}`);
}
}
exports.AssignExpr = AssignExpr;
class Args {
constructor(args, type = 'call') {
this.args = args;
this.type = type;
}
print(level) {
this.args.forEach(x => {
x.print(level);
});
}
size() {
return this.args.length;
}
bindLexicalScope(scope) {
for (let i = 0; i < this.args.length; i++) {
if (this.type === 'function') {
scope.bind(this.args[i].value);
this.args[i].bindLexicalScope(scope);
}
else {
this.args[i].bindLexicalScope && this.args[i].bindLexicalScope(scope);
}
}
}
gen(il, scope) {
if (this.type == 'call') {
for (let i = 0; i < this.args.length; i++) {
const expr = this.args[i];
if (expr.gen) {
expr.gen(il, scope);
}
il.add(`pass ${expr.rvalue()}`);
}
}
}
}
exports.Args = Args;
});
//# sourceMappingURL=expression.js.map
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。