예제 #1
0
        private void AddEntOpsWhenFileWins(Ent ent, List <string> path, List <Op> ops, int i)
        {
            switch (ent.Infos[i].Type)
            {
            case Info.TypeEn.None:
                ops.Add(new Op.CreateFile(path.ToArray(), conns[ent.ActualWinner], conns[i], ent.Name, ent.Infos[ent.ActualWinner].Time));
                break;

            case Info.TypeEn.File:
                if (!ent.Infos[i].Equals(ent.Infos[ent.ActualWinner]))
                {
                    ops.Add(new Op.DeleteFile(path.ToArray(), conns[i], ent.Name));
                    ops.Add(new Op.CreateFile(path.ToArray(), conns[ent.ActualWinner], conns[i], ent.Name, ent.Infos[ent.ActualWinner].Time));
                }
                break;

            case Info.TypeEn.Dir:
                AddDeleteEmptyDirOp(ops, i, ent, path);
                ops.Add(new Op.CreateFile(path.ToArray(), conns[ent.ActualWinner], conns[i], ent.Name, ent.Infos[ent.ActualWinner].Time));
                break;

            case Info.TypeEn.Other:
                ops.Add(new Op.DeleteFile(path.ToArray(), conns[i], ent.Name));
                break;
            }
        }
예제 #2
0
 public void Iterate(CADEntityProc Proc, CADIterate Params)
 {
     foreach (DXFEntity Ent in Entities)
     {
         Ent.Invoke(Proc, Params);
     }
 }
        public void MainTest()
        {
            var sw = new Stopwatch();

            using (var s = Domain.OpenSession(SessionConfiguration.Default))
                using (s.Activate())
                    using (var t1 = s.OpenTransaction(TransactionOpenMode.New)) {
                        sw.Start();

                        var ent = new Ent();

                        for (var i = 0; i < IterationsCount; i++)
                        {
                            Session.Current.Query.All <Ent>().Where(z => z.Id == ent.Id).ToArray();
                            ent.Num = i;
                            if (i % 100 == 0)
                            {
                                Console.WriteLine("{0}    {1}", i, sw.Elapsed.TotalSeconds);
                                sw.Restart();
                            }
                        }
                        sw.Stop();
                        t1.Complete();
                    }
        }
예제 #4
0
 public override bool HasNext()
 {
     if (this.next == null)
     {
         this.next = this.Peek();
     }
     return(this.next != null);
 }
예제 #5
0
 private void AssertNoChildren(Ent ent, List <string> path, List <Op> ops)
 {
     Info.TypeEn subbecomes = MergeRecurseSubs(ent, path, ops);
     if (subbecomes != 0)
     {
         throw new CannotHappenException("Should delete all siblings but for some of them children remain.");
     }
 }
예제 #6
0
 private void AddDeleteEmptyDirOp(List <Op> ops, int c, Ent ent, List <string> path)
 {
     foreach (string ignoredFileName in ent.Infos[c].ContainedIgnoredFiles)
     {
         ops.Add(new Op.DeleteFile(path.Concat(new string[] { ent.Name }).ToArray(), conns[c], ignoredFileName));
     }
     ops.Add(new Op.DeleteEmptyDir(path.ToArray(), conns[c], ent.Name));
 }
 public static AuthorityEntity toAuthorityEntity(this Ent ent)
 {
     return(new AuthorityEntity()
     {
         Id = ent.EntOwnId,
         AuthorityName = ent.EntVal
     });
 }
예제 #8
0
파일: Pass.cs 프로젝트: Oshhcar/Colette
 public override Result GetC3D(Ent e, bool funcion, bool ciclo, bool isDeclaracion, bool isObjeto, LinkedList <Error> errores)
 {
     if (!isDeclaracion)
     {
         Debugger(e, "Pass");
     }
     return(new Result());
 }
