Exemplo n.º 1
0
        static void SimpleCallbackTest()
        {
            var m = new ModRef <int>(0);
            var d = m.Map(a => 2 * a);

            Report.Begin("m = 0");
            var s = d.UnsafeRegisterCallbackNoGcRoot(v =>
            {
                Report.Line("m * 2 = {0}", v);
            });

            Report.End();

            Report.Begin("m = 3");
            using (Adaptive.Transaction)
            {
                m.Value = 3;
            }
            Report.End();


            Report.Begin("m = 1; m = 2");
            using (Adaptive.Transaction)
            {
                m.Value = 1;
                m.Value = 2;
            }
            Report.End();
        }
Exemplo n.º 2
0
        public static bool TryGetTarget(ModRef n, out AST <Node> target)
        {
            Contract.Requires(n != null);
            if (!(n.CompilerData is Location))
            {
                target = null;
                return(false);
            }

            target = ((Location)n.CompilerData).AST;
            return(true);
        }
Exemplo n.º 3
0
        static IModRef <BackendConfiguration> SetScene(IRenderControl win)
        {
            var view        = CameraView.LookAt(new V3d(2.0, 2.0, 2.0), V3d.Zero, V3d.OOI);
            var perspective =
                win.Sizes.Select(s => FrustumModule.perspective(60.0, 0.1, 10.0, ((float)s.X / (float)s.Y)));


            var viewTrafo = DefaultCameraController.control(win.Mouse, win.Keyboard, win.Time, view);

            var index     = new[] { 0, 1, 2, 0, 2, 3 };
            var positions = new[] { new V3f(-1, -1, 0), new V3f(1, -1, 0), new V3f(1, 1, 0), new V3f(-1, 1, 0) };

            var attributes = new SymbolDict <Array>()
            {
                { DefaultSemantic.Positions, positions }
            };

            var quad = new IndexedGeometry(IndexedGeometryMode.TriangleList,
                                           (Array)index,
                                           attributes,
                                           new SymbolDict <Object>());

            var quadSg = quad.ToSg();

            var whiteShader = Effects.ConstantColor.Effect(C4f.White);

            var trafo = Effects.Trafo.Effect;

            var sg =
                quadSg
                .WithEffects(new[] { trafo, whiteShader })
                .ViewTrafo(viewTrafo.Select(t => t.ViewTrafo))
                .ProjTrafo(perspective.Select(t => t.ProjTrafo()));

            var config = new ModRef <BackendConfiguration>(BackendConfigurationModule.UnmanagedOptimized);
            var task   = ((Aardvark.Rendering.GL.Runtime)win.Runtime).CompileRender(win.FramebufferSignature, config, Aardvark.SceneGraph.Semantics.RenderObjectSemantics.Semantic.renderObjects(sg));

            win.RenderTask = DefaultOverlays.withStatistics(task);

            return(config);
        }
Exemplo n.º 4
0
        private void ResetState()
        {
            currentModule = null;
            parseResult.ClearFlags();
            /******* State for building terms ********/
            appStack.Clear();
            argStack.Clear();
            quoteStack.Clear();
            /*****************************************/

            /******* State for building rules, contracts, and comprehensions ********/
            crntRule     = null;
            crntContract = null;
            crntBody     = null;
            /*****************************************/

            /******* State for building types and type declarations ********/
            crntTypeDeclName = null;
            crntTypeDeclSpan = default(Span);
            crntTypeDecl     = null;
            crntTypeTerm     = null;
            currentEnum      = null;
            /*****************************************/

            /******* State for ModRefs, steps, and updates ********/
            crntModRef      = null;
            crntStep        = null;
            crntUpdate      = null;
            crntModRefState = ModRefState.None;
            /*************************************/

            /******* State for sentence configs ********/
            crntSentConf = null;
            /*************************************/

            IsBuildingNext   = false;
            IsBuildingUpdate = false;
            IsBuildingCod    = false;
        }
Exemplo n.º 5
0
 public ModApplyInfo(ModRef modRef)
     : base(NodeKind.ModApply, modRef.Span)
 {
     ModRef = modRef;
 }
Exemplo n.º 6
0
        private void AppendModRef(ModRef modRef)
        {
            Contract.Requires(currentModule != null);
            Contract.Requires(modRef != null);
            Contract.Requires(crntModRefState != ModRefState.None);
            crntModRef = modRef;
            switch (crntModRefState)
            {
            case ModRefState.Input:
                switch (currentModule.NodeKind)
                {
                case NodeKind.Transform:
                    ((Transform)currentModule).AddInput(new Param(modRef.Span, null, modRef));
                    break;

                case NodeKind.TSystem:
                    ((TSystem)currentModule).AddInput(new Param(modRef.Span, null, modRef));
                    break;

                case NodeKind.Machine:
                    ((Machine)currentModule).AddInput(new Param(modRef.Span, null, modRef));
                    break;

                case NodeKind.Model:
                    ((Model)currentModule).AddCompose(modRef);
                    break;

                default:
                    throw new NotImplementedException();
                }
                break;

            case ModRefState.Output:
                switch (currentModule.NodeKind)
                {
                case NodeKind.Transform:
                    ((Transform)currentModule).AddOutput(new Param(modRef.Span, null, modRef));
                    break;

                case NodeKind.TSystem:
                    ((TSystem)currentModule).AddOutput(new Param(modRef.Span, null, modRef));
                    break;

                default:
                    throw new NotImplementedException();
                }
                break;

            case ModRefState.Other:
                switch (currentModule.NodeKind)
                {
                case NodeKind.Domain:
                    ((Domain)currentModule).AddCompose(modRef);
                    break;

                case NodeKind.Model:
                    ((Model)currentModule).SetDomain(modRef);
                    break;

                case NodeKind.Machine:
                    ((Machine)currentModule).AddStateDomain(modRef);
                    break;

                default:
                    throw new NotImplementedException();
                }
                break;

            case ModRefState.ModApply:
                appStack.Push(new ModApplyInfo(modRef));
                break;
            }
        }