Example #1
0
 public AstObjectCreation(string file, int line, int col, AstTypeExpr type)
     : base(file, line, col)
 {
     if (type == null)
         throw new ArgumentNullException("type");
     _typeExpr = type;
     _proxy = new ArgumentsProxy(_arguments);
 }
Example #2
0
 public AstTypecast(string file, int line, int column, AstExpr subject, AstTypeExpr type)
     : base(file, line, column)
 {
     if (subject == null)
         throw new ArgumentNullException("subject");
     if (type == null)
         throw new ArgumentNullException("type");
     Subject = subject;
     Type = type;
 }
Example #3
0
 public AstGetSetStatic(
     string file, int line, int col, PCall call, AstTypeExpr typeExpr, string memberId)
     : base(file, line, col, call)
 {
     if (typeExpr == null)
         throw new ArgumentNullException("typeExpr");
     if (memberId == null)
         throw new ArgumentNullException("memberId");
     TypeExpr = typeExpr;
     _memberId = memberId;
 }
Example #4
0
        public override bool TryOptimize(CompilerTarget target, out AstExpr expr)
        {
            expr = null;

            _typeExpr = (AstTypeExpr) _GetOptimizedNode(target, _typeExpr);

            //Optimize arguments
            for (var i = 0; i < _arguments.Count; i++)
            {
                var arg = _arguments[i];
                var oArg = _GetOptimizedNode(target, arg);
                if (ReferenceEquals(oArg, arg))
                    continue;
                _arguments[i] = oArg;
            }

            return false;
        }
Example #5
0
 internal AstObjectCreation(Parser p, AstTypeExpr type)
     : this(p.scanner.File, p.t.line, p.t.col, type)
 {
 }
Example #6
0
 internal AstTypecast(Parser p, AstExpr subject, AstTypeExpr type)
     : this(p.scanner.File, p.t.line, p.t.col, subject, type)
 {
 }
Example #7
0
 internal AstGetSetStatic(Parser p, PCall call, AstTypeExpr typeExpr, string memberId)
     : this(p.scanner.File, p.t.line, p.t.col, call, typeExpr, memberId)
 {
 }
Example #8
0
        public override bool TryOptimize(CompilerTarget target, out AstExpr expr)
        {
            _OptimizeNode(target, ref _subject);
            _type = (AstTypeExpr) _GetOptimizedNode(target, _type);

            expr = null;

            var constSubject = _subject as AstConstant;
            var constType = _type as AstConstantTypeExpression;
            if (constSubject == null || constType == null)
                return false;
            PType type;
            try
            {
                type = target.Loader.ConstructPType(constType.TypeExpression);
            }
            catch (PrexoniteException)
            {
                //ignore, cast failed. cannot be optimized
                return false;
            }
            expr =
                new AstConstant(File, Line, Column, constSubject.ToPValue(target).Type.Equals(type));
            return true;
        }