public override void Build(BuildItems items) { using (var dllStream = new MemoryStream()) { using (var pdbStream = new MemoryStream()) { #if DEBUG var result = items.Compilation.Emit(dllStream, pdbStream, options: new Microsoft.CodeAnalysis.Emit.EmitOptions(false, Microsoft.CodeAnalysis.Emit.DebugInformationFormat.PortablePdb)); #else var result = items.Compilation.Emit(dllStream, pdbStream); #endif items.EmitResult = result; if (!result.Success) { var all = new StringBuilder(); foreach (var diagnostic in result.Diagnostics) { all.Append(diagnostic); } items.DllFile = null; items.PdbFile = null; throw new CompilationException(all.ToString()); } items.DllFile = dllStream.ToArray(); items.PdbFile = pdbStream.ToArray(); } } Successor?.Build(items); }
public override void Build(BuildItems items) { items.SchemaProvider = new TransitionSchemaProvider(items.SchemaProvider); var queryTree = items.RawQueryTree; var metadataInferer = new BuildMetadataAndInferTypeVisitor(items.SchemaProvider); var metadataInfererTraverser = new BuildMetadataAndInferTypeTraverseVisitor(metadataInferer); queryTree.Accept(metadataInfererTraverser); queryTree = metadataInferer.Root; var rewriter = new RewriteQueryVisitor(); var rewriteTraverser = new RewriteQueryTraverseVisitor(rewriter, new ScopeWalker(metadataInfererTraverser.Scope)); queryTree.Accept(rewriteTraverser); queryTree = rewriter.RootScript; var csharpRewriter = new ToCSharpRewriteTreeVisitor(metadataInferer.Assemblies, metadataInferer.SetOperatorFieldPositions, metadataInferer.InferredColumns); var csharpRewriteTraverser = new ToCSharpRewriteTreeTraverseVisitor(csharpRewriter, new ScopeWalker(metadataInfererTraverser.Scope)); queryTree.Accept(csharpRewriteTraverser); items.TransformedQueryTree = queryTree; items.Compilation = csharpRewriter.Compilation; items.AccessToClassPath = csharpRewriter.AccessToClassPath; Successor?.Build(items); }
public override void Build(BuildItems items) { var lexer = new Lexer(items.RawQuery, true); var parser = new FqlParser(lexer); items.RawQueryTree = parser.ComposeAll(); Successor?.Build(items); }
public object Build(Type targetType, JValue jsonValue) { if (CanProcess(targetType, jsonValue)) { return(DoBuild(targetType, jsonValue)); } else { return(Successor.Build(targetType, jsonValue)); } }
/// <summary> /// override method for build simple triangle on three point /// </summary> /// <param name="pointA"></param> /// <param name="pointB"></param> /// <param name="pointC"></param> /// <returns>New simple triangle</returns> public override Triangle Build(Point pointA, Point pointB, Point pointC) { double[] sizeSiseTriangle = new double[3] { pointA.GetDistance(pointB), pointA.GetDistance(pointC), pointB.GetDistance(pointC) }; Array.Sort(sizeSiseTriangle); if (!(Math.Abs(sizeSiseTriangle[0] + sizeSiseTriangle[1] - sizeSiseTriangle[2]) < eps)) { return(new SimpleTriangle(pointA, pointB, pointC)); } return(Successor?.Build(pointA, pointB, pointC) ?? throw new Exception("Can't build simple triangle")); }
/// <summary> /// override method for build equilateral triangle on three point /// </summary> /// <param name="pointA"></param> /// <param name="pointB"></param> /// <param name="pointC"></param> /// <returns>New equilateral triangle </returns> public override Triangle Build(Point pointA, Point pointB, Point pointC) { double sideAB = pointA.GetDistance(pointB); double sideAC = pointA.GetDistance(pointC); double sideBC = pointB.GetDistance(pointC); if (Math.Abs(sideAB - sideAC) < eps && Math.Abs(sideAB - sideBC) < eps && Math.Abs(sideAC - sideBC) < eps) { return(new EquilateralTriangle(pointA, pointB, pointC)); } return(Successor?.Build(pointA, pointB, pointC) ?? throw new Exception("Can't build equilateral triangle")); }
/// <summary> /// override method for build right triangle on three point /// </summary> /// <param name="pointA"></param> /// <param name="pointB"></param> /// <param name="pointC"></param> /// <returns>New right triangle </returns> public override Triangle Build(Point pointA, Point pointB, Point pointC) { Point vectorAB = new Point(pointB.X - pointA.X, pointB.Y - pointA.Y); Point vectorAC = new Point(pointC.X - pointA.X, pointC.Y - pointA.Y); Point vectorBC = new Point(pointC.X - pointB.X, pointC.Y - pointB.Y); if (Math.Abs(vectorAB.X * vectorAC.X + vectorAB.Y * vectorAC.Y) < eps || Math.Abs(vectorAB.X * vectorBC.X + vectorAB.Y * vectorBC.Y) < eps || Math.Abs(vectorAC.X * vectorBC.X + vectorAC.Y * vectorBC.Y) < eps) { return(new RightTriangle(pointA, pointB, pointC)); } return(Successor?.Build(pointA, pointB, pointC) ?? throw new Exception("Can't build right triangle")); }
/// <inheritdoc /> public override Triangle Build(Point a, Point b, Point c) { // While vectors are not exactly "points", they can be identified by coordinates just like points var vectorAB = new Point(Math.Abs(b.X - a.X), Math.Abs(b.Y - a.Y)); var vectorBC = new Point(Math.Abs(c.X - b.X), Math.Abs(c.Y - b.Y)); var vectorAC = new Point(Math.Abs(c.X - a.X), Math.Abs(c.Y - a.Y)); if (Math.Abs(vectorAB.X * vectorBC.X + vectorAB.Y * vectorBC.Y) < Tolerance || Math.Abs(vectorAB.X * vectorAC.X + vectorAB.Y * vectorAC.Y) < Tolerance || Math.Abs(vectorAC.X * vectorBC.X + vectorAC.Y * vectorBC.Y) < Tolerance) { return(new RightTriangle(a, b, c)); } return(Successor?.Build(a, b, c)); }
public override void Build(BuildItems items) { var queryTree = items.RawQueryTree; var prepareQuery = new PrepareQueryVisitor(items.Engine); var prepareQueryTraverser = new PrepareQueryTraverseVisitor(prepareQuery); queryTree.Accept(prepareQueryTraverser); queryTree = prepareQuery.Root; var csharpRewriter = new RunQueryVisitor(items.Engine); var csharpRewriteTraverser = new RunTraverseVisitor(csharpRewriter); queryTree.Accept(csharpRewriteTraverser); items.Result = csharpRewriter.Result; Successor?.Build(items); }
public override void Build(BuildItems items) { using (var dllStream = new MemoryStream()) { using (var pdbStream = new MemoryStream()) { var result = items.Compilation.Emit(dllStream, pdbStream); items.EmitResult = result; if (!result.Success) { var all = new StringBuilder(); foreach (var diagnostic in result.Diagnostics) { all.Append(diagnostic); } items.CompiledQuery = null; items.DllFile = null; items.PdbFile = null; throw new CompilationException(all.ToString()); } var dllBytesArray = dllStream.ToArray(); var pdbBytesArray = pdbStream.ToArray(); var assembly = Assembly.Load(dllBytesArray, pdbBytesArray); var type = assembly.GetType(items.AccessToClassPath); var runnable = (IRunnable)Activator.CreateInstance(type); runnable.Provider = items.SchemaProvider; items.CompiledQuery = runnable; items.DllFile = dllBytesArray; items.PdbFile = pdbBytesArray; } } Successor?.Build(items); }