Example #1
0
 private bool _tryOptimizeConstCast(CompilerTarget target, AstConstant constSubject,
     AstConstantTypeExpression constType, out AstExpr expr)
 {
     expr = null;
     PType type;
     try
     {
         type = target.Loader.ConstructPType(constType.TypeExpression);
     }
     catch (PrexoniteException)
     {
         //ignore, cast failed. cannot be optimized
         return false;
     }
     PValue result;
     if (constSubject.ToPValue(target).TryConvertTo(target.Loader, type, out result))
         return AstConstant.TryCreateConstant(target, Position, result, out expr);
     else
         return false;
 }