예제 #9
0
        private Info.TypeEn MergeRecurse(Ent ent, List <string> path, List <Op> ops)
        {
            Info.TypeEn becomes = 0;
            if (ent.ActualWinner == WinnerPreserve)
            {
                for (int i = 0; i < MaxConnCount; i++)
                {
                    if (ent.Infos[i] != null)
                    {
                        becomes |= ent.Infos[i].Type;
                    }
                }
                if (0 == (becomes & ~(Info.TypeEn.Dir | Info.TypeEn.Other)))
                {
                    MergeRecurseSubs(ent, path, ops);
                }
                else
                {
                    AssertNoChildren(ent, path, ops);
                }
            }
            else
            {
                becomes = ent.Infos[ent.ActualWinner].Type;
                Info.AssertValidType(becomes);
                switch (becomes)
                {
                case Info.TypeEn.None:
                    AssertNoChildren(ent, path, ops);
                    MapInfosThatExist(ent, delegate(int i) {
                        AddEntOpsWhenNoneWins(ent, path, ops, i);
                    });
                    break;

                case Info.TypeEn.File:
                    AssertNoChildren(ent, path, ops);
                    MapInfosThatExist(ent, delegate(int i) {
                        AddEntOpsWhenFileWins(ent, path, ops, i);
                    });
                    break;

                case Info.TypeEn.Dir:
                    MapInfosThatExist(ent, delegate(int i) {
                        AddEntOpsWhenDirWins(ent, path, ops, i);
                    });
                    MergeRecurseSubs(ent, path, ops);
                    break;

                case Info.TypeEn.Other:
                    MapInfosThatExist(ent, delegate(int i) {
                        AddEntOpsWhenOtherWins(ent, i);
                    });
                    break;
                }
            }
            return(becomes);
        }
예제 #10
0
 public override KeyValuePair <string, Ref> Next()
 {
     if (this.HasNext())
     {
         Ent r = this.next;
         this.next = this.Peek();
         return(r);
     }
     throw new NoSuchElementException();
 }
예제 #11
0
파일: NonLocal.cs 프로젝트: Oshhcar/Colette
        public override Result GetC3D(Ent e, bool funcion, bool ciclo, bool isDeclaracion, bool isObjeto, LinkedList <Error> errores)
        {
            if (!isDeclaracion)
            {
                Debugger(e, "Nonlocal");
            }
            Result result = new Result();

            return(result);
        }
예제 #12
0
 private void btnClear_Click(object sender, EventArgs e)
 {
     SuspendLayout();
     foreach (Control Ent in FlowEntries.Controls)
     {
         Ent.Dispose();
     }
     FlowEntries.Controls.Clear();
     ResumeLayout();
 }
예제 #13
0
        public void TestAlpha()
        {
            var va = Vec.From(1, 2, 3);
            var vb = Vec.From(4, 5, 6);
            var vc = Vec.From(7, 8, 9);
            var vd = Vec.From(0, 0, 0);

            Ent.Wind(va, vb).Deco().Says("dual");
            Ent.Wind(va, vb, vc).Deco().Says("tri");
            Ent.Wind(va, vb, vc, vd).Deco().Says("quadri");
        }
예제 #14
0
        public override Result GetC3D(Ent e, bool funcion, bool ciclo, bool isObjeto, LinkedList <Error> errores)
        {
            Result result = new Result();

            Result rsVerdadera = Verdadera.GetC3D(e, funcion, ciclo, isObjeto, errores);
            Result rsFalsa     = Falsa.GetC3D(e, funcion, ciclo, isObjeto, errores);

            if (Condicion is Relacional)
            {
                ((Relacional)Condicion).Cortocircuito = true;
            }
            else if (Condicion is Logica)
            {
                ((Logica)Condicion).Evaluar = true;
            }

            Result rsCondicion = Condicion.GetC3D(e, funcion, ciclo, isObjeto, errores);

            if (rsVerdadera != null && rsFalsa != null && rsCondicion != null)
            {
                if (Condicion is Literal)
                {
                    rsCondicion.EtiquetaV = NuevaEtiqueta();
                    rsCondicion.EtiquetaF = NuevaEtiqueta();

                    rsCondicion.Codigo    += "ifFalse (" + rsCondicion.Valor + " == 1) goto " + rsCondicion.EtiquetaV + ";\n";
                    rsCondicion.Codigo    += "goto " + rsCondicion.EtiquetaF + ";\n";
                    rsCondicion.EtiquetaV += ":\n";
                    rsCondicion.EtiquetaF += ":\n";
                }

                if (Condicion is Relacional || Condicion is Literal)
                {
                    string copy = rsCondicion.EtiquetaF;
                    rsCondicion.EtiquetaF = rsCondicion.EtiquetaV;
                    rsCondicion.EtiquetaV = copy;
                }

                string etqSalida = NuevaEtiqueta();
                result.Valor   = NuevoTemporal();
                result.Codigo += rsCondicion.Codigo;
                result.Codigo += rsCondicion.EtiquetaV;
                result.Codigo += rsVerdadera.Codigo;
                result.Codigo += result.Valor + " = " + rsVerdadera.Valor + ";\n";
                result.Codigo += "goto " + etqSalida + ";\n";
                result.Codigo += rsCondicion.EtiquetaF;
                result.Codigo += rsFalsa.Codigo;
                result.Codigo += result.Valor + " = " + rsFalsa.Valor + ";\n";
                result.Codigo += etqSalida + ":\n";

                Tipo = Verdadera.GetTipo();
            }
            return(result);
        }
