Ejemplo n.º 1
0
 public InOut(int op, string varOut, SymbolTable _st, Dictionary <int, string> dict)
 {
     this.varOut  = varOut;
     this.op      = op;
     this.oper    = dict[op];
     this.typeOut = Cube.getInstance().outputCube(_st.getType(varOut), _st.getType(varOut), op, dict);
 }
Ejemplo n.º 2
0
 public Assign(int op, string varA, string varOut, SymbolTable _st, Dictionary <int, string> dict)
 {
     this.varA    = varA;
     this.varOut  = varOut;
     this.dirA    = _st.getDir(varA);
     this.op      = op;
     this.oper    = dict[op];
     this.typeOut = Cube.getInstance().outputCube(_st.getType(varA), _st.getType(varOut), op, dict);
 }
Ejemplo n.º 3
0
Archivo: Goto.cs Proyecto: rbtote/AGRO
 public Goto(int typeGoto, string varCond, SymbolTable _st, Dictionary <int, string> dict)
 {
     this.typeGoto = typeGoto;
     this.oper     = dict[typeGoto];
     if (typeGoto != 68) //68 is plain goto
     {
         this.varCond    = varCond;
         this.dirVarCond = _st.getDir(varCond);
         this.valid      = Cube.getInstance().outputCube(_st.getType(varCond), 1, 17, dict); //The variable received with int(1) equals(17)
     }
     //this.direction = direction;
 }
Ejemplo n.º 4
0
        public void countVars(SymbolTable st)
        {
            foreach (string key in st.symbols.Keys)
            {
                // TYPES:   t_int = 1, t_float = 2, t_char = 3, t_void = 4 ,t_obj = 5, t_string = 6
                // KINDS:   var = 0, func = 1, temporal = 2, pointer = 3

                int dims = 1;

                if (st.getDim1(key) != 0)
                {
                    if (st.getDim2(key) != 0)
                    {
                        dims = st.getDim1(key) * st.getDim2(key);
                    }
                    else
                    {
                        dims = st.getDim1(key);
                    }
                }

                switch (st.getType(key))
                {
                // INT
                case 1:
                    switch (st.getKind(key))
                    {
                    // VAR
                    case 0:
                    // FUNC
                    case 1:
                        intCount += dims;
                        break;

                    // VAR TEMP
                    case 2:
                        intTempCount += dims;
                        break;

                    // POINTER
                    case 3:
                        pointerCount += dims;
                        break;
                    }
                    break;

                // FLOAT
                case 2:
                    switch (st.getKind(key))
                    {
                    // VAR
                    case 0:
                    // FUNC
                    case 1:
                        floatCount += dims;
                        break;

                    // VAR TEMP
                    case 2:
                        floatTempCount += dims;
                        break;

                    // POINTER
                    case 3:
                        pointerCount += dims;
                        break;
                    }
                    break;

                // CHAR
                case 3:
                    switch (st.getKind(key))
                    {
                    // VAR
                    case 0:
                    // FUNC
                    case 1:
                        charCount += dims;
                        break;

                    // VAR TEMP
                    case 2:
                        charTempCount += dims;
                        break;

                    // POINTER
                    case 3:
                        pointerCount += dims;
                        break;
                    }
                    break;

                // STRING
                case 6:
                    switch (st.getKind(key))
                    {
                    // VAR
                    case 0:
                    // FUNC
                    case 1:
                        stringCount += dims;
                        break;

                    // VAR TEMP
                    case 2:
                        stringTempCount += dims;
                        break;

                    // POINTER
                    case 3:
                        pointerCount += dims;
                        break;
                    }
                    break;
                }
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Sets to the class in the dirClasse the values of the symbolTable
        /// </summary>
        /// <param name="st">The symbol table of the class</param>
        public void setClassVars(SymbolTable st)
        {
            foreach (string key in st.symbols.Keys)
            {
                // TYPES:   t_int = 1, t_float = 2, t_char = 3, t_void = 4 ,t_obj = 5, t_string = 6
                // KINDS:   var = 0, func = 1
                // ACCESS:  public = 1, private = -1
                //              [type, kind, dir, dim1?0, dim2?0, access:[-1|1]]

                symbolsClass[key] = st.getSymbol(key);

                // Omit func allocation
                if (st.symbols[key][1] == 1)
                {
                    continue;
                }

                int dims = 1;

                if (st.getDim1(key) != 0)
                {
                    if (st.getDim2(key) != 0)
                    {
                        dims = st.getDim1(key) * st.getDim2(key);
                    }
                    else
                    {
                        dims = st.getDim1(key);
                    }
                }



                switch (st.getType(key))
                {
                // INT
                case 1:
                    intCount += dims;
                    break;

                // FLOAT
                case 2:
                    floatCount += dims;
                    break;

                // CHAR
                case 3:
                    charCount += dims;
                    break;

                // VOID
                case 4:
                    break;

                // STRING
                case 6:
                    stringCount += dims;
                    break;
                }
            }
        }