Exemplo n.º 1
0
    public static DyTypeInfo GetMixinByCode(int code)
    {
        DyTypeInfo mixin = null !;

        GetMixinByCodeGenerated(code, ref mixin);
        return(mixin);
    }
Exemplo n.º 2
0
    public static DyObject OverloadProhibited(this ExecutionContext ctx, DyTypeInfo typeInfo, string name)
    {
        name = Builtins.NameToOperator(name);

        if (Builtins.IsSetter(name))
        {
            name = $"set {typeInfo.ReflectedTypeName}.{name}";
        }
        else if (name == Builtins.Get)
        {
            name = $"{typeInfo.ReflectedTypeName}[]";
        }
        else if (name == Builtins.Set)
        {
            name = $"set {typeInfo.ReflectedTypeName}[]";
        }
        else if (name.IndexOfAny(Builtins.OperatorSymbols.ToCharArray()) != -1)
        {
            name = $"{typeInfo.ReflectedTypeName} {name}";
        }
        else
        {
            name = $"{typeInfo.ReflectedTypeName}.{name}";
        }

        ctx.Error = new(DyError.OverloadProhibited, name);
        return(Nil);
    }
Exemplo n.º 3
0
    protected override DyObject CastOp(ExecutionContext ctx, DyObject self, DyTypeInfo targetType)
    {
        if (targetType.ReflectedTypeId == DeclaringUnit.Date.ReflectedTypeId)
        {
            return(((DyDateTime)self).GetDate(DeclaringUnit.Date));
        }
        else if (targetType.ReflectedTypeId == DeclaringUnit.Time.ReflectedTypeId)
        {
            return(((DyDateTime)self).GetTime(DeclaringUnit.Time));
        }

        return(base.CastOp(ctx, self, targetType));
    }
Exemplo n.º 4
0
    protected override DyObject CastOp(ExecutionContext ctx, DyObject self, DyTypeInfo targetType)
    {
        if (targetType.ReflectedTypeId == self.TypeId)
        {
            return(self);
        }

        var xs = (DyCollection)self;

        return(targetType.ReflectedTypeId switch
        {
            Dy.Tuple => new DyTuple(xs.ToArray()),
            Dy.Array => new DyArray(xs.ToArray()),
            Dy.Iterator => DyIterator.Create(xs),
            Dy.Set => new DySet(new HashSet <DyObject>(xs.ToArray())),
            _ => base.CastOp(ctx, self, targetType)
        });
Exemplo n.º 5
0
 protected override DyObject CastOp(ExecutionContext ctx, DyObject self, DyTypeInfo targetType) =>
 targetType.ReflectedTypeId switch
 {
Exemplo n.º 6
0
 internal DyClass(DyTypeInfo type, string ctor, DyTuple fields, DyTuple inits, Unit unit) : base(type.ReflectedTypeId) =>
     (DecType, Constructor, Fields, Inits, DeclaringUnit) = (type, ctor, fields, inits, unit);
Exemplo n.º 7
0
 static partial void GetMixinByCodeGenerated(int code, ref DyTypeInfo name);
Exemplo n.º 8
0
 public static DyObject TypeClosed(this ExecutionContext ctx, DyTypeInfo typeInfo)
 {
     ctx.Error = new(DyError.TypeClosed, typeInfo.ReflectedTypeName);
     return(Nil);
 }
Exemplo n.º 9
0
 public DyObject Read(ExecutionContext ctx, DyTypeInfo type) =>
 type.ReflectedTypeId switch
 {