예제 #15
0
 private void MapInfosThatExist(Ent ent, IntToVoidFunc mapfunc)
 {
     for (int i = 0; i < MaxConnCount; i++)
     {
         if (ent.Infos[i] != null)
         {
             Info.AssertValidType(ent.Infos[i].Type);
             mapfunc(i);
         }
     }
 }
        public static Ent ToEnt(this AuthorityEntity AuthorityEntity, Ent ent = null)
        {
            if (ent == null)
            {
                ent = new Ent();
            }

            ent.EntOwnId = AuthorityEntity.Id;
            ent.EntVal   = AuthorityEntity.AuthorityName;

            return(ent);
        }
예제 #17
0
        public List <Op> Merge(TreeNodeCollection nodes)
        {
            List <Op> ops = new List <Op>();

            if (nodes.Count > 0)
            {
                TreeNode rootNode = nodes[0];
                Ent      rootEnt  = (Ent)rootNode.Tag;
                MergeRecurse(rootEnt, new List <string>(), ops);
            }
            // NOTE: I'm relying on the fact that OrderBy is a stable sort.
            return(ops.OrderBy(x => x).ToList());
        }
예제 #18
0
 public override double UseSkill(Ent player, Ent Enemy)
 {
     if (!(player is Player))
     {
         return(0);
     }
     if (manaCost <= (player as Player).Mp)
     {
         player.Mp -= manaCost;
         player.BonusChanceCrit += Buff + Amplificator * Lvl;
         return(0);
     }
     return(0);
 }
예제 #19
0
        public override double UseSkill(Ent player, Ent Enemy)

        {
            if (!(player is Player))
            {
                return(0);
            }
            if (manaCost <= (player as Player).Mp)
            {
                player.Mp -= manaCost;
                return(DamageBonus + Damage);
            }
            return(0);
        }
예제 #20
0
        private void AnalyzeDir(Ent dirent, ulong dirconnmask)
        {
            var ents = new Dictionary <string, Ent>();

            MapBits(dirconnmask, delegate(int c) {
                conns[c].MapDirEntries(delegate(string name, Info info) {
                    if (ShouldIgnore(name, info))
                    {
                        dirent.Infos[c].AddIgnoredFile(name);
                    }
                    else
                    {
                        if (!ents.ContainsKey(name))
                        {
                            ents[name] = new Ent(conns);
                        }
                        ents[name].Infos[c] = info;
                    }
                });
            });
            foreach (KeyValuePair <string, Ent> kvp in ents)
            {
                string name = kvp.Key;
                Ent    ent  = kvp.Value;

                if (ent.AllInfosAreIdenticalFiles)
                {
                    continue;
                }

                ent.AddUnder(dirent, name);

                ulong connmask = MapIntoBits(MaxConnCount, delegate(int c) {
                    return((ent.Infos[c] != null) && (ent.Infos[c].Type == Info.TypeEn.Dir));
                });

                if (connmask != 0)
                {
                    MapBits(connmask, delegate(int c) { conns[c].DescendDir(name); });
                    AnalyzeDir(ent, connmask);
                    MapBits(connmask, delegate(int c) { conns[c].AscendDir(); });
                }

                if (ent.AllInfosAreDirs && (ent.Node.Nodes.Count == 0))
                {
                    ent.Node.Remove();
                }
            }
        }
