public void LibraryCpp1() { if (!File.Exists(this.dllpath)) { Assert.Pass($"Missing DLL file '{this.dllpath}' - Test will not be run."); } string[] file1 = { "namespace library {", " class Console {", " public external GetColumn(): int;", " public external GetRow(): int;", " }", "}" }; SourceProject project = new SourceProject() { Name = "LibraryCpp1", Output = "libraryCpp1.hlib", ProjectType = SourceProjectType.Library, References = new[] { new SourceProjectNativeReference("Hsharp", this.dllpath, "1.0.0", "C/C++", "Windows") }, Sources = new[] { new SourceProjectFile("file1", ToSingleText(file1), true), } }; var result = this.compiler.CompileProject(project); Assert.That(result.Success); }
public void Reset() { this.m_thisLog = null; this.m_currentProject = null; this.m_timer = null; this.m_externalBindables = new List <ExternContainer>(); this.m_lastResult = new CompileResult(true, "No compilation"); }
private void EditDataClick(object sender, RoutedEventArgs e) { if (SourceProject.IsNull()) { return; } preEditData = SourceProject.Clone() as Project; EditMode = true; RebindSourceProject(); }
private CompileResult ImportReferences(Domain globalDomain, SourceProject project) { // Loop over references for (int i = 0; i < project.References.Length; i++) { if (project.References[i] is SourceProjectNativeReference nativeReference) { switch (nativeReference.TargetLanguage) { case "C#": case "CS": var cse = ImportCsDll(nativeReference, globalDomain); if (!cse) { return(cse); } break; case "C": case "C++": case "C/C++": var cppe = ImportCCPPDll(nativeReference); if (!cppe) { return(cppe); } break; default: return(new CompileResult(false, $"Attempt to reference library using language '{nativeReference.TargetLanguage}'. That is not supported.")); } } else if (project.References[i] is SourceProjectReference reference) { Log.WriteLine("DEV-WARNING: References to other H# libraries currently not implemented!"); } else { Log.WriteLine($"WARNING: Unsupported reference type '{project.References[i].GetType()}'"); } } return(new CompileResult(true)); }
public MuTestOptions Build() { var muTestOptions = new MuTestOptions { SourceProjectParameter = GetOption(SourceProject.Value(), CliOptions.SourceProject), SourceProjectLibraryParameter = GetOption(SourceLib.Value(), CliOptions.SourceLib), SourceClassParameter = GetOption(SourceClass.Value(), CliOptions.SourceClass), TestProjectParameter = GetOption(TestProject.Value(), CliOptions.TestProject), TestProjectLibraryParameter = GetOption(TestLib.Value(), CliOptions.TestLib), TestClassParameter = GetOption(TestClass.Value(), CliOptions.TestClass), ExecuteAllTests = GetOption(ExecuteAllTests.Value(), CliOptions.ExecuteAllTests), SkipTestProjectBuild = GetOption(SkipTestProjectBuild.Value(), CliOptions.SkipTestProjectBuild), IncludePartialClasses = GetOption(IncludePartialClasses.Value(), CliOptions.IncludePartialClasses), AnalyzeExternalCoveredClasses = GetOption(AnalyzeExternalCoveredClasses.Value(), CliOptions.AnalyzeExternalCoveredClasses), IncludeNestedClasses = GetOption(IncludeNestedClasses.Value(), CliOptions.IncludeNestedClasses), UseClassFilter = GetOption(UseClassFilter.Value(), CliOptions.UseClassFilter), X64TargetPlatform = GetOption(X64.Value(), CliOptions.X64TargetPlatform), BuildInReleaseModeParameter = GetOption(ReleaseMode.Value(), CliOptions.BuildInReleaseMode), EnableDiagnostics = GetOption(Diagnostics.Value(), CliOptions.EnableDiagnostics), OptimizeTestProject = GetOption(OptimizeTestProject.Value(), CliOptions.OptimizeTestProject), ConcurrentTestRunners = GetOption(Parallel.Value(), CliOptions.Parallel), SurvivedThreshold = GetOption(SurvivedThreshold.Value(), CliOptions.SurvivedThreshold), KilledThreshold = GetOption(KilledThreshold.Value(), CliOptions.KilledThreshold), OutputPathParameter = GetOption(OutputPath.Value(), CliOptions.OutputPath), NoCoverage = GetOption(NoCoverage.Value(), CliOptions.NoCoverage), RegEx = GetOption(RegEx.Value(), CliOptions.Regex), Specific = GetOption(Specific.Value(), CliOptions.Specific), ClassName = GetOption(ClassName.Value(), CliOptions.ClassName), ProcessWholeProject = GetOption(ProcessWholeProject.Value(), CliOptions.ProcessWholeProject), TestExecutionThreshold = GetOption(FindTestTime.Value(), CliOptions.TestExecutionThreshold), MutantsPerLine = GetOption(MutantsPerLine.Value(), CliOptions.MutantsPerLine) }; muTestOptions .MultipleSourceClasses .AddRange(GetOption(MultipleSourceClasses.Value(), CliOptions.MultipleSourceClasses).Distinct()); muTestOptions .MultipleTestClasses .AddRange(GetOption(MultipleTestClasses.Value(), CliOptions.MultipleTestClasses).Distinct()); muTestOptions.ValidateOptions(); return(muTestOptions); }
public IEnumerator<KeyValuePair<IVersionedItem, IVersionedItem>> GetEnumerator() { foreach (KeyValuePair<Guid, Guid> keyValuePair in copyDictionaryGuid) { ExolutioObject objectKey = SourceProject.TranslateComponent<ExolutioObject>(keyValuePair.Key); if (objectKey is ProjectVersion) { continue; } ExolutioObject objectValue = TargetProject.TranslateComponent<ExolutioObject>(keyValuePair.Value); if (objectKey.GetType() != objectValue.GetType()) { throw new ExolutioModelException(); } IVersionedItem keyItem = (IVersionedItem) objectKey; IVersionedItem valueItem = (IVersionedItem) objectValue; yield return new KeyValuePair<IVersionedItem, IVersionedItem>(keyItem, valueItem); } }
private IEnumerable <SourceProject> ConvertProject(IEnumerable <ProjectInSolution> projects) { var result = new List <SourceProject>(); foreach (var project in projects) { if (project.ProjectType == SolutionProjectType.KnownToBeMSBuildFormat) { var sourceProject = new SourceProject() { AbsolutePath = project.AbsolutePath, ProjectName = project.ProjectName, ProjectGuid = project.ProjectGuid }; result.Add(sourceProject); } } return(result); }
public void Library1() { string[] file1 = { "namespace library {", " class LibKlass {", " five(): int {", " return 5;", " }", " }", "}" }; string[] file2 = { "namespace library {", " class otherClass {", " lib(): LibKlass {", " return new LibKlass();", " }", " }", "}" }; SourceProject project = new SourceProject() { Name = "Library1", Output = "library1.hlib", ProjectType = SourceProjectType.Library, References = Array.Empty <SourceProjectReference>(), Sources = new[] { new SourceProjectFile("file1", ToSingleText(file1), true), new SourceProjectFile("file2", ToSingleText(file2), true) } }; var result = this.compiler.CompileProject(project); Assert.That(result.Success); }
public CompileResult CompileProject(SourceProject project) { // Set active project this.m_currentProject = project; // Meta data generation this.m_thisLog = new(); this.m_externalBindables = new(); this.m_timer = Stopwatch.StartNew(); // Parse all files AST[] asts = new AST[this.m_currentProject.Sources.Length]; for (int i = 0; i < this.m_currentProject.Sources.Length; i++) { var parseResult = ParseFile(this.m_currentProject.Sources[i], out AST ast); if (!parseResult) { Log.WriteLine($"Failed to parse {this.m_currentProject.Sources[i].Name} :\n\t{"Some currently un-generated error!"}"); Log.WriteLine(); return(parseResult); } asts[i] = ast; } // Create the global domain and import external references Domain globalDomain = Domain.GetGlobalDomain(); var result = ImportReferences(globalDomain, this.m_currentProject); if (!result) { return(this.FatalError(result)); } // Detect types result = StaticTypeDetector.Detect(asts, globalDomain); if (!result) { return(this.FatalError(result)); } // Define types result = StaticTypeDefiner.DefineAllTypes(asts, globalDomain); if (!result) { return(this.FatalError(result)); } // Solve potential inheritance problems etc. result = InheritanceSolver.Solve(asts, globalDomain); if (!result) { return(this.FatalError(result)); } // TODO: Run static checks // Verify variables VarsVerifier vVerifier = new VarsVerifier(); for (int i = 0; i < asts.Length; i++) { result = vVerifier.Vars(asts[i]); if (!result) { return(this.FatalError(result)); } } // Verify control paths ControlpathVerifier pathVerifier = new ControlpathVerifier(); for (int i = 0; i < asts.Length; i++) { result = pathVerifier.Verify(asts[i]); if (!result) { return(this.FatalError(result)); } } // Run static typecheck Typechecker typechecker = new Typechecker(); for (int i = 0; i < asts.Length; i++) { result = typechecker.Typecheck(asts[i], globalDomain); if (!result) { return(this.FatalError(result)); } } // Compile Application ASTCompiler astCompiler = new ASTCompiler(asts); result = astCompiler.Compile(); if (!result) { return(this.FatalError(result)); } // Apply linking Linker linker = new Linker(astCompiler, globalDomain, this.m_externalBindables); result = linker.Link(); if (!result) { return(this.FatalError(result)); } // Stop timer this.m_timer.Stop(); // Get compile output ProgramOutput compilerOutput = this.GetCompileOutput(astCompiler, linker, globalDomain); // If successful compile, save, otherwise log error if (compilerOutput is not null) { compilerOutput.Save(project.Output); compilerOutput.SaveAsText(project.Output.Replace(".bin", ".txt").Replace(".hlib", ".txt")); Log.WriteLine($"Compiled \"{project.Name}\" successfully in {this.m_timer.ElapsedMilliseconds / 1000.0}s."); Log.WriteLine(); this.m_thisLog.SaveAndClose(project.Output.Replace(".bin", ".log").Replace(".hlib", ".log")); return(new CompileResult(true)); } else { Log.WriteLine($"Compile Error \"{project.Name}\" : {result}"); Log.WriteLine(); this.m_thisLog.SaveAndClose(project.Output.Replace(".bin", ".log").Replace(".hlib", ".log")); return(new CompileResult(false)); } }
public String Convert(String source, SourceDetails details, SourceProject project) { if(details.Type == SourceType.INTERFACE) { Pattern pattern = Pattern.compile("^(\\s+)public\\s+(.*\\)\\s*;.*$)"); List<String> lines = stripLines(source); StringWriter writer = new StringWriter(); for(String line : lines) { Matcher matcher = pattern.matcher(line); if(matcher.matches()) { String indent = matcher.group(1); String remainder = matcher.group(2); writer.append(indent); writer.append(remainder); writer.append("\n"); } else { writer.append(line); writer.append("\n"); } } return writer.ToString(); } return source; }
public String Convert(String source, SourceDetails details, SourceProject project) { List<String> lines = stripLines(source); Map<String, String> substitutions = calculateSubstututions(details, project); StringWriter writer = new StringWriter(); for(String line : lines) { for(String substitute : substitutions.keySet()) { line = line.replaceAll(substitute, substitutions.get(substitute)); } writer.append(line); writer.append("\n"); } return writer.ToString(); }
public abstract String Convert(String source, SourceDetails details, SourceProject project);
public Map<String, String> calculateSubstututions(SourceDetails details, SourceProject project) { Map<String, String> substitutes = new HashMap<String, String>(); for(String field : details.getFields().keySet()) { String type = details.getFields().get(field); SourceDetails fieldDetails = project.GetDetails(type); if(fieldDetails != null) { PopulateFrom(fieldDetails, field, substitutes); } } PopulateFrom(details, null, substitutes); return substitutes; }
private void CancelEditionClicked(object sender, RoutedEventArgs e) { SourceProject.SetValues(preEditData); EditMode = false; PropertyChanged.SafeRise(this, HardType.GetName(() => SourceProject)); }