コード例 #1
0
        public void Add_SymbolRedefinition_ThrowsSymbolRedefinitionException()
        {
            var environment = new Environment();

            environment.Add(new Symbol("x"), new Nil());
            Assert.Throws <SymbolRedefinitionException>(() =>
                                                        environment.Add(new Symbol("x"), new Nil()));
        }
コード例 #2
0
ファイル: HlangFunction.cs プロジェクト: BalenDezai/Hlang
        /// <summary>
        /// Bind the instance of the class to the scope of the function under the keyword "this"
        /// </summary>
        /// <param name="instance">Instance of class</param>
        /// <returns>The function with "this" binded</returns>
        public HlangFunction Bind(HlangClass instance)
        {
            Environment env = new Environment(_closure);

            env.Add("this", instance);
            return(new HlangFunction(_funcDeclaration, env));
        }
コード例 #3
0
ファイル: Entity.cs プロジェクト: zorbathut/ghi
        public void Creation()
        {
            Dec.Config.TestParameters = new Dec.Config.UnitTestParameters {
                explicitStaticRefs = new System.Type[] { typeof(EntityTemplateDecs) }
            };
            var parser = new Dec.Parser();

            parser.AddString(@"
                <Decs>
                    <ComponentDec decName=""Component"">
                        <type>SimpleComponent</type>
                    </ComponentDec>

                    <EntityDec decName=""EntityModel"">
                        <components>
                            <li>Component</li>
                        </components>
                    </EntityDec>
                </Decs>
            ");
            parser.Finish();

            Environment.Startup();
            Environment.Add(new Ghi.Entity(EntityTemplateDecs.EntityModel));
            var ents = Environment.List.ToArray();

            Assert.AreEqual(1, ents.Length);
            Assert.IsTrue(ents[0].Component <SimpleComponent>() != null);
        }
コード例 #4
0
ファイル: Entity.cs プロジェクト: zorbathut/ghi
        public void ToStringExistent()
        {
            Dec.Config.TestParameters = new Dec.Config.UnitTestParameters {
                explicitStaticRefs = new System.Type[] { typeof(EntityTemplateDecs) }
            };
            var parser = new Dec.Parser();

            parser.AddString(@"
                <Decs>
                    <ComponentDec decName=""Component"">
                        <type>SimpleComponent</type>
                    </ComponentDec>

                    <EntityDec decName=""EntityModel"">
                        <components>
                            <li>Component</li>
                        </components>
                    </EntityDec>
                </Decs>
            ");
            parser.Finish();

            Environment.Startup(toString: e => "ToStringTest");
            Environment.Add(new Ghi.Entity(EntityTemplateDecs.EntityModel));
            var ents = Environment.List.ToArray();

            Assert.AreEqual("ToStringTest", ents[0].ToString());
        }
コード例 #5
0
ファイル: Entity.cs プロジェクト: zorbathut/ghi
        public void ToStringNonexistent()
        {
            Dec.Config.TestParameters = new Dec.Config.UnitTestParameters {
                explicitStaticRefs = new System.Type[] { typeof(EntityTemplateDecs) }
            };
            var parser = new Dec.Parser();

            parser.AddString(@"
                <Decs>
                    <ComponentDec decName=""Component"">
                        <type>SimpleComponent</type>
                    </ComponentDec>

                    <EntityDec decName=""EntityModel"">
                        <components>
                            <li>Component</li>
                        </components>
                    </EntityDec>
                </Decs>
            ");
            parser.Finish();

            Environment.Startup();
            Environment.Add(new Ghi.Entity(EntityTemplateDecs.EntityModel));
            var ents = Environment.List.ToArray();

            ents[0].ToString(); // we're just checking to make sure it doesn't crash, we actually don't care what it outputs
        }
コード例 #6
0
 public override void Write(CustomFileWriter writer)
 {
     // WithProperties(x => x.Underscore().Dasherize().ToLowerInvariant());
     if (!string.IsNullOrWhiteSpace(DotNetVersion))
     {
         With.Add("dotnet-version", DotNetVersion);
     }
     if (!string.IsNullOrWhiteSpace(SourceUrl))
     {
         With.Add("source-url", SourceUrl);
     }
     if (!string.IsNullOrWhiteSpace(Owner))
     {
         With.Add("owner", Owner);
     }
     if (!string.IsNullOrWhiteSpace(SourceUrl))
     {
         NuGetAuthToken = string.IsNullOrWhiteSpace(NuGetAuthToken) ? "${{ secrets.GITHUB_TOKEN }}" : NuGetAuthToken;
     }
     if (!string.IsNullOrWhiteSpace(NuGetAuthToken))
     {
         Environment.Add("NUGET_AUTH_TOKEN", NuGetAuthToken);
     }
     base.Write(writer);
 }
コード例 #7
0
        private void AddToCategory(string category, string field, string label, NameValueCollection value)
        {
            var labelValue = Tuple.Create(label, value.Cast <string>()
                                          .Select(key => new KeyValuePair <string, string>(key, value[key]))
                                          );

            switch (category)
            {
            case "form":
                Form.Add(field, labelValue);
                break;

            case "support.metrics.system":
                System.Add(field, labelValue);
                break;

            case "support.metrics.environment":
                Environment.Add(field, labelValue);
                break;

            case "support.metrics.counters":
                Counters.Add(field, labelValue);
                break;

            case "support.metrics.tasks":
                Tasks.Add(field, labelValue);
                break;

            case "support.metrics.eventlog":
                EventLog.Add(field, labelValue);
                break;
            }
        }
コード例 #8
0
ファイル: CoreTests.cs プロジェクト: Daouki/yung
 public CoreFunctionTests()
 {
     _environment = new Environment();
     foreach (var(key, value) in Core.Functions)
     {
         _environment.Add(key, value);
     }
 }
コード例 #9
0
ファイル: Entity.cs プロジェクト: zorbathut/ghi
            public static void Execute()
            {
                var entity = new Entity(EntityTemplateDecs.EntityModel);

                Environment.Add(entity);    // We intentionally add it first; we should still be able to muck with it

                entity.Component <SimpleComponent>().number = 4;
            }
コード例 #10
0
        public void Contains(string binding, bool expected)
        {
            var environment = new Environment();

            environment.Add(new Symbol("a"), new Nil());
            var actual = environment.Contains(new Symbol(binding));

            Assert.Equal(expected, actual);
        }
コード例 #11
0
        public override void GlobalSetup()
        {
            if (TieredJit)
            {
                Environment.Add("COMPLUS_EXPERIMENTAL_TieredCompilation", "1");
            }

            base.GlobalSetup();
        }
コード例 #12
0
        public CodegenProperty AddSymbol(CodegenExpressionRef symbol)
        {
            if (Environment.IsEmpty()) {
                Environment = new List<CodegenExpressionRef>(4);
            }

            Environment.Add(symbol);
            return this;
        }
コード例 #13
0
        public override void GlobalSetup()
        {
            if (!NodeReuse)
            {
                Environment.Add("MSBUILDDISABLENODEREUSE", "1");
            }

            base.GlobalSetup();
        }
コード例 #14
0
        public void GetValue_FromOuter()
        {
            var bindingName      = new Symbol("x");
            var outerEnvironment = new Environment();

            outerEnvironment.Add(bindingName, new Nil());
            var innerEnvironment = new Environment(outerEnvironment);
            var value            = innerEnvironment.GetValue(bindingName);

            Assert.IsType <Nil>(value);
        }
コード例 #15
0
 /// <summary>
 /// Sets an environment value.
 /// </summary>
 /// <param name="key"></param>
 /// <param name="value"></param>
 private void Set(string key, object value)
 {
     if (Environment.ContainsKey(key))
     {
         Environment[key] = value;
     }
     else
     {
         Environment.Add(key, value);
     }
 }
コード例 #16
0
        public override void GlobalSetup()
        {
            // The environment of persistent build processes may be modified, so they should be killed in both
            // setup and cleanup to ensure consistent results both inside and outside the benchmarking app.
            KillPersistentBuildProcesses();

            if (TieredJit)
            {
                Environment.Add("COMPLUS_EXPERIMENTAL_TieredCompilation", "1");
            }

            base.GlobalSetup();
        }
コード例 #17
0
ファイル: ComponentPermission.cs プロジェクト: zorbathut/ghi
        public void PermissionsRwRo()
        {
            Dec.Config.TestParameters = new Dec.Config.UnitTestParameters {
                explicitStaticRefs = new System.Type[] { typeof(Decs) }
            };
            var parser = new Dec.Parser();

            parser.AddString(@"
                <Decs>
                    <ComponentDec decName=""SimpleComponent"">
                        <type>SimpleComponent</type>
                    </ComponentDec>

                    <ComponentDec decName=""StringComponent"">
                        <type>StringComponent</type>
                    </ComponentDec>

                    <EntityDec decName=""EntityModel"">
                        <components>
                            <li>SimpleComponent</li>
                            <li>StringComponent</li>
                        </components>
                    </EntityDec>

                    <SystemDec decName=""TestSystem"">
                        <type>ComponentPermissionRwSystem</type>
                        <iterate>
                            <SimpleComponent>ReadOnly</SimpleComponent>
                            <StringComponent>ReadWrite</StringComponent>
                        </iterate>
                    </SystemDec>

                    <ProcessDec decName=""TestProcess"">
                        <order>
                            <li>TestSystem</li>
                        </order>
                    </ProcessDec>
                </Decs>
            ");
            parser.Finish();

            Environment.Startup();

            Environment.Add(new Entity(Decs.EntityModel));
            Environment.Add(new Entity(Decs.EntityModel));

            ComponentPermissionRwSystem.Executions = 0;
            ExpectErrors(() => Environment.Process(Decs.TestProcess));
            Assert.AreEqual(2, ComponentPermissionRwSystem.Executions);
        }
コード例 #18
0
ファイル: AST.cs プロジェクト: Sharknevercries/MiniLisp
            public override object Evaluate()
            {
                if (FunctionName != null)
                {
                    Function = LookUp(FunctionName) as IAST;
                }

                var env = new Environment();

                if (Function is FunctionCall)
                {
                    Function = Function.Evaluate() as IAST;
                }

                var func = Function as Function;

                if (Param.Count != func.Param.Count)
                {
                    Scanner.yyerror(SYNTAX_ERROR);
                    YYAbort();
                }

                for (int i = 0; i < Param.Count; i++)
                {
                    var  key   = func.Param[i];
                    IAST value = null;
                    if (Param[i] is Function)
                    {
                        value = Param[i];
                    }
                    else
                    {
                        value = Param[i].Evaluate() as IAST;
                    }
                    env.Add(key, value);
                }

                PushEnvironment(env);

                if (FunctionName != null)
                {
                    Add(FunctionName, Function);
                }

                var ret = func.Evaluate();

                PopEnvironment();

                return(ret);
            }
コード例 #19
0
ファイル: Syntaxes.cs プロジェクト: yagiey/scallop
        public static SExp Define(SExp[] vals, Environment env)
        {
            Utilities.CheckArguments(vals, args=>args.Length==2, "define: ");
              SExp name = vals[0];
              if (!(name is Identifier))
              {
            string msg = "define: The first argument must be identifier.";
            throw new TypeNotMatchException(msg);
              }

              SExp exp = Utilities.Eval(vals[1], env);

              env.Add(new Entry((name as Identifier).Value as string, exp));
              return name;
        }
コード例 #20
0
        public void Basic()
        {
            Dec.Config.TestParameters = new Dec.Config.UnitTestParameters {
                explicitStaticRefs = new System.Type[] { typeof(Decs) }
            };
            var parser = new Dec.Parser();

            parser.AddString(@"
                <Decs>
                    <ComponentDec decName=""Component"">
                        <type>SimpleComponent</type>
                    </ComponentDec>

                    <EntityDec decName=""EntityModel"">
                        <components>
                            <li>Component</li>
                        </components>
                    </EntityDec>

                    <SystemDec decName=""TestSystem"">
                        <type>IterationSystem</type>
                        <iterate>
                            <Component>ReadWrite</Component>
                        </iterate>
                    </SystemDec>

                    <ProcessDec decName=""TestProcess"">
                        <order>
                            <li>TestSystem</li>
                        </order>
                    </ProcessDec>
                </Decs>
            ");
            parser.Finish();

            Environment.Startup();

            Environment.Add(new Entity(Decs.EntityModel));
            Environment.Add(new Entity(Decs.EntityModel));

            IterationSystem.Executions = 0;
            Environment.Process(Decs.TestProcess);
            Assert.AreEqual(2, IterationSystem.Executions);

            Entity[] entities = Environment.List.OrderBy(e => e.Component <SimpleComponent>().number).ToArray();
            Assert.AreEqual(1, entities[0].Component <SimpleComponent>().number);
            Assert.AreEqual(2, entities[1].Component <SimpleComponent>().number);
        }
コード例 #21
0
        public static void Main(string[] args)
        {
            using (Context c = Context.Create(DebugLevel.Debug))
            {
                using (Environment e = c.CreateEnvironment())
                {
                    float[] vertices = new float[] { 1, 0, 0, 0, 1, 0, 0, 0, 1 };
                    float[] indices  = new float[] { 0, 1, 2 };

                    using (TriMesh trimesh = new TriMesh(vertices, indices))
                    {
                        using (Body body = e.CreateBody(""))
                        {
                            body.InitFromTriMesh(trimesh, true);
                            body.Name = "mytriangle";

                            e.Add(body);
                            e.SetViewer("qtcoin");

                            float[] pose         = new float[] { 1, 0, 0, 0, 0, 0, 0 };
                            ulong   startsimtime = e.SimulationTime;

                            for (int i = 0; i < 10000; ++i)
                            {
                                e.Lock();

                                ulong  newsimtime = e.SimulationTime;
                                double deltatime  = (double)((newsimtime - startsimtime) * 1e-6);
                                //double fanim = System.Math.IEEERemainder(deltatime,1.0);

                                pose[0]         = (float)System.Math.Sin(deltatime);
                                pose[3]         = (float)System.Math.Cos(deltatime);
                                body.TransformF = pose;

                                e.Unlock();

                                // wait until sim time changes
                                while (newsimtime == e.SimulationTime)
                                {
                                    System.Threading.Thread.Sleep(1);
                                }
                            }
                        }
                    }
                }
            }
        }
コード例 #22
0
        public void Addition()
        {
            Dec.Config.TestParameters = new Dec.Config.UnitTestParameters {
                explicitStaticRefs = new System.Type[] { typeof(Decs) }
            };
            var parser = new Dec.Parser();

            parser.AddString(@"
                <Decs>
                    <ComponentDec decName=""Component"">
                        <type>SimpleComponent</type>
                    </ComponentDec>

                    <EntityDec decName=""EntityModel"">
                        <components>
                            <li>Component</li>
                        </components>
                    </EntityDec>

                    <SystemDec decName=""TestSystem"">
                        <type>IterationAddSystem</type>
                        <iterate>
                            <Component>ReadWrite</Component>
                        </iterate>
                    </SystemDec>

                    <ProcessDec decName=""TestProcess"">
                        <order>
                            <li>TestSystem</li>
                        </order>
                    </ProcessDec>
                </Decs>
            ");
            parser.Finish();

            Environment.Startup();

            Environment.Add(new Entity(Decs.EntityModel));
            Environment.Add(new Entity(Decs.EntityModel));

            Assert.AreEqual(2, Environment.List.Count());
            Environment.Process(Decs.TestProcess);
            Assert.AreEqual(4, Environment.List.Count());
        }
コード例 #23
0
        public void PermissionsRwRw()
        {
            Dec.Config.TestParameters = new Dec.Config.UnitTestParameters {
                explicitStaticRefs = new System.Type[] { typeof(Decs) }
            };
            var parser = new Dec.Parser();

            parser.AddString(@"
                <Decs>
                    <ComponentDec decName=""Component"">
                        <type>SimpleComponent</type>
                    </ComponentDec>

                    <EntityDec decName=""Entity"">
                        <components>
                            <li>Component</li>
                        </components>
                    </EntityDec>

                    <SystemDec decName=""TestSystem"">
                        <type>FullPermissionRwSystem</type>
                        <full>
                            <Component>ReadWrite</Component>
                        </full>
                    </SystemDec>

                    <ProcessDec decName=""TestProcess"">
                        <order>
                            <li>TestSystem</li>
                            <li>TestSystem</li>
                        </order>
                    </ProcessDec>
                </Decs>
            ");
            parser.Finish();

            Environment.Startup();
            Environment.Add(new Entity(Decs.Entity));

            FullPermissionRwSystem.Executions = 0;
            Environment.Process(Decs.TestProcess);
            Assert.AreEqual(2, FullPermissionRoSystem.Executions);
        }
コード例 #24
0
ファイル: RegexFilter.cs プロジェクト: sri-n/RecursiveCleaner
        public bool IsMatch(FileSystemInfo fsi, Environment environment)
        {
            var m = regex.Match(fsi.Name);

            if (!m.Success) return false;

            foreach( var groupName in regex.GetGroupNames() )
            {
                var group = m.Groups[groupName];

                Log.Debug("Groups[\"{0}\"] = {1}", groupName, group);

                if (group.Success)
                {
                    environment.Add(groupName, group.Value);
                }
            }

            return true;
        }
コード例 #25
0
        public bool IsMatch(FileSystemInfo fsi, Environment environment)
        {
            var m = regex.Match(fsi.Name);

            if (!m.Success)
            {
                return(false);
            }

            foreach (var groupName in regex.GetGroupNames())
            {
                var group = m.Groups[groupName];

                Log.Debug("Groups[\"{0}\"] = {1}", groupName, group);

                if (group.Success)
                {
                    environment.Add(groupName, group.Value);
                }
            }

            return(true);
        }
コード例 #26
0
        public void IterationIndex()
        {
            Dec.Config.TestParameters = new Dec.Config.UnitTestParameters {
                explicitStaticRefs = new System.Type[] { typeof(IterationIndexDefs) }
            };
            var parser = new Dec.Parser();

            parser.AddString(@"
                <Decs>
                    <ComponentDec decName=""ComponentA"">
                        <type>SimpleComponent</type>
                    </ComponentDec>

                    <ComponentDec decName=""ComponentB"">
                        <type>StringComponent</type>
                    </ComponentDec>

                    <EntityDec decName=""IterationIndexEntityA"">
                        <components>
                            <li>ComponentA</li>
                        </components>
                    </EntityDec>

                    <EntityDec decName=""IterationIndexEntityB"">
                        <components>
                            <li>ComponentB</li>
                        </components>
                    </EntityDec>

                    <SystemDec decName=""IterationIndexSystemA"">
                        <type>IterationIndexSystemA</type>
                        <iterate>
                            <ComponentA>ReadWrite</ComponentA>
                        </iterate>
                    </SystemDec>

                    <SystemDec decName=""IterationIndexSystemB"">
                        <type>IterationIndexSystemB</type>
                        <iterate>
                            <ComponentB>ReadWrite</ComponentB>
                        </iterate>
                    </SystemDec>

                    <ProcessDec decName=""IterationIndexProcess"">
                        <order>
                            <li>IterationIndexSystemA</li>
                            <li>IterationIndexSystemB</li>
                        </order>
                    </ProcessDec>
                </Decs>
            ");
            parser.Finish();

            Environment.Startup();

            Environment.Add(new Entity(IterationIndexDefs.IterationIndexEntityA));
            Environment.Add(new Entity(IterationIndexDefs.IterationIndexEntityB));

            Environment.Process(IterationIndexDefs.IterationIndexProcess);

            Assert.AreEqual(1, IterationIndexSystemA.Touched.Count);
            Assert.AreEqual(1, IterationIndexSystemA.Touched.Count);
            Assert.AreEqual(2, Enumerable.Union(IterationIndexSystemA.Touched, IterationIndexSystemB.Touched).Count());
        }
コード例 #27
0
 public static void Execute(Entity simple)
 {
     Environment.Add(new Entity(Decs.EntityModel));
 }
コード例 #28
0
ファイル: Main.cs プロジェクト: jdsika/TUM_HOly
        public static void Main(string[] args)
        {
            using (Context c = Context.Create(DebugLevel.Debug))
            {
                using (Environment e = c.CreateEnvironment())
                {
                    e.Load("data/lab1.env.xml");
                    e.SetViewer("qtcoin");

                    bool pole2added = true;
                    Body bodypole2  = e.GetBody("pole2");
                    Body bodypole3  = e.GetBody("pole3");

                    using (DisposableList <BodyLink> links = bodypole3.Links)
                    {
                        using (DisposableList <BodyGeometry> geometries = links[0].Geometries)
                        {
                            float[] pose         = bodypole3.TransformF;
                            ulong   startsimtime = e.SimulationTime;;

                            for (int i = 0; i < 10000; ++i)
                            {
                                e.Lock();

                                ulong  newsimtime = e.SimulationTime;
                                double deltatime  = (newsimtime - startsimtime) * 1e-6;
                                float  fanim      = (float)System.Math.IEEERemainder(deltatime, 1.0);

                                // animate around X axis
                                pose[4] = 1.0f + fanim;
                                bodypole3.TransformF = pose;

                                // set the color
                                geometries[0].SetDiffuseColor(1.0f, 0.0f, fanim);

                                if (fanim > 0.5 && pole2added)
                                {
                                    // remove the pole
                                    e.Remove(bodypole2);
                                    pole2added = false;
                                }
                                else if (fanim < 0.5 && !pole2added)
                                {
                                    e.Add(bodypole2);
                                    pole2added = true;
                                }

                                // unlock
                                e.Unlock();

                                // wait until sim time changes
                                while (newsimtime == e.SimulationTime)
                                {
                                    System.Threading.Thread.Sleep(1);
                                }
                            }
                        }
                    }
                }
            }
        }
コード例 #29
0
 public JenkinsOptions AddEnvironment(string key, string value)
 {
     Environment.Add(key, value);
     return(this);
 }