Exemple #1
0
        internal ExportsValue InitNodejsVariables(string documentation)
        {
            var filename = _analyzer.GetConstant(_filePath);
            var dirName  = _analyzer.GetConstant(String.IsNullOrWhiteSpace(_filePath) ? "" : Path.GetDirectoryName(_filePath), alwaysCache: true);

            if (documentation == null)
            {
                _module = new ModuleValue(_filePath, _moduleRecord);
            }
            else
            {
                _module = new BuiltinModuleValue(_filePath, documentation, _moduleRecord);
            }
            var exports = new ExportsValue(_filePath, this);

            _module.Add("exports", exports.Proxy);

            EnvironmentRecord.GetOrAddVariable("__dirname").AddTypes(this, dirName.Proxy);
            EnvironmentRecord.GetOrAddVariable("__filename").AddTypes(this, filename.Proxy);
            EnvironmentRecord.GetOrAddVariable("exports").AddTypes(this, exports.Proxy);
            EnvironmentRecord.GetOrAddVariable("module").AddTypes(this, _module.Proxy);
            return(exports);
        }
Exemple #2
0
 public ModuleBuildFunctionValue(ModuleValue module) : base()
 {
     this.Module  = module;
     Keyword      = $"module({module.Name},{module.Author},{Module.Version})";
     EvaluateFunc = (x, y) => { Execute(this, x, y); return(this.Module); };
 }