Beispiel #1
0
 public RegisterZIndex(int nX, int nY, String nId, RegisterInfo nR)
     : base(nX, nY, nId, "regZ_index", nR)
 {
     bodky = new [] { new ObjektBodka(-14, -ry - 8, Brushes.Red, this, 0, new BodkaInfo("data", 1, false, r.bitDlzka, false)),
                      new ObjektBodka(6, -ry - 8, Brushes.Red, this, 1, Projekt.DATABAZA[op].vstupy[1]) };
     ciary = new Ciara[2];
 }
Beispiel #2
0
 public Register(int nX, int nY, String nId, String nOp, RegisterInfo nR)
     : base(nX, nY, nId, nOp)
 {
     r  = nR;
     rx = 25;
     dx = 50;
     ry = 25;
     dy = 50;
 }
Beispiel #3
0
        void registerComboBoxSelectedIndexChanged(object sender, EventArgs e)
        {
            ComboBox     cb       = (ComboBox)sender;
            RegisterInfo r        = modul.registre[cb.SelectedIndex];
            Register     register = (Register)modul.objekty[click];

            register.r = r;
            register.bodky[0].info.bitDlzka = r.bitDlzka;
            if (!(register is RegisterZIndex))
            {
                register.bodky[0].info.bitSirka = r.bitSirka;
            }
            register.zrusEditovaciePrvky(panel1);
            register.nastavEditovaciePrvky(panel1);
            registerComboBox();
            register.pridajOkTlacitko(this);
            aktualizujPlochu();
        }
Beispiel #4
0
        void vytvorRegisterOperaciu(object sender, EventArgs e, String op, RegisterInfo r)
        {
            Register temp = null;
            String   id   = modul.getOpId(op);

            if (op == "regC")
            {
                temp = new RegisterC(clickX, clickY, id, r);
            }
            else if (op == "regZ")
            {
                temp = new RegisterZ(clickX, clickY, id, r);
            }
            else if (op == "regZ_index")
            {
                temp = new RegisterZIndex(clickX, clickY, id, r);
            }
            temp.setM(modul);
            modul.objekty.Add(id, temp);
            aktualizujPlochu();
        }
Beispiel #5
0
 public RegisterZ(int nX, int nY, String nId, RegisterInfo nR)
     : base(nX, nY, nId, "regZ", nR)
 {
     bodky = new [] { new ObjektBodka(-4, -ry - 8, Brushes.Red, this, 0, new BodkaInfo("data", r.bitSirka, false, r.bitDlzka, false)) };
     ciary = new Ciara[1];
 }
Beispiel #6
0
 public RegisterC(int nX, int nY, String nId, RegisterInfo nR)
     : base(nX, nY, nId, "regC", nR)
 {
     bodky = new [] { new ObjektBodka(-4, ry, Brushes.Black, this, 0, new BodkaInfo("out", r.bitSirka, false, r.bitDlzka, false)) };
 }
