Пример #1
0
        public static ParsedField GetParsedField(string line)
        {
            Scope      scope;
            ParsedType type;
            string     variableName;
            bool       isConst;
            string     valueToAssignTo;
            bool       isVirtual;
            bool       isOverride;
            bool       isStatic;
            bool       isNew;
            bool       isAsync;


            ParsedMethod.GetLineInformation(line, out scope, out type, out variableName, out isConst, out isVirtual,
                                            out isOverride, out isStatic, out isNew, out isAsync, out valueToAssignTo);

            ParsedField parsedField = new ParsedField();

            parsedField.Scope           = scope;
            parsedField.Type            = type;
            parsedField.Name            = variableName;
            parsedField.IsConst         = isConst;
            parsedField.IsStatic        = isStatic;
            parsedField.ValueToAssignTo = valueToAssignTo;

            return(parsedField);
        }
Пример #2
0
        private void ParseField(string line)
        {
            ParsedField parsedField = GetParsedField(line);

            // todo: parsedField add attributes
            this.CurrentAttributes.Clear();
            mParsedFields.Add(parsedField);
        }
Пример #3
0
        public ParsedField Clone()
        {
            ParsedField newField = (ParsedField)this.MemberwiseClone();

            newField.Type = Type.Clone();

            return(newField);
        }
Пример #4
0
        internal static ParsedField FromFieldInfo(System.Reflection.FieldInfo field)
        {
            ParsedField toReturn = new ParsedField();
            toReturn.Name = field.Name;
            toReturn.Type = new ParsedType( field.FieldType.Name);
            toReturn.IsStatic = field.IsStatic;

            return toReturn;
        }
Пример #5
0
        internal static ParsedField FromFieldInfo(System.Reflection.FieldInfo field)
        {
            ParsedField toReturn = new ParsedField();

            toReturn.Name     = field.Name;
            toReturn.Type     = new ParsedType(field.FieldType.Name);
            toReturn.IsStatic = field.IsStatic;

            return(toReturn);
        }
Пример #6
0
        public ParsedField GetField(string fieldName)
        {
            foreach (ParsedField parsedField in mParsedFields)
            {
                if (parsedField.Name == fieldName)
                {
                    return(parsedField);
                }
            }

            foreach (ParsedClass parentClass in mParentParsedClasses)
            {
                ParsedField parsedField = parentClass.GetField(fieldName);

                if (parsedField != null)
                {
                    return(parsedField);
                }
            }

            return(null);
        }
Пример #7
0
        public static ParsedClass FromType(Type type)
        {
            ParsedClass toReturn = new ParsedClass();

            var fieldInfos = type.GetFields();

            foreach (var field in fieldInfos)
            {
                ParsedField parsedField = ParsedField.FromFieldInfo(field);

                toReturn.ParsedFields.Add(parsedField);
            }

            var propertyInfos = type.GetProperties();

            foreach (var property in propertyInfos)
            {
                ParsedProperty parsedProperty = ParsedProperty.FromPropertyInfo(property);

                toReturn.ParsedProperties.Add(parsedProperty);
            }

            return(toReturn);
        }
Пример #8
0
        internal void FillArgumentList(ParsedMethod parsedMethod, List <string> currentBlock, int lineIndex, bool requireTypes)
        {
            int  wordIndex                 = 0;
            int  parenthesisDeep           = 0;
            bool hasFoundClosedParenthesis = false;

            ParsedField argumentToAddTo = null;

            while (!hasFoundClosedParenthesis)
            {
                string line = currentBlock[lineIndex];

                wordIndex = 0;

                string currentType = null;

                while (true)
                {
                    string word = ParsedClass.GetWord(line, ref wordIndex);

                    if (word == "(")
                    {
                        if (argumentToAddTo != null)
                        {
                            argumentToAddTo.Name += word;
                        }

                        parenthesisDeep++;
                    }
                    else if (word == ")")
                    {
                        parenthesisDeep--;


                        if (parenthesisDeep == 0)
                        {
                            hasFoundClosedParenthesis = true;
                            break;
                        }
                        else if (argumentToAddTo != null)
                        {
                            argumentToAddTo.Name += word;
                        }
                    }
                    else if (word == "")
                    {
                        lineIndex++;
                        break;
                    }
                    else if (parenthesisDeep == 0)
                    {
                        continue;
                    }
                    else if (word == ",")
                    {
                        argumentToAddTo = null;
                        continue;
                    }
                    else if (currentType == null && requireTypes)
                    {
                        currentType = word;
                    }
                    else
                    {
                        ParsedField parsedField = new ParsedField(Scope.Public, currentType, word);
                        currentType = null;

                        parsedMethod.ArgumentList.Add(parsedField);

                        argumentToAddTo = parsedField;
                    }
                }
            }
        }
Пример #9
0
        public static ParsedField GetParsedField(string line)
        {
            Scope scope;
            ParsedType type;
            string variableName;
            bool isConst;
            string valueToAssignTo;
            bool isVirtual;
            bool isOverride;
            bool isStatic;
            bool isNew;
            bool isAsync;


            ParsedMethod.GetLineInformation(line, out scope, out type, out variableName, out isConst, out isVirtual,
                out isOverride, out isStatic, out isNew, out isAsync, out valueToAssignTo);

            ParsedField parsedField = new ParsedField();
            parsedField.Scope = scope;
            parsedField.Type = type;
            parsedField.Name = variableName;
            parsedField.IsConst = isConst;
            parsedField.IsStatic = isStatic;
            parsedField.ValueToAssignTo = valueToAssignTo;

            return parsedField;
        }
Пример #10
0
        internal void FillArgumentList(ParsedMethod parsedMethod, List<string> currentBlock, int lineIndex, bool requireTypes)
        {
            int wordIndex = 0;
            int  parenthesisDeep = 0;
            bool hasFoundClosedParenthesis = false;

            ParsedField argumentToAddTo = null;

            while (!hasFoundClosedParenthesis)
            {
                string line = currentBlock[lineIndex];

                wordIndex = 0;

                string currentType = null;

                while (true)
                {
                    string word = ParsedClass.GetWord(line, ref wordIndex);

                    if (word == "(")
                    {
                        if (argumentToAddTo != null)
                        {
                            argumentToAddTo.Name += word;
                        }

                        parenthesisDeep++;
                    }
                    else if (word == ")")
                    {
                        parenthesisDeep--;


                        if (parenthesisDeep == 0)
                        {
                            hasFoundClosedParenthesis = true;
                            break;
                        }
                        else if (argumentToAddTo != null)
                        {
                            argumentToAddTo.Name += word;
                        }

                        
                    }
                    else if (word == "")
                    {
                        lineIndex++;
                        break;
                    }
                    else if (parenthesisDeep == 0)
                    {
                        continue;
                    }
                    else if (word == ",")
                    {
                        argumentToAddTo = null;
                        continue;
                    }
                    else if (currentType == null && requireTypes)
                    {
                        currentType = word;
                    }
                    else
                    {
                        ParsedField parsedField = new ParsedField(Scope.Public, currentType, word);
                        currentType = null;

                        parsedMethod.ArgumentList.Add(parsedField);

                        argumentToAddTo = parsedField;
                    }

                }
            }
        }