public void AddGlobalTest( ) { using (var module = new NativeModule(TestModuleName)) { module.AddGlobal(module.Context.Int32Type, "TestInt"); GlobalVariable globalVar = module.GetNamedGlobal("TestInt"); Assert.AreEqual("TestInt", globalVar.Name); Assert.AreSame(module.Context.Int32Type.CreatePointerType( ), globalVar.NativeType); } }
public void AddGlobalTest2( ) { using (var module = new NativeModule(TestModuleName)) { module.AddGlobal(module.Context.Int32Type, true, Linkage.WeakODR, module.Context.CreateConstant(0x12345678), "TestInt"); GlobalVariable globalVar = module.GetNamedGlobal("TestInt"); Assert.AreEqual("TestInt", globalVar.Name); Assert.AreSame(module.Context.Int32Type.CreatePointerType( ), globalVar.NativeType); Assert.AreSame(module.Context.Int32Type, globalVar.Initializer.NativeType); Assert.AreEqual(Linkage.WeakODR, globalVar.Linkage); Assert.IsTrue(globalVar.IsConstant); Assert.IsInstanceOfType(globalVar.Initializer, typeof(ConstantInt)); var constInt = ( ConstantInt )globalVar.Initializer; Assert.AreEqual(0x12345678, constInt.SignExtendedValue); } }