Exemplo n.º 1
0
 public void AddGlobalTest( )
 {
     using (var context = new Context( ))
         using (var module = new BitcodeModule(context, 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);
         }
 }
Exemplo n.º 2
0
 public void AddGlobalTest2( )
 {
     using (var context = new Context( ))
         using (var module = new BitcodeModule(context, 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);
         }
 }