/// <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); }
/// <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; }
/// <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; }
/// <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"); } }
/// <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"); } }
/// <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); } }
/// <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"); } }
public ProcedureBuilder(string name, COMPILATION_CONTEXT _ctx) { ctx = _ctx; proc_name = name; }
/// <summary> /// /// </summary> /// <param name="cont"></param> /// <returns></returns> public TYPE_INFO TypeCheck(COMPILATION_CONTEXT cont) { return(TYPE_INFO.TYPE_NUMERIC); }
/// <summary> /// /// </summary> /// <param name="local"></param> /// <param name="global"></param> /// <returns></returns> public override TYPE_INFO TypeCheck(COMPILATION_CONTEXT cont) { return(info.Type); }
public abstract TYPE_INFO TypeCheck(COMPILATION_CONTEXT cont);