public static void AddCodes(NodeBase caller, BlockBase parent, NodeBase target, OpModule codes, string op, Addr32 dest) { if (target is TypeOf) target = (target as TypeOf).Target; var v = target as Variant; if (v != null && parent.GetFunction(v.Name) == null) { var fpname = (target as Variant).Name; var fpt = Types.GetType(parent, fpname); if (fpt == null || !fpt.Check()) throw caller.Abort("undefined type: {0}", fpname); codes.AddCodesV(op, dest, codes.GetTypeObject(fpt)); return; } var tt = target.Type; var tr = tt as TypeReference; var tts = tt.Type as TypeStruct; if (tr != null && (tr.IsArray || (tts != null && tts.IsClass))) { target.AddCodesV(codes, "mov", null); var label = new OpCode(); codes.Add(I386.Test(Reg32.EAX, Reg32.EAX)); codes.Add(I386.Jcc(Cc.Z, label.Address)); codes.Add(I386.MovRA(Reg32.EAX, Addr32.NewRO(Reg32.EAX, -16))); codes.Add(label); codes.AddCodes(op, dest); } else codes.AddCodesV(op, dest, codes.GetTypeObject(tt)); }
public void CheckArgs(NodeBase target, NodeBase[] args) { if (!(args.Length == Args.Length || (HasParams && args.Length >= Args.Length))) throw target.Abort("argument mismatched: {0}", target.Name); for (int i = 0; i < Args.Length; i++) { var t1 = args[i].Type; var t2 = Args[i].Type; if (t1 != null && t1.Cast(t2) == null) throw target.Abort( "can not cast arg {0}: {1}: {2} => {3}", i + 1, Args[i].Name, t1.Name, t2.Name); } }