Beispiel #1
0
        static IR packTuple(AST_Tuple tuple, DataType_Tuple tupleType)
        {
            IR_Allocate alloc = new IR_Allocate {
                dType = tupleType
            };

            tuple.values.forEach((val, i) => {
                IR member = instructions.Add(IR.getMember(alloc, tupleType.members[i], i));
                instructions.Add(IR.operation <IR_Assign>(member, val.result, null));
            });
            return(alloc);
        }
Beispiel #2
0
        static void getTuple_Type_Kind(AST_Tuple tuple, out DataType_Tuple tupleType, out ValueKind tupleKind)
        {
            ValueKind      _tupleKind = 0;
            DataType_Tuple _tupleType = new DataType_Tuple(tuple.values.Count);

            tuple.values.forEach((val, i) => {
                _tupleKind           |= val.result.dKind;
                _tupleType.members[i] = val.result.dType;
            });

            if ((_tupleKind & (ValueKind.STATIC_TYPE | ValueKind.STATIC_FUNCTION)) != 0)
            {
                if ((_tupleKind & ~(ValueKind.STATIC_TYPE | ValueKind.STATIC_FUNCTION)) != 0)
                {
                    throw Jolly.addError(tuple.location, "Tuple mixes values and types");
                }
            }
            else if ((_tupleKind & (ValueKind.ADDRES | ValueKind.STATIC_VALUE | ValueKind.VALUE)) == 0)
            {
                throw Jolly.addError(tuple.location, "Invalid tuple type");
            }
            tupleKind = _tupleKind;
            tupleType = (DataType_Tuple)DataType.makeUnique(_tupleType);
        }