Esempio n. 1
0
        protected override Ast.Expression MapMemberAccess(MemberExpression me)
        {
            var glfield = me.Member.GetAttribute <GLFieldAttribute> ();

            if (glfield != null)
            {
                return(Ast.FRef(Expr(me.Expression), Ast.Fld(glfield.Name)));
            }
            var syntax = me.Member.GetGLSyntax();

            if (syntax != null)
            {
                return(Ast.Call(syntax, Expr(me.Expression)));
            }
            if (me.Member.IsBuiltin())
            {
                return(me.Expression.Type.IsGLType() ?
                       Ast.FRef(Expr(me.Expression), Ast.Fld(me.Member.Name)) :
                       (Ast.Expression)Ast.VRef(Ast.Fld(me.Member.Name)));
            }
            var declType = me.Expression.Type;

            if (declType.IsGLStruct())
            {
                MapType(declType);
                var astruct = (Ast.Structure)_globals[declType.Name];
                var field   = astruct.Fields.Find(f => f.Name == me.Member.Name);
                return(Ast.FRef(Expr(me.Expression), field));
            }
            return(base.MapMemberAccess(me));
        }
Esempio n. 2
0
        protected override Ast.Expression MapMemberAccess(MemberExpression me)
        {
            var clfield = me.Member.GetAttribute <CLFieldAttribute> ();

            if (clfield != null)
            {
                return(Ast.FRef(Expr(me.Expression), Ast.Fld(clfield.Name)));
            }
            var syntax = me.Member.GetCLSyntax();

            if (syntax != null)
            {
                return(Ast.Call(syntax, Expr(me.Expression)));
            }
            var declType = me.Expression.Type;

            if (declType.IsCLStruct() || declType.IsCLUnion())
            {
                MapType(declType);
                var astruct = (Ast.Structure)_globals[StructTypeName(declType)];
                var field   = astruct.Fields.Find(f => f.Name == me.Member.Name);
                return(Ast.FRef(Expr(me.Expression), field));
            }
            if (declType.IsSubclassOf(typeof(ArgGroup)))
            {
                var          argName = ArgGroupMemberName(me);
                Ast.Variable v       = _currentScope.FindLocalVar(argName);
                if (v == null)
                {
                    throw new ParseException("Group argument not defined: " + argName);
                }
                return(Ast.VRef(v));
            }
            return(base.MapMemberAccess(me));
        }