public override void VisitQualifier(Qualifier n) { n.Expression.Visit(this); switch (n.Type.ToLower()) { case "date": _lastSeenType = n.InternalType = new TypeDate(); break; case "real": _lastSeenType = n.InternalType = new TypeReal(); break; case "integer": _lastSeenType = n.InternalType = new TypeInteger(); break; case "string": _lastSeenType = n.InternalType = new TypeString(); break; case "boolean": _lastSeenType = n.InternalType = new TypeBoolean(); break; default: throw new Exception("Unknown type qualifier: (" + n.Type + ")"); } }
public JsonType GetCommonType(JsonType type2) { var commonType = GetCommonTypeEnum(this.Type, type2.Type); if (commonType == JsonTypeEnum.Array) { if (type2.Type == JsonTypeEnum.NullableSomething) { return(this); } if (this.Type == JsonTypeEnum.NullableSomething) { return(type2); } var commonInternalType = InternalType.GetCommonType(type2.InternalType).MaybeMakeNullable(generator); if (commonInternalType != InternalType) { return new JsonType(generator, JsonTypeEnum.Array) { InternalType = commonInternalType } } ; } //if (commonType == JsonTypeEnum.Dictionary) //{ // var commonInternalType = InternalType.GetCommonType(type2.InternalType); // if (commonInternalType != InternalType) return new JsonType(JsonTypeEnum.Dictionary) { InternalType = commonInternalType }; //} if (this.Type == commonType) { return(this); } return(new JsonType(generator, commonType).MaybeMakeNullable(generator)); }
private InternalType ExpressionRelational() { InternalType result = ExpressionAdditive(); while (scanner.CurrType == TokenType.OpLess || scanner.CurrType == TokenType.OpGreater || scanner.CurrType == TokenType.OpLessEquals || scanner.CurrType == TokenType.OpGreaterEquals) { TokenType type = scanner.CurrType; scanner.Scan(); CheckOperands(ExpressionAdditive(), result); switch (type) { case TokenType.OpLess: EmitOpcode(Opcodes.LT); break; case TokenType.OpGreater: EmitOpcode(Opcodes.GT); break; case TokenType.OpLessEquals: EmitOpcode(Opcodes.LEQ); break; case TokenType.OpGreaterEquals: EmitOpcode(Opcodes.GEQ); break; } } return(result); }
/// <summary> /// Initializes a new instance of the <see cref="Field"/> class. /// </summary> /// <param name="fieldDefinition">The field definition.</param> public Field (FieldDefinition fieldDefinition, Class type, Class _class, InternalType internalType) { this.type = type; this.internalType = internalType; this.fieldDefinition = fieldDefinition; this._class = _class; }
private InternalType ExpressionMultiplicative() { InternalType result = ExpressionUnary(); while (scanner.CurrType == TokenType.OpMul || scanner.CurrType == TokenType.OpDiv || scanner.CurrType == TokenType.OpMod) { TokenType type = scanner.CurrType; scanner.Scan(); CheckOperands(ExpressionUnary(), result); switch (type) { case TokenType.OpMul: EnsureType(result, InternalType.Integer | InternalType.Float); EmitOpcode(Opcodes.MUL); break; case TokenType.OpDiv: EnsureType(result, InternalType.Integer | InternalType.Float); EmitOpcode(Opcodes.DIV); break; case TokenType.OpMod: EnsureType(result, InternalType.Integer); EmitOpcode(Opcodes.MOD); break; } } return(result); }
/// <summary> /// Initializes a new instance of the <see cref="Argument"/> class. /// </summary> /// <param name="index">The index.</param> /// <param name="type">The type.</param> /// <param name="internalType">Type of the internal.</param> public Argument(int index, Class type, InternalType internalType) : base("Arg", index) { this.type = type; this.internalType = internalType; this.forceSpill = true; }
private void CheckOperands(InternalType t1, InternalType t2) { if (t1 != t2) { Error("Incompatible types: {0} and {1}", t1, t2); } }
private InternalType ExpressionUnary() { TokenType type = TokenType.Unknown; if (scanner.CurrType == TokenType.OpMinus || scanner.CurrType == TokenType.OpNot) { type = scanner.CurrType; scanner.Scan(); ExpressionUnary(); } InternalType result = Factor(); switch (type) { case TokenType.OpNot: EnsureType(result, InternalType.Integer); EmitOpcode(Opcodes.NOT); break; case TokenType.OpMinus: EnsureType(result, InternalType.Integer | InternalType.Float); EmitOpcode(Opcodes.PUSH_INTEGER); EmitInteger(0); EmitOpcode(Opcodes.SUB); break; } return(result); }
private void DeclareVariable() { int index = FetchInteger(); InternalType type = (InternalType)FetchInteger(); AddVariable(index, type); }
/// <summary> /// Initializes a new instance of the <see cref="Local"/> class. /// </summary> /// <param name="index">The index.</param> /// <param name="type">The type.</param> /// <param name="internalType">Type of the internal.</param> public Local (int index, Class type, InternalType internalType) : base ("Loc", index) { this.type = type; this.internalType = internalType; this.forceSpill = true; }
public static T GetBuiltinResource <T>(string path) where T : InternalObjectBase { MelonDebug.Msg("GetBuiltinResource<T>"); IntPtr ptr = GetBuiltinResource(InternalType.Of <T>(), path); return(ptr != IntPtr.Zero ? (T)typeof(T).GetConstructor(new[] { typeof(IntPtr) }).Invoke(new object[] { ptr }) : null); }
/// <summary> /// Initializes a new instance of the <see cref="Argument"/> class. /// </summary> /// <param name="index">The index.</param> /// <param name="type">The type.</param> /// <param name="internalType">Type of the internal.</param> public Argument (int index, Class type, InternalType internalType) : base ("Arg", index) { this.type = type; this.internalType = internalType; this.forceSpill = true; }
protected internal ArrayCreation(NRefactory.ArrayCreateExpression arrayCreateExpression, IScope scope, INRefcatoryExpressionVisitor visitor) : base(scope, visitor) { _arrayCreateExpression = arrayCreateExpression; _isJaggeedArray = IsJaggedArray(); _isVector = IsVector(); InternalType = GetArrayType(); if (InternalType.GetArrayRank() == 1 && !_isJaggeedArray) { if (TryGetOneDimensionalArrayBounds()) { BuildEmptyOneDimensionalArray(); } else { BuildOneDimensionalArray(); } } else { if (TryGetBounds()) { BuildEmptyMultiDimensionalArray(); } else { BuildMultiDimensionalArrayAccess(); } } }
/// <summary> /// Initializes a new instance of the <see cref="Local"/> class. /// </summary> /// <param name="index">The index.</param> /// <param name="type">The type.</param> /// <param name="internalType">Type of the internal.</param> public Local(int index, Class type, InternalType internalType) : base("Loc", index) { this.type = type; this.internalType = internalType; this.forceSpill = true; }
private InternalType ExpressionAdditive() { InternalType result = ExpressionMultiplicative(); while (scanner.CurrType == TokenType.OpPlus || scanner.CurrType == TokenType.OpMinus) { TokenType type = scanner.CurrType; scanner.Scan(); CheckOperands(ExpressionMultiplicative(), result); if (type == TokenType.OpMinus) { EnsureType(result, InternalType.Integer | InternalType.Float); } switch (scanner.CurrType) { case TokenType.OpPlus: EmitOpcode(Opcodes.ADD); break; case TokenType.OpMinus: EmitOpcode(Opcodes.SUB); break; } } return(result); }
private void EnsureType(InternalType result, InternalType allowed) { if ((result & allowed) == 0) { Error("Operator not applicable to these operands"); } }
/// <summary> /// Initializes a new instance of the <see cref="Field"/> class. /// </summary> /// <param name="fieldDefinition">The field definition.</param> public Field(FieldDefinition fieldDefinition, Class type, Class _class, InternalType internalType) { this.type = type; this.internalType = internalType; this.fieldDefinition = fieldDefinition; this._class = _class; }
public JsonType GetCommonType(JsonType type2) { var commonType = GetCommonTypeEnum(this.Type, type2); if (commonType == JsonTypeEnum.Array) { if (type2.Type == JsonTypeEnum.NullableSomething) return this; if (this.Type == JsonTypeEnum.NullableSomething) return type2; JsonType commonInternalType; if (InternalType == null && type2.InternalType != null) // Handling the case Test_4 where the first array is an empty object commonInternalType = type2.InternalType; else commonInternalType = InternalType.GetCommonType(type2.InternalType).MaybeMakeNullable(generator); if (commonInternalType != InternalType) return new JsonType(generator, JsonTypeEnum.Array) { InternalType = commonInternalType }; } //if (commonType == JsonTypeEnum.Dictionary) //{ // var commonInternalType = InternalType.GetCommonType(type2.InternalType); // if (commonInternalType != InternalType) return new JsonType(JsonTypeEnum.Dictionary) { InternalType = commonInternalType }; //} if (this.Type == commonType) return this; return new JsonType(generator, commonType).MaybeMakeNullable(generator); }
public JsonType GetCommonType(JsonType type2) { var commonType = GetCommonTypeEnum(this.Type, type2.Type); if (commonType == JsonTypeEnum.Array) { if (type2.Type == JsonTypeEnum.NullableSomething) { return(this); } if (this.Type == JsonTypeEnum.NullableSomething) { return(type2); } var commonInternalType = InternalType.GetCommonType(type2.InternalType).MaybeMakeNullable(_generator); if (commonInternalType != InternalType) { return(new JsonType(_generator, JsonTypeEnum.Array) { InternalType = commonInternalType }); } } return(this.Type == commonType ? this : new JsonType(_generator, commonType).MaybeMakeNullable(_generator)); }
public static SqlTypeInformation SqlTypeFromInternalType(InternalType internalType, IDbProvider provider) { return(new SqlTypeInformation { SqlType = provider.TypeDictionary[internalType], IsUnique = false }); }
private Expression ReduceComplexList() { var addMethod = InternalType.GetMethod("Add"); var inits = _initializers.Cast <ArrayInitializer>() .Select(i => Expression.ElementInit(addMethod, i.Initializers)); return(Expression.ListInit(Expression.New(_constructor), inits)); }
private void AddVariable(int index, InternalType type, object value = null) { VariableInfo info = new VariableInfo { Index = index, Type = type, Value = value }; variables.Add(index, info); }
protected InternalMethod(string name, InternalType returnType, Dictionary <string, InternalType> formals) { Name = name; FuncInfo = new TypeFunction(name) { ReturnType = returnType, Formals = formals }; }
public BuildinType( InternalType intType = InternalType.c, int len = 0 ) { this.Type = intType; if (len == 0) { this.Length = getDefaultLength( intType ); } else { this.setLength( len ); } }
public JsonType GetInnermostType() { if (Type != JsonTypeEnum.Array) { throw new InvalidOperationException(); } return(InternalType.Type != JsonTypeEnum.Array ? InternalType : InternalType.GetInnermostType()); }
/// <summary> /// Adjusts the type of the register internal. /// </summary> /// <param name="type">The type.</param> /// <returns></returns> public InternalType AdjustRegisterInternalType(InternalType type) { InternalType result = InternalType.NotSet; switch (type) { case InternalType.I: result = InternalType.I; break; case InternalType.U: result = InternalType.I; break; case InternalType.I1: case InternalType.U1: case InternalType.I2: case InternalType.U2: case InternalType.I4: case InternalType.U4: result = InternalType.I4; break; case InternalType.I8: case InternalType.U8: result = InternalType.I8; break; case InternalType.R4: case InternalType.R8: case InternalType.F: result = InternalType.F; break; case InternalType.ValueType: result = InternalType.ValueType; break; case InternalType.O: result = InternalType.O; break; case InternalType.SZArray: result = InternalType.SZArray; break; case InternalType.Array: result = InternalType.Array; break; case InternalType.M: result = InternalType.M; break; } return(result); }
public Type LookupCilType(InternalType type) { if (type is TypeClass) { var name = (type as TypeClass).ClassName; return(TypeBuilderMap[name].Builder); } return(type.CilType); }
/// <summary> /// Initializes a new instance of the <see cref="AlertArgumentsProxy" /> class. /// </summary> /// <param name="caption">The caption</param> /// <param name="message">The message</param> /// <param name="positiveButton">The positive button text</param> /// <param name="negativeButton">The negative button text</param> public AlertArgumentsProxy(string caption, string message, string positiveButton, string negativeButton) { var assembly = typeof(Application).GetAssemblyEx(); InternalType = assembly.GetType("Xamarin.Forms.AlertArguments"); _propertyInfo = InternalType.GetPropertyEx("Result"); var constructor = InternalType.GetConstructorsEx()[0]; Object = constructor.Invoke(new object[] { caption, message, positiveButton, negativeButton }); }
public override string ToString() { if (IsFinallyPointsToFunction()) { return(RenderFuncStr("")); } else { return(InternalType.ToString() + " " + GetModifiersStr()); } }
public override string ToString() { if (IsFinallyPointsToFunction()) { return(RenderFuncStr("")); } else { return(InternalType.ToString() + (IsReference ? " &" : " *")); } }
public NpgsqlDate(int year, int month, int day) { _type = InternalType.Finite; if (year == 0 || year < MinYear || year > MaxYear || month < 1 || month > 12 || day < 1 || (day > (IsLeap(year) ? 366 : 365))) { throw new ArgumentOutOfRangeException(); } _daysSinceEra = DaysForYears(year) + (IsLeap(year) ? LeapYearDays : CommonYearDays)[month - 1] + day - 1; }
NpgsqlDateTime(InternalType type, NpgsqlDate date, TimeSpan time) { if (!date.IsFinite && type != InternalType.Infinity && type != InternalType.NegativeInfinity) { throw new ArgumentException("Can't construct an NpgsqlDateTime with a non-finite date, use Infinity and NegativeInfinity instead", nameof(date)); } _type = type; _date = date; _time = time; }
private InternalEntry(BinaryReaderEx br) { br.AssertInt32(0); unk2 = br.ReadInt32(); br.AssertInt32(4); br.AssertInt32(4); unk5 = br.ReadInt32(); Name = br.ReadShiftJISLengthPrefixed(0xA3); string type = br.ReadShiftJISLengthPrefixed(0x04); type = char.ToUpper(type[0]) + type.Substring(1); Type = (InternalType)Enum.Parse(typeof(InternalType), type); br.AssertInt32(1); br.AssertInt32(0); unk6 = br.ReadInt32(); unk7 = br.ReadInt32(); br.AssertInt32(1); unk8 = br.ReadInt32(); unk9 = br.ReadInt32(); if (Type == InternalType.Int) { Value = br.ReadInt32(); } else if (Type == InternalType.Int2) { Value = br.ReadInt32s(2); } else if (Type == InternalType.Bool) { Value = br.ReadBoolean(); } else if (Type == InternalType.Float) { Value = br.ReadSingle(); } else if (Type == InternalType.Float2) { Value = br.ReadSingles(2); } else if (Type == InternalType.Float3) { Value = br.ReadSingles(3); } else if (Type == InternalType.Float4) { Value = br.ReadSingles(4); } br.AssertByte(4); br.Pad(4); br.AssertInt32(0); }
public static int getDefaultLength( InternalType intType ) { switch (intType) { case InternalType.c: return 1; case InternalType.n: return 1; case InternalType.d: return 8; case InternalType.t: return 6; case InternalType.i: return 4; case InternalType.p: return 6; default: return 0; //fehler } }
public BuildinType(InternalType intType = InternalType.c, int len = 0) { this.Type = intType; if (len == 0) { this.Length = getDefaultLength(intType); } else { this.setLength(len); } }
protected Descriptor(InternalType t) { Type = t; }
/// <summary> /// Initializes a new instance of the <see cref="Ldind"/> class. /// </summary> /// <param name="type">The type.</param> /// <param name="result">The result.</param> /// <param name="value">The value.</param> public Ldind (InternalType type, Register result, Register value) : base ("Ldind", result, new Operand [] { value }) { this.type = type; result.InternalType = this.AdjustRegisterInternalType (type); }
/// <summary> /// Adjusts the type of the register internal. /// </summary> /// <param name="type">The type.</param> /// <returns></returns> public InternalType AdjustRegisterInternalType (InternalType type) { InternalType result = InternalType.NotSet; switch (type) { case InternalType.I: result = InternalType.I; break; case InternalType.U: result = InternalType.I; break; case InternalType.I1: case InternalType.U1: case InternalType.I2: case InternalType.U2: case InternalType.I4: case InternalType.U4: result = InternalType.I4; break; case InternalType.I8: case InternalType.U8: result = InternalType.I8; break; case InternalType.R4: case InternalType.R8: case InternalType.F: result = InternalType.F; break; case InternalType.ValueType: result = InternalType.ValueType; break; case InternalType.O: result = InternalType.O; break; case InternalType.SZArray: result = InternalType.SZArray; break; case InternalType.Array: result = InternalType.Array; break; case InternalType.M: result = InternalType.M; break; } return result; }
public static System.Type GetSystemTypeSimple(InternalType t) { switch (t) { case InternalType.t_Boolean: return typeof(bool); case InternalType.t_Byte: return typeof(byte); case InternalType.t_SByte: return typeof(sbyte); case InternalType.t_Short: return typeof(short); case InternalType.t_UShort: return typeof(ushort); case InternalType.t_Char: return typeof(char); case InternalType.t_Enum: return null; case InternalType.t_Int: return typeof(int); case InternalType.t_UInt: return typeof(uint); case InternalType.t_Long: return typeof(long); case InternalType.t_ULong: return typeof(ulong); case InternalType.t_Float: return typeof(float); case InternalType.t_Double: return typeof(double); case InternalType.t_String: return typeof(string); case InternalType.t_Date: return typeof(System.DateTime); case InternalType.t_Object: case InternalType.t_Value: case InternalType.t_ArrayOfBoolean: case InternalType.t_ArrayOfByte: case InternalType.t_ArrayOfSByte: case InternalType.t_ArrayOfShort: case InternalType.t_ArrayOfUShort: case InternalType.t_ArrayOfChar: case InternalType.t_ArrayOfEnum: case InternalType.t_ArrayOfInt: case InternalType.t_ArrayOfUInt: case InternalType.t_ArrayOfLong: case InternalType.t_ArrayOfULong: case InternalType.t_ArrayOfFloat: case InternalType.t_ArrayOfDouble: case InternalType.t_ArrayOfString: case InternalType.t_ArrayOfDate: case InternalType.t_ArrayOfObject: case InternalType.t_ArrayOfValue: case InternalType.t_Unsupported: return null; } return null; }
public InternalOuterTypeDependingOnConcrete(InternalType internalInstance) { }
/// <summary> /// Common implementations which pop a value from the IL evaluation stack and save it in another means /// of storage (such as stloc, stind, starg). /// </summary> private void Save (Class _class, InternalType destinationType, Memory memory, IR.Operands.Register value) { switch (destinationType) { case InternalType.I1: if (value.IsRegisterSet) this.assembly.MOV (R32.EAX, Assembly.GetRegister (value.Register)); else this.assembly.MOV (R32.EAX, new DWordMemory (this.GetAddress (value))); this.assembly.MOV (new ByteMemory (memory), R8.AL); break; case InternalType.U1: if (value.IsRegisterSet) this.assembly.MOV (R32.EAX, Assembly.GetRegister (value.Register)); else this.assembly.MOV (R32.EAX, new DWordMemory (this.GetAddress (value))); this.assembly.MOV (new ByteMemory (memory), R8.AL); break; case InternalType.I2: if (value.IsRegisterSet) this.assembly.MOV (R32.EAX, Assembly.GetRegister (value.Register)); else this.assembly.MOV (R32.EAX, new DWordMemory (this.GetAddress (value))); this.assembly.MOV (new WordMemory (memory), R16.AX); break; case InternalType.U2: if (value.IsRegisterSet) this.assembly.MOV (R32.EAX, Assembly.GetRegister (value.Register)); else this.assembly.MOV (R32.EAX, new DWordMemory (this.GetAddress (value))); this.assembly.MOV (new WordMemory (memory), R16.AX); break; case InternalType.I4: case InternalType.U4: case InternalType.I: case InternalType.U: case InternalType.O: case InternalType.SZArray: case InternalType.Array: if (value.IsRegisterSet) this.assembly.MOV (R32.EAX, Assembly.GetRegister (value.Register)); else this.assembly.MOV (R32.EAX, new DWordMemory (this.GetAddress (value))); this.assembly.MOV (new DWordMemory (memory), R32.EAX); break; case InternalType.I8: case InternalType.U8: Memory source = this.GetAddress (value); source.DisplacementDelta = 4; DWordMemory destination = new DWordMemory (memory); destination.DisplacementDelta = 4; this.assembly.MOV (R32.EAX, new DWordMemory (this.GetAddress (value))); this.assembly.MOV (new DWordMemory (memory), R32.EAX); this.assembly.MOV (R32.EAX, new DWordMemory (source)); this.assembly.MOV (new DWordMemory (destination), R32.EAX); break; case InternalType.ValueType: uint size = (uint) this.method.Engine.GetTypeSize (_class.TypeFullName, 4); if (size == 4) { if (value.IsRegisterSet) this.assembly.MOV (R32.EAX, Assembly.GetRegister (value.Register)); else this.assembly.MOV (R32.EAX, new DWordMemory (this.GetAddress (value))); this.assembly.MOV (new DWordMemory (memory), R32.EAX); } else { this.assembly.PUSH (R32.ECX); this.assembly.PUSH (R32.ESI); this.assembly.PUSH (R32.EDI); if (value.IsRegisterSet) this.assembly.MOV (R32.ESI, Assembly.GetRegister (value.Register)); else this.assembly.LEA (R32.ESI, new DWordMemory (this.GetAddress (value))); this.assembly.LEA (R32.EDI, new DWordMemory (memory)); this.assembly.MOV (R32.ECX, size); this.assembly.CLD (); this.assembly.REP (); this.assembly.MOVSB (); this.assembly.POP (R32.EDI); this.assembly.POP (R32.ESI); this.assembly.POP (R32.ECX); } break; case InternalType.R4: case InternalType.R8: case InternalType.F: case InternalType.M: case InternalType.TypedReference: default: throw new NotImplementedEngineException ("Save not supported for InternalType." + destinationType); } }
/// <summary> /// Common implementation for IL instructions which load a value onto the IL evaluation stack. /// </summary> private void Load (IR.Operands.Register assignee, InternalType sourceType, Memory memory) { switch (sourceType) { case InternalType.I1: this.assembly.MOVSX (R32.EAX, new ByteMemory (memory)); if (assignee.IsRegisterSet) this.assembly.MOV (Assembly.GetRegister (assignee.Register), R32.EAX); else this.assembly.MOV (new DWordMemory (this.GetAddress (assignee)), R32.EAX); break; case InternalType.U1: this.assembly.MOVZX (R32.EAX, new ByteMemory (memory)); if (assignee.IsRegisterSet) this.assembly.MOV (Assembly.GetRegister (assignee.Register), R32.EAX); else this.assembly.MOV (new DWordMemory (this.GetAddress (assignee)), R32.EAX); break; case InternalType.I2: this.assembly.MOVSX (R32.EAX, new WordMemory (memory)); if (assignee.IsRegisterSet) this.assembly.MOV (Assembly.GetRegister (assignee.Register), R32.EAX); else this.assembly.MOV (new DWordMemory (this.GetAddress (assignee)), R32.EAX); break; case InternalType.U2: this.assembly.MOVZX (R32.EAX, new WordMemory (memory)); if (assignee.IsRegisterSet) this.assembly.MOV (Assembly.GetRegister (assignee.Register), R32.EAX); else this.assembly.MOV (new DWordMemory (this.GetAddress (assignee)), R32.EAX); break; case InternalType.I4: case InternalType.U4: case InternalType.I: case InternalType.U: case InternalType.O: case InternalType.M: case InternalType.SZArray: case InternalType.Array: this.assembly.MOV (R32.EAX, new DWordMemory (memory)); if (assignee.IsRegisterSet) this.assembly.MOV (Assembly.GetRegister (assignee.Register), R32.EAX); else this.assembly.MOV (new DWordMemory (this.GetAddress (assignee)), R32.EAX); break; case InternalType.I8: case InternalType.U8: DWordMemory source = new DWordMemory (memory); source.DisplacementDelta = 4; Memory destination = this.GetAddress (assignee); destination.DisplacementDelta = 4; this.assembly.MOV (R32.EAX, new DWordMemory (memory)); this.assembly.MOV (new DWordMemory (this.GetAddress (assignee)), R32.EAX); this.assembly.MOV (R32.EAX, new DWordMemory (source)); this.assembly.MOV (new DWordMemory (destination), R32.EAX); break; case InternalType.ValueType: uint size = (uint) assignee.Type.Size; if (size == 4) { this.assembly.MOV (R32.EAX, new DWordMemory (memory)); if (assignee.IsRegisterSet) this.assembly.MOV (Assembly.GetRegister (assignee.Register), R32.EAX); else this.assembly.MOV (new DWordMemory (this.GetAddress (assignee)), R32.EAX); } else { this.assembly.PUSH (R32.ECX); this.assembly.PUSH (R32.ESI); this.assembly.PUSH (R32.EDI); this.assembly.LEA (R32.ESI, new DWordMemory (memory)); if (assignee.IsRegisterSet) this.assembly.MOV (R32.EDI, Assembly.GetRegister (assignee.Register)); else this.assembly.LEA (R32.EDI, new DWordMemory (this.GetAddress (assignee))); this.assembly.MOV (R32.ECX, size); this.assembly.CLD (); this.assembly.REP (); this.assembly.MOVSB (); this.assembly.POP (R32.EDI); this.assembly.POP (R32.ESI); this.assembly.POP (R32.ECX); } break; case InternalType.R4: case InternalType.R8: case InternalType.F: case InternalType.TypedReference: default: throw new NotImplementedEngineException ("Load not supported for InternalType." + sourceType); } }
public static object GetValue(string strValue, InternalType tp) { char[] splitor = new char[] { ';' }; string[] temp_array = null; System.Array array_result = null; switch (tp) { case InternalType.t_Boolean: return Convert.ToBoolean(strValue); case InternalType.t_Byte: return Convert.ToByte(strValue); case InternalType.t_SByte: return Convert.ToSByte(strValue); case InternalType.t_Short: return Convert.ToInt16(strValue); case InternalType.t_UShort: return Convert.ToUInt16(strValue); case InternalType.t_Char: return Convert.ToChar(strValue); case InternalType.t_Enum: return Convert.ToInt32(strValue); case InternalType.t_Int: return Convert.ToInt32(strValue); case InternalType.t_UInt: return Convert.ToUInt32(strValue); case InternalType.t_Long: return Convert.ToInt64(strValue); case InternalType.t_ULong: return Convert.ToUInt64(strValue); case InternalType.t_Float: return Convert.ToSingle(strValue); case InternalType.t_Double: return Convert.ToDouble(strValue); case InternalType.t_String: return strValue; case InternalType.t_Date: return Convert.ToDateTime(strValue); /* unsupported right now InternalType.t_Object, InternalType.t_Value, */ case InternalType.t_ArrayOfBoolean: case InternalType.t_ArrayOfByte: case InternalType.t_ArrayOfSByte: case InternalType.t_ArrayOfShort: case InternalType.t_ArrayOfUShort: case InternalType.t_ArrayOfEnum: case InternalType.t_ArrayOfInt: case InternalType.t_ArrayOfUInt: case InternalType.t_ArrayOfLong: case InternalType.t_ArrayOfULong: case InternalType.t_ArrayOfFloat: case InternalType.t_ArrayOfDouble: case InternalType.t_ArrayOfDate: temp_array = strValue.Split(splitor); array_result = System.Array.CreateInstance(GetSystemTypeSimple(tp), temp_array.Length); for (int i=0; i<temp_array.Length; i++) array_result.SetValue(GetValue(temp_array[i], InternalType.t_Boolean), i); return array_result; case InternalType.t_ArrayOfString: //array of string is a little bit different return null; case InternalType.t_ArrayOfChar: //array of char is a little bit different return null; /* InternalType.t_ArrayOfObject, InternalType.t_ArrayOfValue, */ case InternalType.t_Unsupported: throw new OOD.Exception.NotImplemented( null, "This data type is not supported yet."); } return null; }
/// <summary> /// Convert the val to a byte array. /// </summary> /// <param name="val"></param> /// <param name="tp"></param> /// <returns></returns> public static byte[] GetByteArray(object val, InternalType tp) { int offset = 0; byte[] result = null; switch (tp) { case InternalType.t_Boolean: return BitConverter.GetBytes((bool)val); case InternalType.t_Byte: return new byte[] { (byte)val }; case InternalType.t_SByte: return BitConverter.GetBytes((byte)val); case InternalType.t_Short: return BitConverter.GetBytes((short)val); case InternalType.t_UShort: return BitConverter.GetBytes((ushort)val); case InternalType.t_Char: return BitConverter.GetBytes((char)val); case InternalType.t_Enum: return BitConverter.GetBytes((short)val); case InternalType.t_Int: return BitConverter.GetBytes((int)val); case InternalType.t_UInt: return BitConverter.GetBytes((uint)val); case InternalType.t_Long: return BitConverter.GetBytes((long)val); case InternalType.t_ULong: return BitConverter.GetBytes((ulong)val); case InternalType.t_Float: return BitConverter.GetBytes((float)val); case InternalType.t_Double: return BitConverter.GetBytes((double)val); case InternalType.t_String: return System.Text.ASCIIEncoding.ASCII.GetBytes((string)val); case InternalType.t_Date: long t_ticks = ((DateTime)val).Ticks; return BitConverter.GetBytes(t_ticks); /* FORMAT for array */ // [Lenght] [xx] [xxx] [xx] // 2 bytes // case InternalType.t_ArrayOfBoolean: // bool[] t_b_array = (bool[])val; // result = new byte[t_b_array.Length+2]; // for (int i=0; i<t_b_array.Length; i++) // { // byte[] t = BitConverter.GetBytes(t_b_array[i]); // result[i] = t[0]; // } // return result; // case InternalType.t_ArrayOfByte: // return (byte[])val; // case InternalType.t_ArrayOfSByte: // sbyte[] t_sb_in = (sbyte[])val; // byte[] t_b_out = new byte[t_sb_in.Length]; // for (int i=0; i<t_sb_in.Length; i++) // t_b_out[i] = (byte)t_sb_in[i]; // return t_b_out; // case InternalType.t_ArrayOfShort: // short[] t_short_in = (short[])val; // byte[] t_short_out = new byte[t_short_in.Length<<1]; // int short_offset = 0; // for (int i=0; i<t_short_in.Length; i++) // { // Utility.Bytes.Pack2(t_short_out, short_offset, t_short_in[i]); // short_offset += 2; // } // return t_short_out; // case InternalType.t_ArrayOfUShort: // ushort[] t_ushort_in = (ushort[])val; // byte[] t_ushort_out = new byte[t_ushort_in.Length<<1]; // int ushort_offset = 0; // for (int i=0; i<t_ushort_in.Length; i++) // { // Utility.Bytes.Pack2U(t_ushort_out, ushort_offset, t_ushort_in[i]); // ushort_offset += 2; // } // return t_ushort_out; // case InternalType.t_ArrayOfEnum: // System.Array t_enum_in = (System.Array)val; // byte[] t_enum_out = new byte[t_enum_in.Length<<1]; // int enum_offset = 0; // for (int i=0; i<t_enum_in.Length; i++) // { // Utility.Bytes.Pack2(t_enum_out, enum_offset, (short)t_enum_in.GetValue(i)); // enum_offset += 2; // } // return t_enum_out; // case InternalType.t_ArrayOfInt: // int[] t_int_in = (int[]) val; // byte[] t_int_out = new byte[t_int_in.Length << 2]; // int int_offset = 0; // for (int i=0; i<t_int_in.Length; i++) // { // Utility.Bytes.Pack4(t_int_out, int_offset, t_int_in[i]); // int_offset += 4; // } // return t_int_out; // case InternalType.t_ArrayOfUInt: // uint[] t_uint_in = (uint[])val; // byte[] t_uint_out = new byte[t_uint_in.Length << 2]; // int uint_offset = 0; // for (int i=0; i<t_uint_in.Length; i++) // { // Utility.Bytes.Pack4U(t_uint_out, uint_offset, t_uint_in[i]); // uint_offset += 4; // } // return t_uint_out; // case InternalType.t_ArrayOfLong: // long[] t_long_in = (long[])val; // byte[] t_long_out = new byte[t_long_in.Length << 3]; // int long_offset = 0; // for (int i=0; i<t_long_in.Length; i++) // { // Utility.Bytes.Pack8(t_long_out, long_offset, t_long_in[i]); // long_offset += 8; // } // return t_long_out; // case InternalType.t_ArrayOfULong: // ulong[] t_ulong_in = (ulong[])val; // byte[] t_ulong_out = new byte[t_ulong_in.Length << 3]; // int ulong_offset = 0; // for (int i=0; i<t_ulong_in.Length; i++) // { // Utility.Bytes.Pack8(t_ulong_out, ulong_offset, t_ulong_in[i]); // ulong_offset += 8; // } // return t_ulong_out; // case InternalType.t_ArrayOfFloat: //4 bytes // float[] t_float_in = (float[])val; // byte[] t_float_out = new byte[t_float_in.Length << 2]; // int float_offset = 0; // for (int i=0; i<t_float_in.Length; i++) // { // byte[] bf = BitConverter.GetBytes(t_float_in[i]); // Array.Copy(bf, 0, t_float_out, float_offset, 4); // float_offset += 4; // } // return t_float_out; // case InternalType.t_ArrayOfDouble: //8 bytes // float[] t_float_in = (float[])val; // byte[] t_float_out = new byte[t_float_in.Length << 2]; // int float_offset = 0; // for (int i=0; i<t_float_in.Length; i++) // { // byte[] bf = BitConverter.GetBytes(t_float_in[i]); // Array.Copy(bf, 0, t_float_out, float_offset, 4); // float_offset += 4; // } // return t_float_out; case InternalType.t_ArrayOfDate: case InternalType.t_ArrayOfString: //array of string is a little bit different return null; case InternalType.t_ArrayOfChar: //array of char is a little bit different return null; /* InternalType.t_ArrayOfObject, InternalType.t_ArrayOfValue, */ case InternalType.t_Unsupported: throw new OOD.Exception.NotImplemented( null, "This data type is not supported yet."); } return null; }
/// <summary> /// Initializes a new instance of the <see cref="Ldelem"/> class. /// </summary> /// <param name="type">The type.</param> /// <param name="result">The result.</param> /// <param name="first">The first.</param> /// <param name="second">The second.</param> public Ldelem (InternalType type, Register result, Register first, Register second) : base ("Ldelem", result, new Operand [] { first, second }) { this.type = type; result.InternalType = this.AdjustRegisterInternalType (type); }
/// <summary> /// Initializes a new instance of the <see cref="Stind"/> class. /// </summary> /// <param name="type">The type.</param> /// <param name="result">The result.</param> /// <param name="value">The value.</param> public Stind (InternalType type, Register result, Register value) : base ("Stind", null, new Operand [] { result, value }) { this.type = type; }
/// <summary> /// Takes a type and the index in the function of a parameter /// </summary> public FormalDescriptor(InternalType type, string name, string modifier) : base(type) { Name = name; Modifier = modifier; }
/// <summary> /// Spills the specified type. /// </summary> /// <param name="type">The type.</param> /// <returns></returns> public bool Spill (InternalType type) { if (type == InternalType.NotSet) throw new EngineException ("Size Type not set."); if (type == InternalType.I8 || type == InternalType.U8 || type == InternalType.R4 || type == InternalType.R8 || type == InternalType.ValueType) return true; return false; }
/// <summary> /// Initializes a new instance of the <see cref="Stelem"/> class. /// </summary> /// <param name="type">The type.</param> /// <param name="first">The first.</param> /// <param name="second">The second.</param> /// <param name="value">The value.</param> public Stelem (InternalType type, Register first, Register second, Register value) : base ("Stelem", null, new Operand [] { first, second, value }) { this.type = type; }