tlang-runtime-compiler/TLang.VM/DefaultDependencyPool.cs

50 lines
1.6 KiB
C#

using System.Collections;
using System.Collections.Generic;
using System.IO;
using TLang.Common;
namespace TLang.VM
{
public class DefaultDependencyPool : IDependencyPool
{
List<(TLangDependency Dependency,TVMFile File)> items = new List<(TLangDependency Dependency, TVMFile File)>();
public bool AddDependency(TLangDependency dependency)
{
string fileName = $"{dependency.Name}-{dependency.Version}.tvm";
if(File.Exists(fileName))
{
using(var f = File.OpenRead(fileName))
{
TVMFile file = new TVMFile(f);
items.Add((dependency,file));
return file.LoadDependencies(this);
}
}
return false;
}
private static TLangDependencyResponse DefaultDependencyCheck(TLangDependency dep)
{
string fileName = $"{dep.Name}-{dep.Version}.tvm";
if(File.Exists(fileName))
{
return new TLangDependencyResponse(){Stream = File.OpenRead(fileName)};
}
return new TLangDependencyResponse(){Found = false};
}
public bool DependencyExists(TLangDependency dependency)
{
throw new System.NotImplementedException();
}
public IEnumerator<(TLangDependency Dependency, TVMFile File)> GetEnumerator()
{
throw new System.NotImplementedException();
}
IEnumerator IEnumerable.GetEnumerator()
{
throw new System.NotImplementedException();
}
}
}