mirror of
https://github.com/rastvl/akamai-deobfuscator-2.0.git
synced 2025-04-18 00:57:44 +08:00
35 lines
640 B
JavaScript
35 lines
640 B
JavaScript
|
|
class Environment {
|
|
constructor(record = {}, parent = null) {
|
|
this.record = record;
|
|
this.parent = parent;
|
|
}
|
|
|
|
define(name, value = undefined) {
|
|
this.record[name] = value;
|
|
return value;
|
|
}
|
|
|
|
lookup(name) {
|
|
return this.resolve(name).record[name];
|
|
}
|
|
|
|
resolve(name) {
|
|
if (this.record.hasOwnProperty(name)) {
|
|
return this;
|
|
}
|
|
|
|
if (this.parent === null) {
|
|
throw new ReferenceError(`Variable "${name}" is not defined`);
|
|
}
|
|
|
|
return this.parent.resolve(name);
|
|
}
|
|
|
|
assign(name, value) {
|
|
this.resolve(name).record[name] = value;
|
|
return value;
|
|
}
|
|
}
|
|
|
|
module.exports = Environment; |