2020-08-07 01:58:37 +08:00
|
|
|
/*
|
|
|
|
|
MIT License http://www.opensource.org/licenses/mit-license.php
|
|
|
|
|
Author Ivan Kopeykin @vankop
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
|
|
const RuntimeModule = require("./RuntimeModule");
|
|
|
|
|
const Template = require("./Template");
|
|
|
|
|
|
|
|
|
|
class SimpleRuntimeModule extends RuntimeModule {
|
|
|
|
|
/**
|
|
|
|
|
* @param {string} name name
|
|
|
|
|
* @param {string} runtimeGlobal runtime global
|
2020-08-07 02:03:34 +08:00
|
|
|
* @param {string} expression expression
|
2020-08-07 01:58:37 +08:00
|
|
|
*/
|
2020-08-07 02:03:34 +08:00
|
|
|
constructor(name, runtimeGlobal, expression) {
|
2020-08-07 01:58:37 +08:00
|
|
|
super(name);
|
|
|
|
|
this.runtimeGlobal = runtimeGlobal;
|
2020-08-07 02:03:34 +08:00
|
|
|
this.expression = expression;
|
2020-08-07 01:58:37 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @returns {string} runtime code
|
|
|
|
|
*/
|
|
|
|
|
generate() {
|
2020-08-07 02:03:34 +08:00
|
|
|
return Template.asString([`${this.runtimeGlobal} = ${this.expression};`]);
|
2020-08-07 01:58:37 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
module.exports = SimpleRuntimeModule;
|