コード例 #1
0
ファイル: Parser.cs プロジェクト: ahochha/java-compiler
        /// <summary>
        /// MethodDecl -> PublicT Type IdT ( FormalList ) {
        ///                   VarDecl SeqOfStatements ReturnT Expr ;
        ///               } |
        ///               ε
        /// </summary>
        private void MethodDecl()
        {
            ITableEntry Eplace = null;

            if (Token == Tokens.PublicT)
            {
                Match(Tokens.PublicT);
                Type();
                TypeReturn = TypeVar;
                TableEntry entry = symbolTable.CreateTableEntry();
                MethodNames.Add(Lexeme);
                tacGenerator.GenerateLineOfTAC($"proc {entry.lexeme}");
                Match(Tokens.IdT);
                Depth++;
                ResetMethodGlobals();
                Match(Tokens.LParenT);
                ParameterVarsSize = 4;
                FormalList();
                Offset = 2;
                tacGenerator.tempVarOffset = 2;
                Match(Tokens.RParenT);
                Match(Tokens.LBraceT);
                VarDecl();
                SeqOfStatements();
                Match(Tokens.ReturnT);
                Expr(ref Eplace);

                if (Eplace != null && Eplace.bpOffsetName != "")
                {
                    tacGenerator.GenerateLineOfTAC($"_ax = {Eplace.bpOffsetName}");
                }

                Match(Tokens.SemiT);
                symbolTable.ConvertEntryToMethod(entry);
                symbolTable.DeleteDepth(Depth);
                tacGenerator.GenerateLineOfTAC($"endp {entry.lexeme}");
                tacGenerator.GenerateLineOfTAC("");
                Depth--;
                Match(Tokens.RBraceT);
                MethodDecl();
            }
        }
コード例 #2
0
ファイル: Parser.cs プロジェクト: ahochha/java-compiler
        /// <summary>
        /// MainClass -> FinalT ClassT IdT {
        ///                 PublicT StaticT VoidT MainT ( StringT [ ] IdT ) {
        ///                     SeqOfStatements
        ///                 }
        ///              }
        /// </summary>
        private void MainClass()
        {
            Match(Tokens.FinalT);
            Match(Tokens.ClassT);
            TableEntry finalClassEntry = symbolTable.CreateTableEntry();

            Match(Tokens.IdT);
            Depth++;
            ResetClassGlobals();
            Match(Tokens.LBraceT);
            Match(Tokens.PublicT);
            Match(Tokens.StaticT);
            Match(Tokens.VoidT);
            TypeReturn = VarType.voidType;
            TableEntry mainEntry = symbolTable.CreateTableEntry();

            MethodNames.Add(Lexeme);
            tacGenerator.GenerateLineOfTAC("proc main");
            AssemblyFile.mainName = Lexeme;
            Match(Tokens.MainT);
            Depth++;
            ResetMethodGlobals();
            Match(Tokens.LParenT);
            Match(Tokens.StringT);
            Match(Tokens.LBrackT);
            Match(Tokens.RBrackT);
            Match(Tokens.IdT);
            Match(Tokens.RParenT);
            Match(Tokens.LBraceT);
            SeqOfStatements();
            tacGenerator.GenerateLineOfTAC("endp main");
            ParameterVarsSize = 4;
            symbolTable.ConvertEntryToMethod(mainEntry);
            symbolTable.DeleteDepth(Depth);
            Depth--;
            Match(Tokens.RBraceT);
            symbolTable.ConvertEntryToClass(finalClassEntry);
            symbolTable.DeleteDepth(Depth);
            Depth--;
            Match(Tokens.RBraceT);
        }
コード例 #3
0
        /// <summary>
        /// Get all methods in a class based on Key
        /// </summary>
        /// <param name="T">Key : Type of class</param>
        public virtual void GetMethodNames(IExpireHelper type)
        {
            Type T = type.GetType();
            Dictionary <int, string> methodDict = new Dictionary <int, string>();

            MethodInfo[] methods = T.GetMethods();

            if (!MethodNames.ContainsKey(T) || type.Expire)
            {
                for (ushort i = 0; i < methods.Length; i++)
                {
                    methodDict.Add(i, methods[i].Name);
                }
            }

            if (!MethodNames.ContainsKey(T))
            {
                MethodNames.Add(T, methodDict);
            }
            else if (methodDict.Count > 0)
            {
                MethodNames[T] = methodDict;
            }
        }
