Esempio n. 1
0
        private void InitializeContext()
        {
            Alchemist.Log($"Alchemist starting in directory \"{_currentWorkingDirectory}\"");

            var workingDirectoryFiles = new DirectoryInfo(_currentWorkingDirectory).GetFiles("*.ele");
            var packageFiles          = Packages.SelectMany(GetPackageFiles);

            _sourceContext.AddSourceFiles(workingDirectoryFiles.Concat(packageFiles));
            _sourceContext.Recompile(_compilationContext);
        }
Esempio n. 2
0
        // TODO(Craig): Make this more intelligent
        private FileInfo[] GetPackageFiles(string package)
        {
            var directoryInfo = Directory.Exists(package) ? new DirectoryInfo(package) : null;

            if (directoryInfo == null)
            {
                Alchemist.LogError($"Package directory \"{package}\" doesn't exist.");
                return(Array.Empty <FileInfo>());
            }

            return(directoryInfo.GetFiles("*.ele", SearchOption.AllDirectories));
        }
Esempio n. 3
0
        protected override int ExecuteImplementation()
        {
            var function = _sourceContext.GlobalScope.GetFunction(Function, _compilationContext);

            if (function == null)
            {
                Alchemist.LogError($"Could not find function \"{Function}\".");
                return(1);
            }

            var output   = function.EvaluateAndSerialize(Arguments.ToArray(), _compilationContext);
            var asString = string.Join(", ", output).Replace("∞", "Infinity");

            Alchemist.Log(asString);
            return(0);
        }