예제 #21
0
 public override double UseSkill(Ent player, Ent Enemy)
 {
     if (!(player is Player))
     {
         return(0);
     }
     if (manaCost <= (player as Player).Mp)
     {
         // CalcBonus(player);
         // Damage = Damage + Amplificator * Lvl;
         player.Mp -= manaCost;
         return(DamageBonus + Damage);
     }
     return(0);
 }
예제 #22
0
        public override Result GetC3D(Ent e, bool funcion, bool ciclo, bool isDeclaracion, bool isObjeto, LinkedList <Error> errores)
        {
            Result result    = new Result();
            string etqSalida = NuevaEtiqueta();

            foreach (SubIf subif in SubIfs)
            {
                subif.Salida   = etqSalida;
                result.Codigo += subif.GetC3D(e, funcion, ciclo, isDeclaracion, isObjeto, errores).Codigo;
            }

            result.Codigo += etqSalida + ":\n";

            return(result);
        }
예제 #23
0
        public void Analyze(TreeNodeCollection nodes)
        {
            Ent rootEnt = new Ent(conns);

            rootEnt.MakeRootOf(nodes);
            for (int i = 0; i < MaxConnCount; i++)
            {
                if (conns[i] != null)
                {
                    rootEnt.Infos[i]      = new Info();
                    rootEnt.Infos[i].Type = Info.TypeEn.Dir;
                    conns[i].GoToDir(new string[0]); // Go to root dir.
                }
            }
            AnalyzeDir(rootEnt, AllConnsMask);
        }
예제 #24
0
        public override Result GetC3D(Ent e, bool funcion, bool ciclo, bool isDeclaracion, bool isObjeto, LinkedList <Error> errores)
        {
            if (!isDeclaracion)
            {
                Debugger(e, "Asignacion");
            }

            Result result = new Result();

            if (!isDeclaracion)
            {
                Aritmetica operacion = new Aritmetica(Objetivo, Valor, Op, Linea, Columna);

                Result rsOperacion = operacion.GetC3D(e, funcion, ciclo, isObjeto, errores);

                if (rsOperacion != null)
                {
                    if (!operacion.GetTipo().IsIndefinido())
                    {
                        if (Objetivo is Identificador)
                        {
                            ((Identificador)Objetivo).Acceso = false;
                        }
                        else if (Objetivo is Referencia)
                        {
                            ((Referencia)Objetivo).Acceso = false;
                        }

                        Result rsObjetivo = Objetivo.GetC3D(e, funcion, ciclo, isObjeto, errores);

                        if (operacion.GetTipo().Tip == Objetivo.GetTipo().Tip)
                        {
                            result.Codigo += rsOperacion.Codigo;
                            result.Codigo += rsObjetivo.Codigo;
                            result.Codigo += rsObjetivo.Valor + " = " + rsOperacion.Valor + ";\n";
                        }
                        else
                        {
                            errores.AddLast(new Error("Semántico", "El valor a asignar no es del mismo tipo.", Linea, Columna));
                            return(null);
                        }
                    }
                }
            }

            return(result);
        }
