예제 #1
0
        public void AddClass(TempClass value)
        {
            if (this.Classes == null)
            {
                this.Classes = new List<TempClass>();
            }

            this.Classes.Add(value);
        }
예제 #2
0
        private SharpClass CompileClass(CompilationData data, TempClass @class)
        {
            var result = new SharpClass { Name = @class.Name };

            switch (@class.ClassType)
            {
                case TempClassType.Interface:
                    {
                        result.IsInterface = true;
                        break;
                    }

                case TempClassType.Class:
                    {
                        break;
                    }

                default:
                    {
                        throw new NotImplementedException();
                    }
            }

            // Get the attributes from the intermediate
            IList<TempAttribute> attributes = this.GetAttributes(@class.Attributes);

            // Ensure the class has an accessor, public is default
            if (!attributes.Contains(TempAttribute.Private) && !attributes.Contains(TempAttribute.Protected)
                && !attributes.Contains(TempAttribute.Public))
            {
                attributes.Add(TempAttribute.Public);
            }

            // Compile the info and add it to the result
            result.Attributes = this.CompileClassAttributeString(attributes);
            if (@class.Extends != null)
            {
                result.Inheritance = this.CompileClassInheritanceString(data, @class.Extends);
            }

            if (@class.Inherits != null)
            {
                result.Interfaces = this.CompileClassInheritanceString(data, @class.Inherits);
            }

            return result;
        }
예제 #3
0
        private void TranslateTempFileContent(TranslationData data, TempFileFull fileData)
        {
            int tokenStart = data.CurrentToken;
            TranslationDataIterator iterator = data.GetIterator();
            Token token;
            TempClass contentData = null;
            while (iterator.Next(out token))
            {
                if (token.Term.Type != TermType.IdentifierKey && token.Term.Type != TermType.Key)
                {
                    continue;
                }

                JavaTermKey key = this.GetTermKey(token);
                switch (key)
                {
                    case JavaTermKey.Class:
                    case JavaTermKey.Interface:
                    case JavaTermKey.Enum:
                        {
                            contentData = new TempClass();
                            break;
                        }

                    case JavaTermKey.BraceRight:
                        {
                            return;
                        }
                }

                if (contentData != null)
                {
                    break;
                }
            }

            if (contentData != null)
            {
                data.CurrentToken = tokenStart;
                data.TranslationStack.Push(contentData);
                fileData.AddClass(contentData);
                return;
            }

            throw new InvalidDataException("Unexpected token list: ");
        }