/// <summary> /// Create an instance of Symbol Table /// </summary> public RUNTIME_CONTEXT(TModule Pgrm) { m_dt = new SymbolTable(); _prog = Pgrm; }
/// <summary> /// /// </summary> /// <param name="cont"></param> /// <returns></returns> public override SYMBOL_INFO Evaluate(RUNTIME_CONTEXT cont) { if (m_proc != null) { // // This is a Ordinary Function Call // // RUNTIME_CONTEXT ctx = new RUNTIME_CONTEXT(cont.GetProgram()); ArrayList lst = new ArrayList(); //TYPE_INFO clsrcall; foreach (Exp ex in m_actuals) { lst.Add(ex.Evaluate(cont)); } SymbolTable x = cont.TABLE; ///for closure function /// use the previous/saved the symbol table(context) when the clouser function call for the second time :) if (m_proc.clossure != null) { TModule.ClosureSymbol++; // for the function(variable) closure function if (TModule.ClosureSymbol < 2 || TModule.PrewFun != m_proc.Name) { //if (m_proc.IsVariable == true && (TModule.ClosureSymbol >= 2)) //{ return m_proc.clossure.Execute(Procedure.ClosureMentain, lst); } Procedure.ClosureMentain = ctx; m_proc.Execute(ctx, lst); TModule.PrewFun = m_proc.Name; return(m_proc.clossure.Execute(ctx, lst)); } TModule.PrewFun = m_proc.Name; return(m_proc.clossure.Execute(Procedure.ClosureMentain, lst)); //} //else // return m_proc.clossure.Execute(ctx, lst); } return(m_proc.Execute(ctx, lst)); } else { // Recursive function call...by the time we // reach here..whole program has already been // parsed. Lookup the Function name table and // resolve the Address // // m_proc = cont.GetProgram().Find(_procname); // note GetProgram() return the module RUNTIME_CONTEXT ctx = new RUNTIME_CONTEXT(cont.GetProgram()); ArrayList lst = new ArrayList(); foreach (Exp ex in m_actuals) { lst.Add(ex.Evaluate(cont)); } return(m_proc.Execute(ctx, lst)); } }
/// <summary> /// Create an instance of Symbol Table /// </summary> public COMPILATION_CONTEXT() { m_dt = new SymbolTable(); }