Example #1
0
 public override IR subscript(IR i, IR index, IRList list)
 {
     if (index.dType != Lookup.I32)
     {
         throw Jolly.addError(new SourceLocation(), "Only int can be used as subscript");
     }
     return(list.Add(IR.operation <IR_Substript>(i, index, null)));
 }
Example #2
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);
        }
Example #3
0
        static void assign(AST_Node node)
        {
            var op = (AST_Operation)node;

            if ((op.a.result.dKind & ~ValueKind.ADDRES) != 0)
            {
                throw Jolly.addError(op.location, "Cannot assign to this");
            }
            load(op.b);
            implicitCast(ref op.b.result, op.a.result.dType);

            //TODO: Assign to tuple containing names: someStruct.(a, b) = (0, 1);

            if (op.a.result.irType == NT.ALLOCATE)
            {
                ((IR_Allocate)op.a.result).initialized = true;
            }
            op.result = instructions.Add(IR.operation <IR_Assign>(op.a.result, op.b.result, null));
        }