Beispiel #7
0
        public void nacitajDWKod()
        {
            while (a.token != "")
            {
                if (isToken("]"))
                {
                    return;
                }
                if (isToken("def"))
                {
                    String fMeno = popToken();
                    getToken("[");
                    objekty  = new Dictionary <String, Objekt>();
                    registre = new List <RegisterInfo>();
                    vstupy   = new List <BodkaInfo>();
                    vystupy  = new List <BodkaInfo>();
                    nacitajDWKod();
                    Modul f = new Modul(fMeno, objekty, vstupy, vystupy, registre, poleBodiek, poleIndexov);
                    poleBodiek  = null;
                    poleIndexov = null;
                    moduly.Add(f);
                    if (f.meno != "main")
                    {
                        Projekt.DATABAZA[f.meno] = new ObjektInfo(f.meno, f.meno, vstupy, vystupy);
                    }
                }
                else if (isToken("input"))
                {
                    String   vstup = popToken();
                    IntTuple bit   = getTagIntTuple();
                    vstupy.Add(new BodkaInfo(vstup, bit.a, false, bit.b, false));
                }
                else if (isToken("output"))
                {
                    String   vystup = popToken();
                    IntTuple bit    = getTagIntTuple();
                    vystupy.Add(new BodkaInfo(vystup, bit.a, false, bit.b, false));
                }
                else if (isToken("register"))
                {
                    String   register = popToken();
                    IntTuple bit      = getTagIntTuple();
                    registre.Add(new RegisterInfo(register, bit.a, bit.b));
                }
                else if (isToken("#"))
                {
                    nacitajGraf();
                }
                else
                {
                    getToken("{");
                    String id = popToken();
                    getToken("}");

                    if (isToken("call") || isToken("use"))
                    {
                        String   menoModulu = popToken();
                        IntTuple sur        = getTagIntTuple();
                        volania.Add(new TempPouzitieModulu(moduly.Count, sur, id, menoModulu));
                    }
                    else if (isToken("const"))
                    {
                        List <String> values = new List <String>();
                        getToken("(");
                        while (!isToken(")"))
                        {
                            values.Add(popToken());
                        }
                        IntTuple bit = getTagIntTuple();
                        IntTuple sur = getTagIntTuple();
                        objekty[id] = new Konst(sur.a, sur.b, id, "const", bit.a, bit.b, values.ToArray());
                    }

                    else if (isToken("in"))
                    {
                        String    io  = popToken();
                        IntTuple  sur = getTagIntTuple();
                        BodkaInfo b   = getVstup(io);
                        objekty[id] = new IoOperacia(sur.a, sur.b, id, "in", b);
                    }
                    else if (isToken("out"))
                    {
                        String    io  = popToken();
                        IntTuple  sur = getTagIntTuple();
                        BodkaInfo b   = getVystup(io);
                        objekty[id] = new IoOperacia(sur.a, sur.b, id, "out", b);
                    }
                    else if (isToken("regC"))
                    {
                        String       register = popToken();
                        IntTuple     sur      = getTagIntTuple();
                        RegisterInfo r        = getRegister(register);
                        objekty[id] = new RegisterC(sur.a, sur.b, id, r);
                    }
                    else if (isToken("regZ"))
                    {
                        String       register = popToken();
                        IntTuple     sur      = getTagIntTuple();
                        RegisterInfo r        = getRegister(register);
                        objekty[id] = new RegisterZ(sur.a, sur.b, id, r);
                    }
                    else if (isToken("regZ_index"))
                    {
                        String       register = popToken();
                        IntTuple     sur      = getTagIntTuple();
                        RegisterInfo r        = getRegister(register);
                        objekty[id] = new RegisterZIndex(sur.a, sur.b, id, r);
                    }

                    else if (isToken("change"))
                    {
                        IntTuple bit = getTagIntTuple();
                        IntTuple sur = getTagIntTuple();
                        objekty[id] = new ZmenaBitov(sur.a, sur.b, id, bit.a, bit.b);
                    }
                    else
                    {
                        objekty[id] = nacitajOp(id);
                    }
                }
            }
        }
