예제 #1
0
        public TAttribute readAttribute()
        {
            string name  = currentToken.value;
            string value = null;

            getNextToken();
            if (currentToken.token == ECodeToken.blEquals)
            {
                getNextToken();
                if (name == "NamedConstructor")
                {
                    var ctorName = currentToken.value;
                    var mem      = new TMethod(currentInterfaceType);
                    mem.name       = "ctor";
                    mem.aliasName  = ctorName;
                    mem.resultType = new TType()
                    {
                        name = "void"
                    };
                    getNextToken();
                    if (currentToken.token == ECodeToken.brBraceBegin)
                    {
                        readParameters(mem);
                    }
                    return(new TConstructorAttribute(mem)
                    {
                        name = ctorName
                    });
                }
                value = currentToken.value; //TODO
                getNextToken();
                return(new TNameAttribute()
                {
                    name = name, value = value
                });
            }

            if (name == "Constructor")
            {
                var mem = new TMethod(currentInterfaceType);
                mem.name       = "ctor";
                mem.resultType = new TType()
                {
                    name = "void"
                };
                if (currentToken.token == ECodeToken.brBraceBegin)
                {
                    readParameters(mem);
                }
                return(new TConstructorAttribute(mem));
            }

            if (currentToken.token == ECodeToken.brBraceBegin)
            {
            }

            return(new TNameAttribute()
            {
                name = name
            });
        }
예제 #2
0
 public TConstructorAttribute(TMethod constructor)
 {
     this.constructor = constructor;
 }
예제 #3
0
        private TMember readMember()
        {
            bool    vStatic    = false;
            bool    vConst     = false;
            bool    vFinal     = false;
            bool    vReadonly  = false;
            bool    vAttribute = false;
            TType   type       = null;
            string  name       = "";
            TMember mem        = null;
            var     attrList   = new TAttributeList();

            while (true)
            {
                switch (currentToken.token)
                {
                case ECodeToken.brSmallBraceBegin:
                    attrList = readAttributes();
                    break;

                case ECodeToken.kwStatic:
                    vStatic = true;
                    getNextToken();
                    break;

                case ECodeToken.kwConst:
                    vConst = true;
                    getNextToken();
                    break;

                case ECodeToken.kwAttribute:
                    vAttribute = true;
                    getNextToken();
                    break;

                case ECodeToken.kwReadonly:
                    vReadonly = true;
                    getNextToken();
                    break;

                //case ECodeToken.kwFinal:
                //  vFinal = true;
                //  break;
                case ECodeToken.ltString:
                    type = readType();
                    name = currentToken.value;

                    getNextToken();
                    if (currentToken.token == ECodeToken.brBraceBegin)
                    {
                        mem            = new TMethod(currentInterfaceType);
                        mem.name       = name;
                        mem.resultType = type;
                        mem.attributes = attrList;
                        readParameters((TMethod)mem);
                        checkGotoEndOfStatement();
                    }
                    else
                    {
                        if (vAttribute)
                        {
                            mem            = new TProperty(currentInterfaceType);
                            mem.name       = name;
                            mem.resultType = type;
                            mem.attributes = attrList;
                            checkGotoEndOfStatement();
                            return(mem);
                        }
                        else
                        {
                            mem            = new TField(currentInterfaceType);
                            mem.name       = name;
                            mem.resultType = type;
                            mem.attributes = attrList;
                            if (currentToken.token == ECodeToken.blEquals)
                            {
                                getNextToken();
                                string Value = currentToken.value;
                                getNextToken();
                                if (currentToken.token == ECodeToken.ltString)
                                {
                                    Value += currentToken.value;
                                    if (Value.ToLower() == "0xffffffff")
                                    {
                                        Value = "0xFFFFFFF";
                                    }
                                }
                                ((TField)mem).value = Value;
                            }
                            return(mem);
                        }
                    }
                    break;

                default:
                    getNextToken();
                    break;
                }
                if (currentToken.token == ECodeToken.syEndOfCommand)
                {
                    break;
                }
            }
            return(mem);
        }