Ejemplo n.º 1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="cont"></param>
        /// <returns></returns>
        public override TYPE_INFO TypeCheck(COMPILATION_CONTEXT cont)
        {
            if (m_proc != null)
            {
                _type = m_proc.TypeCheck(cont);
            }

            return(_type);
        }
Ejemplo n.º 2
0
        /// <summary>
        ///     Creates a new symbol and puts into the symbol table
        ///     and stores the key ( variable name )
        /// </summary>
        /// <param name="st"></param>
        /// <param name="name"></param>
        /// <param name="_value"></param>
        public Variable(COMPILATION_CONTEXT st, String name, string _value)
        {
            SYMBOL_INFO s = new SYMBOL_INFO();

            s.SymbolName = name;
            s.Type       = TYPE_INFO.TYPE_STRING;
            s.str_val    = _value;
            st.TABLE.Add(s);
            m_name = name;
        }
Ejemplo n.º 3
0
        /// <summary>
        ///     Creates a new symbol and puts into the symbol table
        ///     and stores the key ( variable name )
        /// </summary>
        /// <param name="st"></param>
        /// <param name="name"></param>
        /// <param name="_value"></param>
        public Variable(COMPILATION_CONTEXT st, String name, double _value)
        {
            SYMBOL_INFO s = new SYMBOL_INFO();

            s.SymbolName = name;
            s.Type       = TYPE_INFO.TYPE_NUMERIC;
            s.dbl_val    = _value;
            st.TABLE.Add(s);
            m_name = name;
        }
Ejemplo n.º 4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="local"></param>
        /// <param name="global"></param>
        /// <returns></returns>
        public override TYPE_INFO TypeCheck(COMPILATION_CONTEXT cont)
        {
            TYPE_INFO eval_left = exp1.TypeCheck(cont);


            if (eval_left == TYPE_INFO.TYPE_NUMERIC)
            {
                _type = eval_left;
                return(_type);
            }
            else
            {
                throw new Exception("Type mismatch failure");
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="cont"></param>
        /// <returns></returns>
        public override TYPE_INFO TypeCheck(COMPILATION_CONTEXT cont)
        {
            TYPE_INFO eval_left = ex1.TypeCheck(cont);


            if (
                eval_left == TYPE_INFO.TYPE_BOOL)
            {
                _type = TYPE_INFO.TYPE_BOOL;
                return(_type);
            }
            else
            {
                throw new Exception("Wrong Type in expression");
            }
        }
Ejemplo n.º 6
0
        /// <summary>
        ///     Look it up in the Symbol Table and
        ///     return the type
        /// </summary>
        /// <param name="local"></param>
        /// <param name="global"></param>
        /// <returns></returns>
        public override TYPE_INFO TypeCheck(COMPILATION_CONTEXT cont)
        {
            if (cont.TABLE == null)
            {
                return(TYPE_INFO.TYPE_ILLEGAL);
            }
            else
            {
                SYMBOL_INFO a = cont.TABLE.Get(m_name);
                if (a != null)
                {
                    _type = a.Type;
                    return(_type);
                }


                return(TYPE_INFO.TYPE_ILLEGAL);
            }
        }
Ejemplo n.º 7
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="cont"></param>
        /// <returns></returns>
        public override TYPE_INFO TypeCheck(COMPILATION_CONTEXT cont)
        {
            TYPE_INFO eval_left  = ex1.TypeCheck(cont);
            TYPE_INFO eval_right = ex2.TypeCheck(cont);

            // The Types should be Boolean...
            // Logical Operators only make sense
            // with Boolean Types

            if (eval_left == eval_right &&
                eval_left == TYPE_INFO.TYPE_BOOL)
            {
                _type = TYPE_INFO.TYPE_BOOL;
                return(_type);
            }
            else
            {
                throw new Exception("Wrong Type in expression");
            }
        }
Ejemplo n.º 8
0
 public ProcedureBuilder(string name, COMPILATION_CONTEXT _ctx)
 {
     ctx       = _ctx;
     proc_name = name;
 }
Ejemplo n.º 9
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="cont"></param>
 /// <returns></returns>
 public TYPE_INFO TypeCheck(COMPILATION_CONTEXT cont)
 {
     return(TYPE_INFO.TYPE_NUMERIC);
 }
Ejemplo n.º 10
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="local"></param>
 /// <param name="global"></param>
 /// <returns></returns>
 public override TYPE_INFO TypeCheck(COMPILATION_CONTEXT cont)
 {
     return(info.Type);
 }
Ejemplo n.º 11
0
 public abstract TYPE_INFO TypeCheck(COMPILATION_CONTEXT cont);