Esempio n. 1
0
        public virtual T VisitStructDefNode(StructDefNode n)
        {
            for (int i = 0; i < n.defaultValues.Count; i++)
            {
                n.defaultValues[i]?.Accept(this);
            }

            return(default(T));
        }
Esempio n. 2
0
        public object VisitStructDefNode(StructDefNode n)
        {
            WriteLine(n.kind + " - " + n.name + "(" + n.Type.Length + ")");
            Indent();
            for (int i = 0; i < n.Type.Fields.Count; i++)
            {
                var m = n.Type.Fields.ElementAt(i);
                WriteLine(m.Key + ":" + m.Value.Item1 + "  +" + m.Value.Item2);
            }
            Dedent();

            return(null);
        }
Esempio n. 3
0
        public override object VisitStructDefNode(StructDefNode n)
        {
            foreach (Expression e in n.defaultValues)
            {
                Visit(e);
            }

            var fields = new Dictionary <string, (TypeSymbol, int)>();

            int c_offset = 0;

            for (int i = 0; i < n.Type.Fields.Count; i++)
            {
                KeyValuePair <string, (TypeSymbol, int)> m = n.Type.Fields.ElementAt(i);
                TypeSymbol curts = m.Value.Item1;

                string name = m.Key;

                TypeSymbol toadd = null;
                if (curts.Name == n.name || MakeTypeSymbolForString(curts.Name).Kind == TypeSymbol.TypeKind.STRUCT) //pointer to (own) struct
                {
                    toadd = TypeSymbol.POINTER_SYMBOL(curts);                                                       //new TypeSymbol(curts.Name, TypeSymbol.TypeKind.POINTER, 8);
                }
                else
                {
                    toadd = MakeTypeSymbolForString(curts.Name);
                }
                int len = toadd.Length;

                if (c_offset > 0 && c_offset % len != 0)
                {
                    c_offset = ((c_offset / len) + 1) * len; // get next biggest multiple of Size -> alignment
                }

                fields.Add(name, (toadd, c_offset));

                c_offset += len;
            }

            TypeSymbol ts = TypeSymbol.STRUCT_SYMBOL(n.name, c_offset, fields);

            n.Type = ts;

            KnownTypes.PutInScope(n.name, ts);

            return(null);
        }
Esempio n. 4
0
 public override MIPSRegister VisitStructDefNode(StructDefNode n)
 {
     return(base.VisitStructDefNode(n));
 }
Esempio n. 5
0
 public override LLVMRegister VisitStructDefNode(StructDefNode n)
 {
     throw new NotImplementedException();
 }
Esempio n. 6
0
 public override object VisitStructDefNode(StructDefNode n)
 {
     interp.Types.Add(n.name, n.Type);
     return(null);
 }