/// <summary> /// calling the type tag. /// </summary> /// <param name="il">The <see cref="ILGenerator"/></param> /// <param name="tag">The <see cref="ITypeTag"/></param> /// <returns></returns> public static Type CallTypeTag(this ILGenerator il, ITypeTag tag) { switch (tag.GetType().Name) { case "BooleanTag": il.Emit(OpCodes.Ldc_I4, (tag as BooleanTag).Value ? 1 : 0); return(typeof(bool)); case "NumberTag": switch (tag.Value.GetType().Name) { case "Int32": il.Emit(OpCodes.Ldc_I4, (int)tag.Value); return(typeof(int)); case "Int64": il.Emit(OpCodes.Ldc_I8, (long)tag.Value); return(typeof(long)); case "Single": il.Emit(OpCodes.Ldc_R4, (float)tag.Value); return(typeof(float)); case "Double": il.Emit(OpCodes.Ldc_R8, (double)tag.Value); return(typeof(double)); case "Int16": il.Emit(OpCodes.Ldc_I4, (short)tag.Value); return(typeof(short)); default: throw new NotSupportedException($"[NumberTag] : [{tag.Value}] is not supported"); } case "OperatorTag": case "StringTag": default: il.Emit(OpCodes.Ldstr, tag.Value?.ToString() ?? string.Empty); return(typeof(string)); } }