public HaxeEmitter(PhaseCompiler compiler) { Compiler = compiler; _symbolMetaCache = new ConcurrentDictionary<ISymbol, SymbolMetaData>(SymbolEquivalenceComparer.Instance); _reservedMethodNames = new ConcurrentDictionary<string, IMethodSymbol>(); _semanticModelLookup = new ConcurrentDictionary<SyntaxTree, SemanticModel>(); }
static void Main(string[] args) { CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; CultureInfo.DefaultThreadCurrentCulture = CultureInfo.InvariantCulture; if (args.Length != 3) { Console.WriteLine("Phase.Cli.exe ProjectFile Configuration Platform"); return; } string testSrc = @" using System; class Test { public function Main() { #if POSITIVE int i = 1; #endif #if NEGATIVE int x = 2; #endif #if !POSITIVE int j = 2; #endif } } "; var tree = CSharpSyntaxTree.ParseText(testSrc, CSharpParseOptions.Default.WithPreprocessorSymbols("POSITIVE")); var input = new PhaseCompilerInput { ProjectFile = args[0], Configuration = args[1], Platform = args[2] }; try { var compiler = new PhaseCompiler(input); compiler.CompileAsync().Wait(); } catch (Exception e) { Console.WriteLine(e); if (Debugger.IsAttached) { Debugger.Break(); } } }
public override bool Execute() { _cancellationTokenSource = new CancellationTokenSource(); var directory = Path.GetDirectoryName(ProjectFile); var arguments = new List <string>(); arguments.Add("/define:\"" + DefineConstants + "\""); arguments.Add("/nowarn:\"" + DisabledWarnings + "\""); if (!string.IsNullOrEmpty(MainEntryPoint)) { arguments.Add("/main:\"" + MainEntryPoint + "\""); } arguments.Add("/target:" + TargetType); arguments.Add("/moduleassemblyname:\"" + ModuleAssemblyName + "\""); if (TreatWarningsAsErrors) { arguments.Add("/warnaserror"); } arguments.Add("/warn:\"" + WarningLevel + "\""); arguments.Add("/warnaserror+:\"" + WarningsAsErrors + "\""); arguments.Add("/warnaserror-:\"" + WarningsNotAsErrors + "\""); foreach (var mr in References) { var filePath = Path.Combine(directory, mr.ItemSpec); var aliases = GetAliases(mr); if (aliases.IsDefaultOrEmpty) { arguments.Add("/reference:\"" + filePath + "\""); } else { foreach (var alias in aliases) { arguments.Add("/reference:" + alias + "=\"" + filePath + "\""); } } } try { ImmutableArray.Create(1, 2, 3); var config = new LoggingConfiguration(); config.AddTarget("msbuild", new MSBuildTarget(Log) { Layout = "${longdate} ${level} ${callsite} - ${message} ${exception:format=ToString}" }); config.AddRule(LogLevel.Trace, LogLevel.Fatal, "msbuild"); LogManager.Configuration = config; var args = CSharpCommandLineParser.Default.Parse(arguments, directory, RuntimeEnvironment.GetRuntimeDirectory()); var resolver = new MetadataFileReferenceResolver(directory); var references = args.ResolveMetadataReferences(resolver); var input = new PhaseCompilerInput { ProjectFile = ProjectFile, CompilationOptions = args.CompilationOptions, ParseOptions = args.ParseOptions, SourceFiles = Sources.Select(s => Path.Combine(directory, s.ItemSpec)).ToArray(), ReferencedAssemblies = references, Platform = Platform, Configuration = Configuration }; var compiler = new PhaseCompiler(input); compiler.CompileAsync(_cancellationTokenSource.Token).Wait(); return(true); } catch (Exception e) { Log.LogError(e.Message); if (Debugger.IsAttached) { Debugger.Break(); } return(false); } }