UNPKG

js-slang

Version:

Javascript-based implementations of Source, written in Typescript

57 lines 1.92 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.StepperIdentifier = void 0; const __1 = require("../.."); const builtins_1 = require("../../builtins"); class StepperIdentifier { constructor(name, leadingComments, trailingComments, loc, range) { this.type = 'Identifier'; this.name = name; this.leadingComments = leadingComments; this.trailingComments = trailingComments; this.loc = loc; this.range = range; } static create(node) { return new StepperIdentifier(node.name, node.leadingComments, node.trailingComments, node.loc, node.range); } isContractible() { // catch undeclared variables if (this.name !== 'undefined' && !(0, builtins_1.isBuiltinFunction)(this.name)) throw new Error(`Name ${this.name} declared later in current scope but not yet assigned`); return false; } isOneStepPossible() { if (this.name !== 'undefined' && !(0, builtins_1.isBuiltinFunction)(this.name)) throw new Error(`Name ${this.name} declared later in current scope but not yet assigned`); return false; } contract() { throw new Error('Method not implemented.'); } oneStep() { throw new Error('Method not implemented.'); } substitute(id, value) { if (id.name === this.name) { __1.redex.postRedex.push(value); return value; } else { return this; } } freeNames() { return [this.name]; } allNames() { return [this.name]; } rename(before, after) { return before === this.name ? new StepperIdentifier(after, this.leadingComments, this.trailingComments, this.loc, this.range) : this; } } exports.StepperIdentifier = StepperIdentifier; //# sourceMappingURL=Identifier.js.map