예제 #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);
        }
예제 #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;
        }
예제 #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;
        }
예제 #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");
            }
        }
예제 #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");
            }
        }
예제 #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);
            }
        }
예제 #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");
            }
        }
예제 #8
0
파일: Builder.cs 프로젝트: Zenith89/FunWap
 public ProcedureBuilder(string name, COMPILATION_CONTEXT _ctx)
 {
     ctx       = _ctx;
     proc_name = name;
 }
예제 #9
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="cont"></param>
 /// <returns></returns>
 public TYPE_INFO TypeCheck(COMPILATION_CONTEXT cont)
 {
     return(TYPE_INFO.TYPE_NUMERIC);
 }
예제 #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);
 }
예제 #11
0
 public abstract TYPE_INFO TypeCheck(COMPILATION_CONTEXT cont);