js-slang
Version:
Javascript-based implementations of Source, written in Typescript
49 lines • 1.99 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.StepperExpressionStatement = void 0;
const generator_1 = require("../../generator");
const __1 = require("../..");
class StepperExpressionStatement {
constructor(expression, leadingComments, trailingComments, loc, range) {
this.type = 'ExpressionStatement';
this.expression = expression;
this.leadingComments = leadingComments;
this.trailingComments = trailingComments;
this.loc = loc;
this.range = range;
}
static create(node) {
return new StepperExpressionStatement((0, generator_1.convert)(node.expression), node.leadingComments, node.trailingComments, node.loc, node.range);
}
isContractible() {
return this.expression.isContractible();
}
isOneStepPossible() {
return this.expression.isOneStepPossible();
}
contract() {
return new StepperExpressionStatement(this.expression.oneStep(), this.leadingComments, this.trailingComments, this.loc, this.range);
}
contractEmpty() {
// Handle cases such as 1; 2; -> 2;
__1.redex.preRedex = [this];
__1.redex.postRedex = [];
}
oneStep() {
return new StepperExpressionStatement(this.expression.oneStep(), this.leadingComments, this.trailingComments, this.loc, this.range);
}
substitute(id, value) {
return new StepperExpressionStatement(this.expression.substitute(id, value), this.leadingComments, this.trailingComments, this.loc, this.range);
}
freeNames() {
return this.expression.freeNames();
}
allNames() {
return this.expression.allNames();
}
rename(before, after) {
return new StepperExpressionStatement(this.expression.rename(before, after), this.leadingComments, this.trailingComments, this.loc, this.range);
}
}
exports.StepperExpressionStatement = StepperExpressionStatement;
//# sourceMappingURL=ExpressionStatement.js.map