示例#1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="cont"></param>
        /// <returns></returns>
        public override bool Compile(DNET_EXECUTABLE_GENERATION_CONTEXT cont)
        {
            if (m_formals != null)
            {
                int i = 0;

                foreach (SYMBOL_INFO b in m_formals)
                {
                    System.Type type = (b.Type == TYPE_INFO.TYPE_BOOL) ?
                                       typeof(bool) : (b.Type == TYPE_INFO.TYPE_NUMERIC) ?
                                       typeof(double) : typeof(string);
                    int s = cont.DeclareLocal(type);
                    b.loc_position = s;
                    cont.TABLE.Add(b);
                    cont.CodeOutput.Emit(OpCodes.Ldarg, i);
                    cont.CodeOutput.Emit(OpCodes.Stloc, cont.GetLocal(s));
                    i++;
                }
            }


            foreach (Stmt e1 in m_statements)
            {
                e1.Compile(cont);
            }

            cont.CodeOutput.Emit(OpCodes.Ret);
            return(true);
        }
示例#2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="cont"></param>
        /// <returns></returns>
        public override bool Compile(DNET_EXECUTABLE_GENERATION_CONTEXT cont)
        {
            //
            // Retrieve the type from the SYMBOL_INFO
            //
            System.Type type = (m_inf.Type == TYPE_INFO.TYPE_BOOL) ?
                               typeof(bool) : (m_inf.Type == TYPE_INFO.TYPE_NUMERIC) ?
                               typeof(double) : typeof(string);
            //
            //  Get the offset of the variable
            //
            int s = cont.DeclareLocal(type);

            // Store the offset in the SYMBOL_INFO
            //
            m_inf.loc_position = s;
            //
            // Add the variable into Symbol Table..
            //
            cont.TABLE.Add(m_inf);

            return(true);
        }