/// <summary> /// Generate an Add opcode. /// </summary> private static RCode OpcodeForType(XTypeReference type, RCode[] opcodes) { if (type.IsInt32() || type.IsUInt32() || type.IsInt16() || type.IsUInt16() || type.IsChar() || type.IsByte() || type.IsSByte() || type.IsBoolean()) return opcodes[0]; if (type.IsInt64() || type.IsUInt64()) return opcodes[1]; if (type.IsFloat()) return opcodes[2]; if (type.IsDouble()) return opcodes[3]; XTypeDefinition typeDef; if (type.TryResolve(out typeDef)) { if (typeDef.IsEnum) { return OpcodeForType(typeDef.GetEnumUnderlyingType(), opcodes); } } throw new ArgumentException("Unsupported type " + type); }