public static PostfixOperator Create(Expression expression, string symbol, Type.Expression type = null)
        {
            PostfixOperator result;

            switch (symbol)
            {
            default:
                result = null;
                break;

            case "++":
            case "--":
                result = new PostfixOperator(expression, symbol, type);
                break;
            }
            return(result);
        }
Beispiel #2
0
            public static BinaryConvertResult PostfixConvertResult(Expression lop, Expression rop,
                                                                   PostfixOperator op)
            {
                BinaryConvertResult res = new BinaryConvertResult();

                switch (op)
                {
                case PostfixOperator.REF:
                case PostfixOperator.DOT:
                    Symbols.Type t = lop.GetType() is Symbols.POINTER && op == PostfixOperator.REF?
                                     ((Symbols.POINTER)lop.GetType()).GetRefType() : lop.GetType();

                    if (!(t is Symbols.RECORD))
                    {
                        throw new Symbols.Exception(lop, NOT_STRUCT);
                    }

                    if (!((Symbols.RECORD)t).GetTable().ContainsVariable(((Identifier)rop).GetName()))
                    {
                        throw new Symbols.Exception(rop,
                                                    string.Format(NOT_MEMBER, ((Identifier)rop).GetName(), t.GetName())
                                                    );
                    }
                    res.lvalue = true;
                    res.type   = (((Symbols.RECORD)t).GetTable().GetVariable(((Identifier)rop).GetName())).GetType();
                    break;

                case PostfixOperator.INDEX:
                    if (!(lop.GetType() is Symbols.POINTER))
                    {
                        throw new Symbols.Exception(lop, NOT_POINTER);
                    }
                    if (!rop.GetType().IsInteger())
                    {
                        throw new Symbols.Exception(rop, NOT_INTEGER);
                    }
                    res.lvalue = true;
                    res.type   = ((Symbols.RefType)lop.GetType()).GetRefType();
                    break;
                }

                res.left  = lop;
                res.right = rop;
                return(res);
            }
 public virtual void Visit(PostfixOperator unaryOperator)
 {
     Visit(( dynamic )(unaryOperator));
 }
Beispiel #4
0
            public static BinaryConvertResult PostfixConvertResult(Expression lop, Expression rop,
				PostfixOperator op)
            {
                BinaryConvertResult res = new BinaryConvertResult();

                switch (op)
                {
                    case PostfixOperator.REF:
                    case PostfixOperator.DOT:
                        Symbols.Type t = lop.GetType() is Symbols.POINTER && op == PostfixOperator.REF?
                            ((Symbols.POINTER)lop.GetType()).GetRefType() : lop.GetType();

                        if (!(t is Symbols.RECORD))
                        {
                            throw new Symbols.Exception(lop, NOT_STRUCT);
                        }

                        if (!((Symbols.RECORD)t).GetTable().ContainsVariable(((Identifier)rop).GetName()))
                        {
                            throw new Symbols.Exception(rop,
                                string.Format(NOT_MEMBER, ((Identifier)rop).GetName(), t.GetName())
                            );
                        }
                        res.lvalue = true;
                        res.type = (((Symbols.RECORD)t).GetTable().GetVariable(((Identifier)rop).GetName())).GetType();
                        break;
                    case PostfixOperator.INDEX:
                        if (!(lop.GetType() is Symbols.POINTER))
                        {
                            throw new Symbols.Exception(lop, NOT_POINTER);
                        }
                        if (!rop.GetType().IsInteger())
                        {
                            throw new Symbols.Exception(rop, NOT_INTEGER);
                        }
                        res.lvalue = true;
                        res.type = ((Symbols.RefType)lop.GetType()).GetRefType();
                        break;
                }

                res.left = lop;
                res.right = rop;
                return res;
            }