Exemple #1
0
        public Val32 GetTypeObjectD(Define st)
        {
            if (st == null) return Val32.New(0);

            var name = st.FullName;
            if (types.ContainsKey(name))
                return types.Get(name) as Val32;

            return GetTypeObjectV(
                name, st.GetFunction(Define.Destructor),
                st.GetSize(), GetTypeObjectD(st.GetBaseStruct()));
        }
Exemple #2
0
 public bool CanUpCast(Define st)
 {
     MakeUp();
     if (st == this) return true;
     var b = GetBaseStruct();
     if (b == null) return false;
     return b.CanUpCast(st);
 }
Exemple #3
0
        private bool AddInitValues(OpModule codes, Define st)
        {
            if (values.Count == 0) return false;

            var members = st.GetMemberDecls();
            if (members.Length != values.Count)
                throw Abort("initializers mismatched: " + st.Name);

            var ad = Addr32.New(Reg32.ESP);
            codes.Add(I386.PushA(ad));
            for (int i = 0; i < values.Count; i++)
            {
                VarDeclare mem = members[i];
                object obj = values[i];
                if (obj is Declare)
                {
                    Define memst = Types.GetStruct(mem.Type);
                    if (!(mem is Declare) || memst == null)
                        throw Abort("struct required: " + mem.Name);
                    (obj as Declare).AddInitValues(codes, memst);
                }
                else if (obj is NodeBase)
                {
                    if (!(mem is VarDeclare))
                        throw Abort("value required: " + mem.Name);
                    (obj as NodeBase).AddCodesV(codes, "mov", null);
                    codes.Add(I386.MovRA(Var.DestRegister, ad));
                    mem.Type.AddSetCodes(codes, Addr32.New(Var.DestRegister));
                }
                else
                    throw Abort("invalid parameter: " + mem.Name);
                codes.Add(I386.AddA(ad, Val32.NewI(mem.Type.Size)));
            }
            codes.Add(I386.AddR(Reg32.ESP, Val32.New(4)));
            return true;
        }
Exemple #4
0
 public static Define New(BlockBase parent, string name, string baseType)
 {
     var ret = new Define();
     ret.init(parent);
     if (string.IsNullOrEmpty(name))
     {
         ret.isAnonymous = true;
         ret.name = parent.GetAnonymousName();
     }
     else
         ret.name = name;
     ret.thisptr = Arg.New(ret, "this", Types.ToVarType(ret.Type));
     ret.BaseType = baseType;
     return ret;
 }
Exemple #5
0
 public void CheckField(Define st1, Define st2)
 {
     st2.MakeUp();
     if (st1 == st2)
         throw Abort(
             "can not define recursive field: {0}",
             st1.GetFullName(name));
     var b = st2.GetBaseStruct();
     if (b != null) CheckField(st1, b);
 }