Example #1
0
        /// <summary>
        /// Specializes native pointer to int casts.
        /// </summary>
        private static void Specialize(
            RewriterContext context,
            SpecializerData data,
            PointerAsIntCast value)
        {
            // Convert from ptr -> native int type -> desired int type
            var builder = context.Builder;

            // ptr -> native int type
            var convertToNativeType = builder.CreatePointerAsIntCast(
                value.Location,
                value.Value,
                data.IntPointerType.BasicValueType);

            // native int type -> desired int type
            var convert = builder.CreateConvert(
                value.Location,
                convertToNativeType,
                value.TargetType);

            context.ReplaceAndRemove(value, convert);
        }
Example #2
0
 /// <summary cref="IValueVisitor.Visit(PointerAsIntCast)"/>
 public void Visit(PointerAsIntCast value) =>
 CodeGenerator.GenerateCode(value);
Example #3
0
 /// <summary cref="IBackendCodeGenerator.GenerateCode(IntAsPointerCast)"/>
 public void GenerateCode(PointerAsIntCast cast) => GenerateCodeForCast(cast);
Example #4
0
 /// <summary cref="IBackendCodeGenerator.GenerateCode(PointerAsIntCast)"/>
 public void GenerateCode(PointerAsIntCast cast) => Alias(cast, cast.Value);
Example #5
0
 /// <summary>
 /// Returns true if we have to adjust the source cast operation.
 /// </summary>
 private static bool CanSpecialize(
     SpecializerData data,
     PointerAsIntCast value) =>
 value.TargetType != data.IntPointerType;
Example #6
0
 /// <summary>
 /// Returns true if we have to adjust the source cast operation.
 /// </summary>
 private static bool CanSpecialize(
     AcceleratorSpecializer specializer,
     PointerAsIntCast value) =>
 value.TargetType != specializer.IntPointerType;