Пример #1
0
 public CompilationFailedException(TransformResults tr, string msg)
     : base(msg)
 {
     Results = tr;
 }
Пример #2
0
        public List <ITypeDeclaration> TransformToDeclaration(ITypeDeclaration itd, AttributeRegistry <object, ICompilerAttribute> inputAttributes, bool trackTransform, bool showProgress,
                                                              out List <TransformError> warnings, bool catchExceptions = false, bool treatWarningsAsErrors = false)
        {
            List <ITypeDeclaration> res = new List <ITypeDeclaration>();

            res.Add(itd);
            AttributeRegistry <object, ICompilerAttribute> attributes = inputAttributes;

            warnings = new List <TransformError>();
            foreach (CodeTransformer ct in transformers)
            {
                string    name  = ct.Transform.Name;
                Stopwatch watch = null;
                if (showProgress)
                {
                    Console.Write(name + " ");
                    watch = Stopwatch.StartNew();
                }
                ct.Transform.Context.InputAttributes = attributes;
                ct.TrackTransform = trackTransform;
                if (catchExceptions)
                {
                    try
                    {
                        res = ct.TransformToDeclaration(res[0]);
                    }
                    catch (Exception ex)
                    {
                        ((BasicTransformContext)ct.Transform.Context).Error("Uncaught exception in transform", ex);
                    }
                }
                else
                {
                    res = ct.TransformToDeclaration(res[0]);
                }
                if (showProgress)
                {
                    watch.Stop();
                    Console.WriteLine("({0}ms)", watch.ElapsedMilliseconds);
                }
#if TestLanguageWriter
                try
                {
                    ILanguageWriter lw = new CSharpWriter() as ILanguageWriter;
                    lw.GenerateSource(res[0]);
                }
                catch
                {
                    Console.WriteLine("Language writer error for " + res[0].Name);
                }
#endif
                TransformResults tr = ct.Transform.Context.Results;
                tr.ThrowIfErrors(name + " failed", treatWarningsAsErrors);
                if (tr.WarningCount > 0)
                {
                    foreach (TransformError te in tr.errorsAndWarnings)
                    {
                        if (te.IsWarning)
                        {
                            warnings.Add(te);
                        }
                    }
                }
                attributes = ct.Transform.Context.OutputAttributes;
            }
            return(res);
        }