Beispiel #8
0
        void vytvorContextMenu(object sender, System.ComponentModel.CancelEventArgs e)
        {
            contextMenuStrip.Items.Clear();

            if (modul == null)
            {
                return;
            }

            ToolStripMenuItem level1;

            ToolStripMenuItem[] level2;
            ToolStripMenuItem[] level3;

            //----------------------------------

            level2 = new ToolStripMenuItem[2];

            level2[0] = new ToolStripMenuItem(Projekt.DATABAZA["const"].text, null, (sender2, e2) => vytvorOperaciu(sender2, e2, "const"));
            level2[1] = new ToolStripMenuItem(Projekt.DATABAZA["index"].text, null, (sender2, e2) => vytvorOperaciu(sender2, e2, "index"));

            level1 = new ToolStripMenuItem("Hodnoty", null, level2);
            contextMenuStrip.Items.Add(level1);

            //----------------------------------

            level2 = new ToolStripMenuItem[2];

            level3 = new ToolStripMenuItem[modul.vstupy.Count];
            for (int j = 0; j < modul.vstupy.Count; j++)
            {
                BodkaInfo vstup = modul.vstupy[j];
                level3[j] = new ToolStripMenuItem(modul.vstupy[j].meno, null, (sender2, e2) => vytvorIoOperaciu(sender2, e2, "in", vstup));
            }
            level2[0] = new ToolStripMenuItem(Projekt.DATABAZA["in"].text, null, level3);
            level3    = new ToolStripMenuItem[modul.vystupy.Count];
            for (int j = 0; j < modul.vystupy.Count; j++)
            {
                BodkaInfo vystup = modul.vystupy[j];
                level3[j] = new ToolStripMenuItem(modul.vystupy[j].meno, null, (sender2, e2) => vytvorIoOperaciu(sender2, e2, "out", vystup));
            }
            level2[1] = new ToolStripMenuItem(Projekt.DATABAZA["out"].text, null, level3);


            level1 = new ToolStripMenuItem("IO operácie", null, level2);
            contextMenuStrip.Items.Add(level1);

            //----------------------------------

            level2 = new ToolStripMenuItem[7];

            level2[0] = new ToolStripMenuItem(Projekt.DATABAZA["add"].text, null, (sender2, e2) => vytvorOperaciu(sender2, e2, "add"));
            level2[1] = new ToolStripMenuItem(Projekt.DATABAZA["sub"].text, null, (sender2, e2) => vytvorOperaciu(sender2, e2, "sub"));
            level2[2] = new ToolStripMenuItem(Projekt.DATABAZA["mul"].text, null, (sender2, e2) => vytvorOperaciu(sender2, e2, "mul"));
            level2[3] = new ToolStripMenuItem(Projekt.DATABAZA["div"].text, null, (sender2, e2) => vytvorOperaciu(sender2, e2, "div"));
            level2[4] = new ToolStripMenuItem(Projekt.DATABAZA["mod"].text, null, (sender2, e2) => vytvorOperaciu(sender2, e2, "mod"));
            level2[5] = new ToolStripMenuItem(Projekt.DATABAZA["inc"].text, null, (sender2, e2) => vytvorOperaciu(sender2, e2, "inc"));
            level2[6] = new ToolStripMenuItem(Projekt.DATABAZA["dec"].text, null, (sender2, e2) => vytvorOperaciu(sender2, e2, "dec"));

            level1 = new ToolStripMenuItem("Aritmetické operácie", null, level2);
            contextMenuStrip.Items.Add(level1);

            //----------------------------------

            level2 = new ToolStripMenuItem[6];

            level2[0] = new ToolStripMenuItem(Projekt.DATABAZA["bit_and"].text, null, (sender2, e2) => vytvorOperaciu(sender2, e2, "bit_and"));
            level2[1] = new ToolStripMenuItem(Projekt.DATABAZA["bit_or"].text, null, (sender2, e2) => vytvorOperaciu(sender2, e2, "bit_or"));
            level2[2] = new ToolStripMenuItem(Projekt.DATABAZA["bit_xor"].text, null, (sender2, e2) => vytvorOperaciu(sender2, e2, "bit_xor"));
            level2[3] = new ToolStripMenuItem(Projekt.DATABAZA["bit_not"].text, null, (sender2, e2) => vytvorOperaciu(sender2, e2, "bit_not"));
            level2[4] = new ToolStripMenuItem(Projekt.DATABAZA["shift_left"].text, null, (sender2, e2) => vytvorOperaciu(sender2, e2, "shift_left"));
            level2[5] = new ToolStripMenuItem(Projekt.DATABAZA["shift_right"].text, null, (sender2, e2) => vytvorOperaciu(sender2, e2, "shift_right"));

            level1 = new ToolStripMenuItem("Bitové operácie", null, level2);
            contextMenuStrip.Items.Add(level1);

            //----------------------------------

            level2 = new ToolStripMenuItem[3];

            level2[0] = new ToolStripMenuItem(Projekt.DATABAZA["log_and"].text, null, (sender2, e2) => vytvorOperaciu(sender2, e2, "log_and"));
            level2[1] = new ToolStripMenuItem(Projekt.DATABAZA["log_or"].text, null, (sender2, e2) => vytvorOperaciu(sender2, e2, "log_or"));
            level2[2] = new ToolStripMenuItem(Projekt.DATABAZA["log_not"].text, null, (sender2, e2) => vytvorOperaciu(sender2, e2, "log_not"));

            level1 = new ToolStripMenuItem("Logické operácie", null, level2);
            contextMenuStrip.Items.Add(level1);

            //----------------------------------

            level2 = new ToolStripMenuItem[6];

            level2[0] = new ToolStripMenuItem(Projekt.DATABAZA["gt"].text, null, (sender2, e2) => vytvorOperaciu(sender2, e2, "gt"));
            level2[1] = new ToolStripMenuItem(Projekt.DATABAZA["gteq"].text, null, (sender2, e2) => vytvorOperaciu(sender2, e2, "gteq"));
            level2[2] = new ToolStripMenuItem(Projekt.DATABAZA["lt"].text, null, (sender2, e2) => vytvorOperaciu(sender2, e2, "lt"));
            level2[3] = new ToolStripMenuItem(Projekt.DATABAZA["lteq"].text, null, (sender2, e2) => vytvorOperaciu(sender2, e2, "lteq"));
            level2[4] = new ToolStripMenuItem(Projekt.DATABAZA["eq"].text, null, (sender2, e2) => vytvorOperaciu(sender2, e2, "eq"));
            level2[5] = new ToolStripMenuItem(Projekt.DATABAZA["noteq"].text, null, (sender2, e2) => vytvorOperaciu(sender2, e2, "noteq"));

            level1 = new ToolStripMenuItem("Porovnávacie operácie", null, level2);
            contextMenuStrip.Items.Add(level1);

            //----------------------------------

            level2 = new ToolStripMenuItem[4];

            level2[0] = new ToolStripMenuItem(Projekt.DATABAZA["concat"].text, null, (sender2, e2) => vytvorOperaciu(sender2, e2, "concat"));
            level2[1] = new ToolStripMenuItem(Projekt.DATABAZA["reverse"].text, null, (sender2, e2) => vytvorOperaciu(sender2, e2, "reverse"));
            level2[2] = new ToolStripMenuItem(Projekt.DATABAZA["change"].text, null, (sender2, e2) => vytvorOperaciu(sender2, e2, "change"));
            level2[3] = new ToolStripMenuItem(Projekt.DATABAZA["if"].text, null, (sender2, e2) => vytvorOperaciu(sender2, e2, "if"));

            level1 = new ToolStripMenuItem("Ďalšie operácie", null, level2);
            contextMenuStrip.Items.Add(level1);

            //----------------------------------

            List <String> pole;

            if (modul.registre.Count > 0)
            {
                level2 = new ToolStripMenuItem[3];
                pole   = new List <String> {
                    "regC", "regZ", "regZ_index"
                };
                for (int i = 0; i < pole.Count; i++)
                {
                    String op = pole[i];
                    level3 = new ToolStripMenuItem[modul.registre.Count];
                    for (int j = 0; j < modul.registre.Count; j++)
                    {
                        RegisterInfo reg = modul.registre[j];
                        level3[j] = new ToolStripMenuItem(modul.registre[j].meno, null, (sender2, e2) => vytvorRegisterOperaciu(sender2, e2, op, reg));
                    }
                    level2[i] = new ToolStripMenuItem(Projekt.DATABAZA[pole[i]].text, null, level3);
                }

                level1 = new ToolStripMenuItem("Register", null, level2);
                contextMenuStrip.Items.Add(level1);
            }

            //----------------------------------

            pole = new List <String>();
            foreach (Modul m in projekt.moduly)
            {
                if (m.meno != "main" && modul != m)
                {
                    pole.Add(m.meno);
                }
            }

            if (pole.Count > 0)
            {
                level2 = new ToolStripMenuItem[pole.Count];
                for (int i = 0; i < pole.Count; i++)
                {
                    String f = pole[i];
                    level2[i] = new ToolStripMenuItem(Projekt.DATABAZA[pole[i]].text, null, (sender2, e2) => vytvorVolanieOperaciu(sender2, e2, f));
                }

                level1 = new ToolStripMenuItem("Vlastné moduly", null, level2);
                contextMenuStrip.Items.Add(level1);
            }
        }