public void BagSaveAndLoad1() { NativeProcedure p1 = new NativeProcedure("p1"); p1.Signature.ReturnType = new NativeBuiltinType(BuiltinType.NativeBoolean); NativeTypeDef td = new NativeTypeDef("LPWSTR", new NativePointer(BuiltinType.NativeWChar)); p1.Signature.Parameters.Add(new NativeParameter("param1", new NativeNamedType("LPWSTR", td))); Assert.Equal("boolean p1(LPWSTR param1)", p1.DisplayName); Assert.Equal("p1(Sig(boolean)(Sal)(param1(LPWSTR(LPWSTR(*(wchar))))(Sal)))", SymbolPrinter.Convert(p1)); var ns = new BasicSymbolStorage(); ns.AddProcedure(p1); ns.AddTypeDef(td); NativeSymbolBag bag = new NativeSymbolBag(ns); NativeProcedure ret1 = null; Assert.True(bag.TryGetGlobalSymbol("p1", out ret1)); bag.AddProcedure(ret1); Assert.True(bag.TryResolveSymbolsAndValues()); Assert.Equal(SymbolPrinter.Convert(p1), SymbolPrinter.Convert(ret1)); }
public void SaveAndLoad6() { NativeFunctionPointer fptr = new NativeFunctionPointer("f1"); Assert.Equal(NativeCallingConvention.WinApi, fptr.CallingConvention); fptr.CallingConvention = NativeCallingConvention.Pascal; fptr.Signature.ReturnType = new NativeBuiltinType(BuiltinType.NativeChar); NativeProcedure proc = new NativeProcedure("p1"); Assert.Equal(NativeCallingConvention.WinApi, proc.CallingConvention); proc.CallingConvention = NativeCallingConvention.CDeclaration; proc.Signature.ReturnType = new NativeBuiltinType(BuiltinType.NativeChar); var ns = new BasicSymbolStorage(); ns.AddProcedure(proc); ns.AddDefinedType(fptr); NativeDefinedType temp = null; NativeFunctionPointer retPtr = null; Assert.True(ns.TryGetGlobalSymbol(fptr.Name, out temp)); retPtr = (NativeFunctionPointer)temp; Assert.Equal(NativeCallingConvention.Pascal, retPtr.CallingConvention); NativeProcedure retProc = null; Assert.True(ns.TryGetGlobalSymbol(proc.Name, out retProc)); Assert.Equal(NativeCallingConvention.CDeclaration, retProc.CallingConvention); }
public void FindOrLoad4() { var ns = new BasicSymbolStorage(); NativeProcedure p1 = new NativeProcedure("p1"); p1.Signature.ReturnType = new NativeBuiltinType(BuiltinType.NativeBoolean); ns.AddProcedure(p1); NativeSymbolBag bag = new NativeSymbolBag(ns); NativeProcedure p = null; Assert.False(bag.Storage.TryGetGlobalSymbol("p1", out p)); Assert.True(bag.TryGetGlobalSymbol("p1", out p)); Assert.True(bag.TryGetGlobalSymbol("p1", out p)); }
public void Proc1() { NativeProcedure p1 = new NativeProcedure("p1"); p1.Signature.ReturnType = new NativeBuiltinType(BuiltinType.NativeByte); var ns = new BasicSymbolStorage(); ns.AddProcedure(p1); NativeProcedure retp1 = null; Assert.True(ns.TryGetGlobalSymbol(p1.Name, out retp1)); Assert.Equal(p1.DisplayName, retp1.DisplayName); }
public void Sal2() { NativeProcedure p1 = new NativeProcedure("p1"); p1.Signature.ReturnType = new NativeBuiltinType(BuiltinType.NativeChar); p1.Signature.ReturnTypeSalAttribute = new NativeSalAttribute(new NativeSalEntry(SalEntryType.Deref, "foo")); var ns = new BasicSymbolStorage(); ns.AddProcedure(p1); NativeProcedure retp1 = null; Assert.True(ns.TryGetGlobalSymbol(p1.Name, out retp1)); Assert.Equal("Deref(foo)", retp1.Signature.ReturnTypeSalAttribute.DisplayName); }
public void Sal3() { NativeParameter param = new NativeParameter("p"); param.SalAttribute = new NativeSalAttribute(SalEntryType.Deref); param.NativeType = new NativeBuiltinType(BuiltinType.NativeChar); NativeProcedure p1 = new NativeProcedure("p1"); p1.Signature.ReturnType = new NativeBuiltinType(BuiltinType.NativeChar); p1.Signature.Parameters.Add(param); var ns = new BasicSymbolStorage(); ns.AddProcedure(p1); NativeProcedure retp1 = null; Assert.True(ns.TryGetGlobalSymbol(p1.Name, out retp1)); Assert.Equal("Deref", retp1.Signature.Parameters[0].SalAttribute.DisplayName); }
public void Proc4() { NativeStruct s1 = new NativeStruct("s1"); s1.Members.Add(new NativeMember("m1", new NativeBuiltinType(BuiltinType.NativeByte))); NativeProcedure p1 = new NativeProcedure("p1"); p1.Signature.ReturnType = s1; var ns = new BasicSymbolStorage(); ns.AddProcedure(p1); NativeProcedure retp1 = null; Assert.True(ns.TryGetGlobalSymbol(p1.Name, out retp1)); Assert.Equal(p1.DisplayName, retp1.DisplayName); NativeDefinedType rets1 = null; Assert.False(ns.TryGetGlobalSymbol(s1.Name, out rets1)); }