예제 #25
0
파일: Literal.cs 프로젝트: Oshhcar/Colette
        public override Result GetC3D(Ent e, bool funcion, bool ciclo, bool isObjeto, LinkedList <Error> errores)
        {
            Result result = new Result();

            if (Tipo.IsInt() || Tipo.IsDouble() || Tipo.IsBoolean())
            {
                result.Valor = Valor.ToString();
            }
            else if (Tipo.IsNone())
            {
                result.Valor   = NuevoTemporal();
                result.Codigo += result.Valor + " = 0 - 1;\n";
            }
            else if (Tipo.IsString())
            {
                /*
                 * string tmp;
                 * int cont = 0;
                 * foreach (char c in Valor.ToString().Substring(1, Valor.ToString().Length - 2))
                 * {
                 *  tmp = NuevoTemporal();
                 *  result.Codigo += tmp + " = H + " + cont++ + ";\n";
                 *  result.Codigo += "heap[" + tmp + "] = " + (int)c + ";\n";
                 *
                 * }
                 * tmp = NuevoTemporal();
                 * result.Codigo += tmp + " = H + " + cont++ + ";\n";
                 * result.Codigo += "heap[" + tmp + "] = 0;\n";
                 *
                 * result.Valor = NuevoTemporal();
                 * result.Codigo += result.Valor + " = H;\n";
                 * result.Codigo += "H = H + " + cont + ";\n";
                 */
                result.Valor   = NuevoTemporal();
                result.Codigo += result.Valor + " = H;\n";

                foreach (char c in Valor.ToString().Substring(1, Valor.ToString().Length - 2))
                {
                    result.Codigo += "heap[H] = " + (int)c + ";\n";
                    result.Codigo += "H = H + 1;\n";
                }
                result.Codigo += "heap[H] = 0;\n";
                result.Codigo += "H = H + 1;\n";
            }

            return(result);
        }
예제 #26
0
 public override double UseSkill(Ent player, Ent Enemy)
 {
     if (!(player is Player))
     {
         return(0);
     }
     if (manaCost <= (player as Player).Mp)
     {
         player.Mp        -= manaCost;
         player.ArmorBuff += (Buff + Amplificator * Lvl);
         return(0);
     }
     else
     {
         return(0);
     }
 }
예제 #27
0
            public static void tick(double fixedDelta)
            {
                List <Eid> entitiesToDestroy = new List <Eid>(); //Required to keep from getting 'Collection Was Modified' exception

                var all = EntityFu.getAll(EntityComponent.HealthComponent.getCid());

                // for this example, just decrement all health components each tick
                foreach (var eid in all)
                {
                    Ent e = new Ent(eid);

                    // this is overly pragmatic, but you get the drift of how to check if a component is valid
                    if (e.health == null || e.health.isEmpty())
                    {
                        continue;
                    }

                    // decrement
                    e.health.hp--;
                    if (e.health.hp < 0)
                    {
                        e.health.hp = 0;
                    }
                    Console.Write("Entity ");
                    Console.Write((int)e.id);
                    Console.Write(" has ");
                    Console.Write(e.health.hp);
                    Console.Write("/");
                    Console.Write(e.health.maxHP);
                    Console.Write(" hit points.");
                    Console.Write("\n");

                    // destroy entity if zero health
                    if (e.health.hp <= 0)
                    {
                        //EntityFu.destroyNow(eid);
                        entitiesToDestroy.Add(eid);
                    }
                }

                foreach (Eid eid in entitiesToDestroy)
                {
                    EntityFu.destroyNow(eid);
                }
            }
예제 #28
0
 private Info.TypeEn MergeRecurseSubs(Ent ent, List <string> path, List <Op> ops)
 {
     Info.TypeEn subbecomes = 0;
     if (ent.Node.Parent != null)
     {
         path.Add(ent.Name);
     }
     foreach (TreeNode subnode in ent.Node.Nodes)
     {
         Ent subent = (Ent)subnode.Tag;
         subbecomes |= MergeRecurse(subent, path, ops);
     }
     if (ent.Node.Parent != null)
     {
         path.RemoveAt(path.Count - 1);
     }
     return(subbecomes);
 }
예제 #29
0
 public override double UseSkill(Ent player, Ent Enemy)
 {
     if (!(player is Player))
     {
         return(0);
     }
     if (manaCost <= (player as Player).Mp)
     {
         player.Mp  -= manaCost;
         oldstatus   = player.Dex;
         player.Dex += (int)(player.Dex * (Buff + Amplificator * Lvl));
         return(0);
     }
     else
     {
         return(0);
     }
 }
예제 #30
0
파일: Test.cs 프로젝트: bailang00/UFM
    IEnumerator Download()
    {
        WWW www = new WWW(url);

        yield return(www);

        string str = www.text;

        www.Dispose();

        var arr = MiniJSON.JsonDecode(str) as ArrayList;

        foreach (Hashtable ht in arr)
        {
            Ent et = new Ent();
            FromHashtable(ht, et);
            Debug.Log(et);
        }
    }