Esempio n. 1
0
 private static void Compile(string fileName) {
   HostEnvironment hostEnvironment = new HostEnvironment();
   IName name = hostEnvironment.NameTable.GetNameFor(fileName);
   IDictionary<string, string> options = new Dictionary<string, string>();
   List<IAssemblyReference> assemblyReferences = new List<IAssemblyReference>();
   List<IModuleReference> moduleReferences = new List<IModuleReference>();
   assemblyReferences.Add(hostEnvironment.LoadAssembly(hostEnvironment.CoreAssemblySymbolicIdentity));
   assemblyReferences.Add((IAssembly)hostEnvironment.LoadUnitFrom(typeof(Microsoft.SmallBasic.Library.ConsoleWindow).Assembly.Location));
   StreamReader instream = File.OpenText(fileName);
   List<SmallBasicDocument> programSources = new List<SmallBasicDocument>(1);
   SmallBasicAssembly assem = new SmallBasicAssembly(name, Path.GetFullPath(fileName), hostEnvironment, options, assemblyReferences, moduleReferences, programSources);
   SmallBasicCompilationHelper helper = new SmallBasicCompilationHelper(assem.Compilation);
   programSources.Add(new SmallBasicDocument(helper, name, Path.GetFullPath(fileName), instream));
   var exeFile = File.Create(Path.ChangeExtension(fileName, "exe"));
   var sourceLocationProvider = assem.Compilation.SourceLocationProvider;
   //var localScopeProvider = assem.Compilation.LocalScopeProvider;
   using (var pdbWriter = new PdbWriter(Path.ChangeExtension(fileName, "pdb"), sourceLocationProvider)) {
     PeWriter.WritePeToStream(assem, hostEnvironment, exeFile, sourceLocationProvider, null, pdbWriter);
   }
 }
Esempio n. 2
0
 internal SmallBasicCompilationPart(SmallBasicCompilationHelper helper, SmallBasicCompilationPart template)
   : base(helper, template)
 {
 }
Esempio n. 3
0
 private static void RunTest(HostEnvironment hostEnvironment, string suiteName, string test, StringBuilder actualOutput, List<string> compilerParameters, List<string> testCaseParameters) {
   IName name = hostEnvironment.NameTable.GetNameFor(suiteName);
   IDictionary<string, string> options = new Dictionary<string, string>();
   List<IAssemblyReference> assemblyReferences = new List<IAssemblyReference>();
   List<IModuleReference> moduleReferences = new List<IModuleReference>();
   assemblyReferences.Add(hostEnvironment.LoadAssembly(hostEnvironment.CoreAssemblySymbolicIdentity));
   assemblyReferences.Add((IAssembly)hostEnvironment.LoadUnitFrom(typeof(Microsoft.SmallBasic.Library.ConsoleWindow).Assembly.Location));
   SmallBasicAssembly/*?*/ assem = null;
   SmallBasicCompilationHelper helper;
   List<SmallBasicDocument> programSources = new List<SmallBasicDocument>(1);
   assem = new SmallBasicAssembly(name, "", hostEnvironment, options, assemblyReferences, moduleReferences, programSources);
   helper = new SmallBasicCompilationHelper(assem.Compilation);
   programSources.Add(/*hostEnvironment.previousDocument = */new SmallBasicDocument(helper, name, "", test));
   var memStream = new MemoryStream();
   PeWriter.WritePeToStream(assem, hostEnvironment, memStream);
   var runtimeAssembly = System.Reflection.Assembly.Load(memStream.ToArray());
   runtimeAssembly.EntryPoint.Invoke(null, null);
 }
Esempio n. 4
0
 internal SmallBasicCompilationPart(SmallBasicCompilationHelper helper, ISourceLocation sourceLocation)
   : base(helper, sourceLocation) 
   // ^ requires sourceLocation.SourceDocument is SpecSharpDocument;
 {
 }
Esempio n. 5
0
 private SmallBasicDocument(SmallBasicCompilationHelper helper, string text, SourceDocument previousVersion, int position, int oldLength, int newLength)
   : base(text, previousVersion, position, oldLength, newLength) {
   this.helper = helper;
 }
Esempio n. 6
0
 public SmallBasicDocument(SmallBasicCompilationHelper helper, IName name, string location, string text)
   : base(name, location, text) {
   this.helper = helper;
 }
Esempio n. 7
0
 public SmallBasicDocument(SmallBasicCompilationHelper helper, IName name, string location, System.IO.StreamReader streamReader)
   : base(name, location, streamReader) {
   this.helper = helper;
 }
Esempio n. 8
0
 private SmallBasicCompilationHelper(Compilation targetCompilation, SmallBasicCompilationHelper template) 
   : base(targetCompilation, template) {
 }