Exemplo n.º 1
0
 public LoadableCache(LoadableValue loadable_value, Type type, NameInfo name_info, bool must_unbox)
 {
     Value         = loadable_value;
     PossibleTypes = type;
     NameInfo      = name_info;
     Types         = AstTypeableNode.ClrTypeFromType(type);
     NeedsUnbox    = must_unbox;
 }
Exemplo n.º 2
0
 internal System.Type[] GetIntrinsicRealTypes(AstNode node)
 {
     if (Intrinsics.ContainsKey(node))
     {
         return(AstTypeableNode.ClrTypeFromType(Intrinsics[node].Item1));
     }
     else if (Parent != null)
     {
         return(Parent.GetIntrinsicRealTypes(node));
     }
     throw new InvalidOperationException("There is no intrinsic type for the node requested. This a compiler bug.");
 }
Exemplo n.º 3
0
        internal void IntrinsicDispatch(Generator generator, AstNode node, LoadableValue original, LoadableValue source_reference, Generator.ParameterisedBlock <LoadableValue> block)
        {
            var intrinsic = Intrinsics[node];

            if (!intrinsic.Item2)
            {
                block(original);
                return;
            }
            var types = AstTypeableNode.ClrTypeFromType(intrinsic.Item1);

            foreach (var type in types)
            {
                var next_label = generator.Builder.DefineLabel();
                original.Load(generator);
                generator.Builder.Emit(OpCodes.Isinst, type);
                generator.Builder.Emit(OpCodes.Brfalse, next_label);
                var builder = generator.Builder;
                block(new AutoUnboxValue(original, type));
                generator.Builder = builder;
                generator.Builder.MarkLabel(next_label);
            }
            generator.EmitTypeError(source_reference, String.Format("Expected type {0} for {1}, but got {2}.", String.Join(" or ", from t in types select Stringish.NameForType(t)), node.PrettyName, "{0}"), original);
        }