コード例 #4
0
 /// <summary>
 /// Fors the method.
 /// </summary>
 /// <param name="methodName">Name of the method.</param>
 /// <returns></returns>
 public InjectableMethodBuilder ForMethod(string methodName)
 {
     return(new InjectableMethodBuilder(Container.AsType(), MethodNames.Add(methodName)));
 }
コード例 #5
0
 /// <summary>
 /// Fors the method.
 /// </summary>
 /// <param name="methodName">Name of the method.</param>
 /// <returns></returns>
 public InjectableMethodBuilder <T, T2, T3, T4, T5, T6, T7, T8, T9> ForMethod(string methodName)
 {
     return(new InjectableMethodBuilder <T, T2, T3, T4, T5, T6, T7, T8, T9>(Container, MethodNames.Add(methodName)));
 }
コード例 #6
0
        public Step(Plugin plugin, Messages message, Stages stage, Modes mode, string entityName, string methodName, params string[] columns)
            : this(plugin, message, stage, mode, entityName)
        {
            Method = plugin.GetType().GetMethod(methodName);

            if (Method != null)
            {
                MethodNames.Add(Method.Name);

                var filteringAttributes = Method.GetCustomAttribute <FilteringAttributesAttribute>();
                if (filteringAttributes != null)
                {
                    _filteringAttributes.AddRange(filteringAttributes.Attributes);
                }
                else if (columns != null)
                {
                    _filteringAttributes.AddRange(columns);
                }

                var preImageAttribute = Method.GetCustomAttribute <PreImageAttribute>();
                if (preImageAttribute != null)
                {
                    _preImageAllAttributes = preImageAttribute.AllColumns;
                    if (!_preImageAllAttributes)
                    {
                        _preImageAttributes.AddRange(preImageAttribute.Columns);
                    }
                }
                else if (columns != null)
                {
                    _preImageAttributes.AddRange(columns);
                }

                var postImageAttribute = Method.GetCustomAttribute <PostImageAttribute>();
                if (postImageAttribute != null)
                {
                    _postImageAllAttributes = postImageAttribute.AllColumns;
                    if (!_postImageAllAttributes)
                    {
                        _postImageAttributes.AddRange(postImageAttribute.Columns);
                    }
                }
                else if (columns != null)
                {
                    _postImageAttributes.AddRange(columns);
                }

                var executionOrderAttribute = Method.GetCustomAttribute <ExecutionOrderAttribute>();
                if (executionOrderAttribute != null)
                {
                    Order = executionOrderAttribute.Order;
                }

                var impersonationUserAttribute = Method.GetCustomAttribute <ImpersonationAttribute>();
                if (impersonationUserAttribute != null)
                {
                    ImpersonationUsername = impersonationUserAttribute.ImpersonationUsername;
                }

                var unsecureConfigAttribute = Method.GetCustomAttribute <UnsecureConfigAttribute>();
                if (unsecureConfigAttribute != null)
                {
                    if (!string.IsNullOrEmpty(unsecureConfigAttribute.UnsecureConfig))
                    {
                        UnsecureConfig = unsecureConfigAttribute.UnsecureConfig;
                    }
                    else
                    {
                        var resourceType = unsecureConfigAttribute.ResourceType;

                        UnsecureConfig = resourceType.GetProperty(unsecureConfigAttribute.PropertyName).GetValue(null) as string;
                    }
                }
            }
        }
コード例 #7
0
 /// <summary>
 /// Fors the method.
 /// </summary>
 /// <param name="methodName">Name of the method.</param>
 /// <returns></returns>
 public InjectableMethodBuilder <T> ForMethod(string methodName)
 {
     return(new InjectableMethodBuilder <T>(Container, MethodNames.Add(methodName)));
 }