public IProject MakeProject(IProject Project, ProjectPath Path, ICompilerLog Log) { var newPath = Path.Path.Parent.Combine(Project.Name).ChangeExtension("ecsproj"); var dsp = DSProject.FromProject(Project, newPath.AbsolutePath.Path); dsp.WriteTo(newPath.Path); return dsp; }
public IProject MakeProject(IProject Project, ProjectPath Path, ICompilerLog Log) { Log.LogWarning(new LogEntry( "ignored '-make-project'", "the '-make-project' option was ignored because cin does not support any C project formats yet.")); return(Project); }
public AzureFunctionsCompiler(ICompilerLog compilerLog) { _compilerLog = compilerLog; _jsonCompiler = new JsonCompiler(); _openApiCompiler = new OpenApiCompiler(); _assemblyCompiler = new AzureFunctionsAssemblyCompiler(compilerLog, new TemplateProvider(CompileTargetEnum.AzureFunctions)); }
/// <summary> /// Creates a GC description from the given binder and log. /// </summary> /// <param name="Binder">The binder to find types with.</param> /// <param name="Log">The log to use when an error is to be reported.</param> public ExternalGCDescription(IBinder Binder, ICompilerLog Log) { var methodFinder = new ExternalGCMethodFinder(Binder, Log); this.allocMethod = methodFinder.AllocateMethod; this.registerFinalizerMethod = methodFinder.RegisterFinalizerMethod; }
/// <summary> /// Creates a GC method finder from the given binder and log. /// </summary> /// <param name="Binder">The binder to find types with.</param> /// <param name="Log">The log to use when an error is to be reported.</param> public ExternalGCMethodFinder(IBinder Binder, ICompilerLog Log) { this.Binder = Binder; this.Log = Log; this.GCType = new Lazy <IType>(GetGCType); this.AllocateMethod = new Lazy <IMethod>(GetAllocateMethod); this.RegisterFinalizerMethod = new Lazy <IMethod>(GetRegisterFinalizerMethod); }
public IProject Parse(ProjectPath Path, ICompilerLog Log) { if (Path.HasExtension("ecs") || Path.HasExtension("cs") || Path.HasExtension("les")) { return new SingleFileProject(Path, Log.Options.GetTargetPlatform()); } else { return DSProject.ReadProject(Path.Path.Path); } }
public Compiler(Assembly configurationSourceAssembly, string outputBinaryFolder, ICompilerLog compilerLog) { _configurationSourceAssembly = configurationSourceAssembly; _outputBinaryFolder = outputBinaryFolder; _compilerLog = compilerLog; _serviceCollection = new ServiceCollection(); CommandingDependencyResolverAdapter adapter = new CommandingDependencyResolverAdapter( (fromType, toInstance) => _serviceCollection.AddSingleton(fromType, toInstance), (fromType, toType) => _serviceCollection.AddTransient(fromType, toType), (resolveType) => null // we never resolve during compilation ); _commandRegistry = adapter.AddCommanding(); _triggerReferenceProvider = new TriggerReferenceProvider(); }
public PassPreferences GetPassPreferences(ICompilerLog Log) { return(new PassPreferences(new PassCondition[] { new PassCondition( PassExtensions.EliminateDeadCodePassName, optInfo => optInfo.OptimizeMinimal || optInfo.OptimizeDebug), new PassCondition( InfiniteRecursionPass.InfiniteRecursionPassName, optInfo => InfiniteRecursionPass.IsUseful(optInfo.Log)) }, new PassInfo <Tuple <IStatement, IMethod, ICompilerLog>, IStatement>[] { new PassInfo <Tuple <IStatement, IMethod, ICompilerLog>, IStatement>( VerifyingDeadCodePass.Instance, PassExtensions.EliminateDeadCodePassName), new PassInfo <Tuple <IStatement, IMethod, ICompilerLog>, IStatement>( InfiniteRecursionPass.Instance, InfiniteRecursionPass.InfiniteRecursionPassName) })); }
public IProject Parse(ProjectPath Path, ICompilerLog Log) { return(new SingleFileProject(Path, Log.Options.GetTargetPlatform())); }
public AspNetCoreAssemblyCompiler(ICompilerLog compilerLog, ITemplateProvider templateProvider = null) : base(compilerLog, templateProvider) { }
/// <inheritdoc/> protected override Tuple <IAssembly, IEnumerable <IAssembly> > RewriteAssemblies( Tuple <IAssembly, IEnumerable <IAssembly> > MainAndOtherAssemblies, IBinder Binder, ICompilerLog Log) { // In addition to emitting LLVM IR from managed code, flame-llvm must also // set up an environment in which managed code can run. Part of this // environment is the 'main' function: managed code expects an entry point // to look like this: `void|int Main(|string[])`, whereas a C 'main' function // must have the following signature: `int main(int, byte**)`. // // To bridge this divide, we'll generate a 'main' function and use that to // call the entry point. var originalAsm = MainAndOtherAssemblies.Item1; var originalEntryPoint = originalAsm.GetEntryPoint(); if (originalEntryPoint == null) { // We can't rewrite the entry point of an assembly that doesn't // have an entry point. return(MainAndOtherAssemblies); } // Generate the following class: // // public static class __entry_point // { // [#builtin_abi("C")] // [#builtin_llvm_linkage(external)] // public static int main(int argc, byte** argv) // { // try // { // var parsedArgs = Environment.Initialize(argc, argv); // return actual_entry_point(...); // // --or-- // actual_entry_point(...); // return 0; // } // catch (Exception ex) // { // Environment.HandleFatalException(ex); // return 1; // } // } // } var mainAsm = new DescribedAssembly( originalAsm.Name, originalAsm.AssemblyVersion, Binder.Environment); var epType = new DescribedType(new SimpleName("__entry_point"), mainAsm); epType.AddAttribute(PrimitiveAttributes.Instance.StaticTypeAttribute); var mainThunk = new DescribedBodyMethod( new SimpleName("main"), epType, PrimitiveTypes.Int32, true); mainThunk.AddAttribute(new LLVMLinkageAttribute(LLVMLinkage.LLVMExternalLinkage)); mainThunk.AddAttribute(LLVMAttributes.CreateAbiAttribute("C")); mainThunk.AddParameter(new DescribedParameter("argc", PrimitiveTypes.Int32)); mainThunk.AddParameter( new DescribedParameter( "argv", PrimitiveTypes.UInt8 .MakePointerType(PointerKind.TransientPointer) .MakePointerType(PointerKind.TransientPointer))); if (originalEntryPoint.HasSameSignature(mainThunk)) { // We don't have to rewrite the entry point if the existing entry point // already has the expected form. return(MainAndOtherAssemblies); } var epCall = CreateEntryPointCall(originalEntryPoint, mainThunk, Binder); mainThunk.Body = epCall.Type.GetIsInteger() ? (IStatement) new ReturnStatement( new StaticCastExpression(epCall, PrimitiveTypes.Int32).Simplify()) : new BlockStatement(new IStatement[] { new ExpressionStatement(epCall), new ReturnStatement(new IntegerExpression(0)) }); var handleExceptionMethod = BindEnvironmentHandleFatalExceptionMethod(Binder); if (handleExceptionMethod != null) { var exceptionParam = handleExceptionMethod.Parameters.Single <IParameter>(); var catchClause = new CatchClause( new DescribedVariableMember( exceptionParam.Name, exceptionParam.ParameterType)); catchClause.Body = new BlockStatement(new IStatement[] { new ExpressionStatement( new InvocationExpression( handleExceptionMethod, null, new IExpression[] { catchClause.ExceptionVariable.CreateGetExpression() })), new ReturnStatement(new IntegerExpression(1)) }); mainThunk.Body = new TryStatement( mainThunk.Body, new CatchClause[] { catchClause }); } epType.AddMethod(mainThunk); mainAsm.AddType(epType); mainAsm.EntryPoint = mainThunk; return(new Tuple <IAssembly, IEnumerable <IAssembly> >( mainAsm, new IAssembly[] { originalAsm }.Concat <IAssembly>(MainAndOtherAssemblies.Item2))); }
public LazySourceDocument(string Identifier, ICompilerLog Log) { this.Identifier = Identifier; this.Log = Log; }
public string GetRuntimeIdentifier(string Identifier, ICompilerLog Log) { return(LLVMIdentifier); }
public AspNetCoreCompiler(ICompilerLog compilerLog) { _compilerLog = compilerLog; _assemblyCompiler = new AspNetCoreAssemblyCompiler(compilerLog, new TemplateProvider(CompileTargetEnum.AspNetCore)); _openApiCompiler = new OpenApiCompiler(); }
public PassPreferences GetPassPreferences(ICompilerLog Log) { return new PassPreferences(new PassCondition[] { new PassCondition("check-nodes", _ => true), new PassCondition(AutoInitializationPass.AutoInitializationPassName, _ => true), new PassCondition(ValueTypeDelegateVisitor.ValueTypeDelegatePassName, optInfo => ValueTypeDelegateVisitor.ValueTypeDelegateWarning.UseWarning(optInfo.Log.Options)), new PassCondition(Flame.Front.Target.PassExtensions.EliminateDeadCodePassName, optInfo => optInfo.OptimizeMinimal || optInfo.OptimizeDebug), new PassCondition(InfiniteRecursionPass.InfiniteRecursionPassName, optInfo => InfiniteRecursionPass.IsUseful(optInfo.Log)), }, new PassInfo<Tuple<IStatement, IMethod, ICompilerLog>, IStatement>[] { new PassInfo<Tuple<IStatement, IMethod, ICompilerLog>, IStatement>( LogPass.Instance, "check-nodes"), new PassInfo<Tuple<IStatement, IMethod, ICompilerLog>, IStatement>( AnalysisPasses.ValueTypeDelegatePass, ValueTypeDelegateVisitor.ValueTypeDelegatePassName), new PassInfo<Tuple<IStatement, IMethod, ICompilerLog>, IStatement>( VerifyingDeadCodePass.Instance, Flame.Front.Target.PassExtensions.EliminateDeadCodePassName), new PassInfo<Tuple<IStatement, IMethod, ICompilerLog>, IStatement>( AutoInitializationPass.Instance, AutoInitializationPass.AutoInitializationPassName), new PassInfo<Tuple<IStatement, IMethod, ICompilerLog>, IStatement>( InfiniteRecursionPass.Instance, InfiniteRecursionPass.InfiniteRecursionPassName) }); }
protected AssemblyCompilerBase(ICompilerLog compilerLog, ITemplateProvider templateProvider) { CompilerLog = compilerLog; TemplateProvider = templateProvider; }
public AzureFunctionsAssemblyCompiler(ICompilerLog compilerLog, ITemplateProvider templateProvider) : base(compilerLog, templateProvider) { }
public AssemblyCompiler(ICompilerLog compilerLog, ITemplateProvider templateProvider = null) { _compilerLog = compilerLog; _templateProvider = templateProvider ?? new TemplateProvider(); }
private static IEnvironment CreateLLVMEnvironment(ICompilerLog Log) { return(new StandaloneEnvironment("llvm")); }