Example #1
0
 public override IR getMember(IR i, int index, IRList list)
 {
     if (index >= members.Length)
     {
         throw Jolly.addError(new SourceLocation(), "Out of index bounds");
     }
     return(list.Add(IR.getMember(i, members[index], index)));
 }
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
        public override IR getMember(IR i, string name, IRList list)
        {
            int             index;
            DataType_Struct iterator = this;

            while (iterator != null)
            {
                if (iterator.memberMap.TryGetValue(name, out index))
                {
                    IR _struct = i;
                    if (iterator != this)
                    {
                        _struct = list.Add(IR.cast <IR_Reinterpret>(i, iterator, null));
                    }
                    return(list.Add(IR.getMember(_struct, iterator.members[index], index + (iterator.inherits == null ? 0 : 1))));
                }
                iterator = iterator.inherits;
            }
            return(null);
        }