本文整理汇总了C#中clojure.lang.CljCompiler.Ast.CljILGen.EmitBoolean方法的典型用法代码示例。如果您正苦于以下问题:C# CljILGen.EmitBoolean方法的具体用法?C# CljILGen.EmitBoolean怎么用?C# CljILGen.EmitBoolean使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类clojure.lang.CljCompiler.Ast.CljILGen
的用法示例。
在下文中一共展示了CljILGen.EmitBoolean方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Emit
public override void Emit(RHC rhc, ObjExpr objx, CljILGen ilg)
{
ilg.EmitBoolean(_val);
ilg.Emit(OpCodes.Box,typeof(bool));
if (rhc == RHC.Statement)
ilg.Emit(OpCodes.Pop);
}
示例2: EmitPrimitive
static void EmitPrimitive(CljILGen ilg, object val)
{
switch (Type.GetTypeCode(val.GetType()) )
{
case TypeCode.Boolean:
ilg.EmitBoolean((bool)val); break;
case TypeCode.Byte:
ilg.EmitByte((byte)val); break;
case TypeCode.Char:
ilg.EmitChar((char)val); break;
case TypeCode.Decimal:
ilg.EmitDecimal((decimal)val); break;
case TypeCode.Double:
ilg.EmitDouble((double)val); break;
case TypeCode.Int16:
ilg.EmitShort((short)val); break;
case TypeCode.Int32:
ilg.EmitInt((int)val); break;
case TypeCode.Int64:
ilg.EmitLong((long)val); break;
case TypeCode.SByte:
ilg.EmitSByte((sbyte)val); break;
case TypeCode.Single:
ilg.EmitSingle((float)val); break;
case TypeCode.UInt16:
ilg.EmitUShort((ushort)val); break;
case TypeCode.UInt32:
ilg.EmitUInt((uint)val); break;
case TypeCode.UInt64:
ilg.EmitULong((ulong)val); break;
default:
throw new InvalidOperationException("Unknown constant type in EmitPrimitive");
}
}
示例3: EmitValue
protected void EmitValue(object value, CljILGen ilg)
{
bool partial = true;
if (value == null)
ilg.Emit(OpCodes.Ldnull);
else if (value is String)
ilg.Emit(OpCodes.Ldstr, (String)value);
else if (value is Boolean)
{
ilg.EmitBoolean((Boolean)value);
ilg.Emit(OpCodes.Box,typeof(bool));
}
else if (value is Int32)
{
ilg.EmitInt((int)value);
ilg.Emit(OpCodes.Box, typeof(int));
}
else if (value is Int64)
{
ilg.EmitLong((long)value);
ilg.Emit(OpCodes.Box, typeof(long));
}
else if (value is Double)
{
ilg.EmitDouble((double)value);
ilg.Emit(OpCodes.Box, typeof(double));
}
else if (value is Char)
{
ilg.EmitChar((char)value);
ilg.Emit(OpCodes.Box,typeof(char));
}
else if (value is Type)
{
Type t = (Type)value;
if (t.IsValueType)
ilg.EmitType(t);
else
{
//ilg.EmitString(Compiler.DestubClassName(((Type)value).FullName));
ilg.EmitString(((Type)value).FullName);
ilg.EmitCall(Compiler.Method_RT_classForName);
}
}
else if (value is Symbol)
{
Symbol sym = (Symbol)value;
if (sym.Namespace == null)
ilg.EmitNull();
else
ilg.EmitString(sym.Namespace);
ilg.EmitString(sym.Name);
ilg.EmitCall(Compiler.Method_Symbol_intern2);
}
else if (value is Keyword)
{
Keyword keyword = (Keyword)value;
if (keyword.Namespace == null)
ilg.EmitNull();
else
ilg.EmitString(keyword.Namespace);
ilg.EmitString(keyword.Name);
ilg.EmitCall(Compiler.Method_RT_keyword);
}
else if (value is Var)
{
Var var = (Var)value;
ilg.EmitString(var.Namespace.Name.ToString());
ilg.EmitString(var.Symbol.Name.ToString());
ilg.EmitCall(Compiler.Method_RT_var2);
}
else if (value is IType)
{
IPersistentVector fields = (IPersistentVector)Reflector.InvokeStaticMethod(value.GetType(), "getBasis", Type.EmptyTypes);
for (ISeq s = RT.seq(fields); s != null; s = s.next())
{
Symbol field = (Symbol)s.first();
Type k = Compiler.TagType(Compiler.TagOf(field));
object val = Reflector.GetInstanceFieldOrProperty(value, field.Name);
EmitValue(val, ilg);
if (k.IsPrimitive)
{
ilg.Emit(OpCodes.Castclass, k);
}
}
ConstructorInfo cinfo = value.GetType().GetConstructors()[0];
ilg.EmitNew(cinfo);
}
else if (value is IRecord)
{
//MethodInfo[] minfos = value.GetType().GetMethods(BindingFlags.Static | BindingFlags.Public);
EmitValue(PersistentArrayMap.create((IDictionary)value), ilg);
MethodInfo createMI = value.GetType().GetMethod("create", BindingFlags.Static | BindingFlags.Public, null, CallingConventions.Standard, new Type[] { typeof(IPersistentMap) }, null);
ilg.EmitCall(createMI);
}
//.........这里部分代码省略.........
示例4: EmitHasArityMethod
protected static void EmitHasArityMethod(TypeBuilder tb, IList<int> arities, bool isVariadic, int reqArity)
{
// TODO: Convert to a Switch instruction
MethodBuilder mb = tb.DefineMethod(
"HasArity",
MethodAttributes.ReuseSlot | MethodAttributes.Public | MethodAttributes.Virtual,
typeof(bool),
new Type[] { typeof(int) });
CljILGen gen = new CljILGen(mb.GetILGenerator());
Label falseLabel = gen.DefineLabel();
Label trueLabel = gen.DefineLabel();
if (isVariadic)
{
gen.EmitLoadArg(1);
gen.EmitInt(reqArity);
gen.Emit(OpCodes.Bge, trueLabel);
}
if (arities != null)
{
foreach (int i in arities)
{
gen.EmitLoadArg(1);
gen.EmitInt(i);
gen.Emit(OpCodes.Beq, trueLabel);
}
}
gen.MarkLabel(falseLabel);
gen.EmitBoolean(false);
gen.Emit(OpCodes.Ret);
gen.MarkLabel(trueLabel);
gen.EmitBoolean(true);
gen.Emit(OpCodes.Ret);
}