Esempio n. 1
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="ObjectCallingOn">Object calling on</param>
 /// <param name="Method">Method builder</param>
 /// <param name="MethodCalling">Method calling on the object</param>
 /// <param name="Parameters">List of parameters to send in</param>
 public Call(IMethodBuilder Method, VariableBase ObjectCallingOn, MethodInfo MethodCalling, object[] Parameters)
     : base()
 {
     this.ObjectCallingOn = ObjectCallingOn;
     this.MethodCalling = MethodCalling;
     this.MethodCallingFrom = Method;
     if (MethodCalling.ReturnType != null && MethodCalling.ReturnType != typeof(void))
     {
         Result = Method.CreateLocal(MethodCalling.Name + "ReturnObject"+Company.Utilities.Reflection.Emit.BaseClasses.MethodBase.ObjectCounter.ToString(CultureInfo.InvariantCulture), MethodCalling.ReturnType);
     }
     if (Parameters != null)
     {
         this.Parameters = new VariableBase[Parameters.Length];
         for (int x = 0; x < Parameters.Length; ++x)
         {
             if (Parameters[x] is VariableBase)
                 this.Parameters[x] = (VariableBase)Parameters[x];
             else
                 this.Parameters[x] = MethodCallingFrom.CreateConstant(Parameters[x]);
         }
     }
     else
     {
         this.Parameters = null;
     }
 }
Esempio n. 2
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="LeftHandSide">Left hand side</param>
 /// <param name="Value">Value to store</param>
 public Assign(VariableBase LeftHandSide, object Value)
     : base()
 {
     if (LeftHandSide == null)
         throw new ArgumentNullException("LeftHandSide");
     this.LeftHandSide = LeftHandSide;
     VariableBase TempValue = Value as VariableBase;
     this.RightHandSide = TempValue == null ? Company.Utilities.Reflection.Emit.BaseClasses.MethodBase.CurrentMethod.CreateConstant(Value) : TempValue;
 }
Esempio n. 3
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="EndIfLabel">End if label (for this else if)</param>
 /// <param name="ComparisonType">Comparison type</param>
 /// <param name="LeftHandSide">Left hand side</param>
 /// <param name="RightHandSide">Right hand side</param>
 public ElseIf(Label EndIfLabel, Comparison ComparisonType, VariableBase LeftHandSide, VariableBase RightHandSide)
     : base()
 {
     this.EndIfLabel = EndIfLabel;
     if (LeftHandSide != null)
         this.LeftHandSide = LeftHandSide;
     else
         this.LeftHandSide = Company.Utilities.Reflection.Emit.BaseClasses.MethodBase.CurrentMethod.CreateConstant(null);
     if (RightHandSide != null)
         this.RightHandSide = RightHandSide;
     else
         this.RightHandSide = Company.Utilities.Reflection.Emit.BaseClasses.MethodBase.CurrentMethod.CreateConstant(null);
     this.ComparisonType = ComparisonType;
 }
Esempio n. 4
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="ComparisonType">Comparison type</param>
 /// <param name="LeftHandSide">Left hand side</param>
 /// <param name="RightHandSide">Right hand side</param>
 public While(Comparison ComparisonType, VariableBase LeftHandSide, VariableBase RightHandSide)
     : base()
 {
     ILGenerator Generator = Company.Utilities.Reflection.Emit.BaseClasses.MethodBase.CurrentMethod.Generator;
     this.StartWhileLabel = Generator.DefineLabel();
     this.EndWhileLabel = Generator.DefineLabel();
     if (LeftHandSide != null)
         this.LeftHandSide = LeftHandSide;
     else
         this.LeftHandSide = Company.Utilities.Reflection.Emit.BaseClasses.MethodBase.CurrentMethod.CreateConstant(null);
     if (RightHandSide != null)
         this.RightHandSide = RightHandSide;
     else
         this.RightHandSide = Company.Utilities.Reflection.Emit.BaseClasses.MethodBase.CurrentMethod.CreateConstant(null);
     this.ComparisonType = ComparisonType;
 }
Esempio n. 5
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="ObjectCallingOn">Object calling on</param>
 /// <param name="Method">Method builder</param>
 /// <param name="MethodCalling">Method calling on the object</param>
 /// <param name="Parameters">List of parameters to send in</param>
 public Call(IMethodBuilder Method, VariableBase ObjectCallingOn, ConstructorInfo MethodCalling, object[] Parameters)
     : base()
 {
     this.ObjectCallingOn = ObjectCallingOn;
     this.ConstructorCalling = MethodCalling;
     this.MethodCallingFrom = Method;
     if (Parameters != null)
     {
         this.Parameters = new VariableBase[Parameters.Length];
         for (int x = 0; x < Parameters.Length; ++x)
         {
             if (Parameters[x] is VariableBase)
                 this.Parameters[x] = (VariableBase)Parameters[x];
             else
                 this.Parameters[x] = MethodCallingFrom.CreateConstant(Parameters[x]);
         }
     }
     else
     {
         this.Parameters = null;
     }
 }
Esempio n. 6
0
 /// <summary>
 /// Sets up a property (List)
 /// </summary>
 /// <param name="Method">Method builder</param>
 /// <param name="BaseType">Base type for the object</param>
 /// <param name="ReturnValue">Return value</param>
 /// <param name="Property">Property info</param>
 /// <param name="Mapping">Mapping info</param>
 private void SetupListProperty(IMethodBuilder Method, Type BaseType, VariableBase ReturnValue, IProperty Property, IMapping Mapping)
 {
     Company.Utilities.Reflection.Emit.FieldBuilder Field = Fields.Find(x => x.Name == Property.DerivedFieldName);
     Company.Utilities.Reflection.Emit.Commands.If If1 = Method.If((VariableBase)SessionField, Comparison.NotEqual, null);
     {
         Company.Utilities.Reflection.Emit.Commands.If If2 = Method.If(Field, Comparison.Equal, null);
         {
             //Load data
             VariableBase IDValue = Method.This.Call(BaseType.GetProperty(Mapping.IDProperty.Name).GetGetMethod());
             VariableBase IDParameter = Method.NewObj(typeof(EqualParameter<>).MakeGenericType(Mapping.IDProperty.Type), new object[] { IDValue, "ID", "@" });
             VariableBase PropertyList = Method.NewObj(typeof(List<IParameter>));
             PropertyList.Call("Add", new object[] { IDParameter });
             MethodInfo LoadPropertiesMethod = typeof(Session).GetMethod("LoadListProperties");
             LoadPropertiesMethod = LoadPropertiesMethod.MakeGenericMethod(new Type[] { BaseType, Field.DataType.GetGenericArguments()[0] });
             VariableBase ReturnVal = ((VariableBase)SessionField).Call(LoadPropertiesMethod, new object[] { Method.This, Property.Name, PropertyList.Call("ToArray") });
             Field.Assign(ReturnVal);
         }
         If2.EndIf();
         PropertyInfo CountProperty=Field.DataType.GetProperty("Count");
         Company.Utilities.Reflection.Emit.Commands.If If4 = Method.If(Field.Call(CountProperty.GetGetMethod()), Comparison.Equal, Method.CreateConstant(0));
         {
             //Load data
             VariableBase IDValue = Method.This.Call(BaseType.GetProperty(Mapping.IDProperty.Name).GetGetMethod());
             VariableBase IDParameter = Method.NewObj(typeof(EqualParameter<>).MakeGenericType(Mapping.IDProperty.Type), new object[] { IDValue, "ID", "@" });
             VariableBase PropertyList = Method.NewObj(typeof(List<IParameter>));
             PropertyList.Call("Add", new object[] { IDParameter });
             MethodInfo LoadPropertiesMethod = typeof(Session).GetMethod("LoadProperties");
             LoadPropertiesMethod = LoadPropertiesMethod.MakeGenericMethod(new Type[] { BaseType, Field.DataType.GetGenericArguments()[0] });
             VariableBase ReturnVal = ((VariableBase)SessionField).Call(LoadPropertiesMethod, new object[] { Method.This, Property.Name, PropertyList.Call("ToArray") });
             Field.Assign(ReturnVal);
         }
         If4.EndIf();
         Company.Utilities.Reflection.Emit.Commands.If If3 = Method.If(Field, Comparison.Equal, null);
         {
             Field.Assign(Method.NewObj(typeof(List<>).MakeGenericType(Property.Type).GetConstructor(Type.EmptyTypes)));
         }
         If3.EndIf();
     }
     If1.EndIf();
     ReturnValue.Assign(Field);
 }
Esempio n. 7
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="Exception">Exception to throw</param>
 public Throw(VariableBase Exception)
 {
     this.Exception = Exception;
 }
Esempio n. 8
0
 /// <summary>
 /// Sets up the command
 /// </summary>
 public override void Setup()
 {
     ILGenerator Generator = Company.Utilities.Reflection.Emit.BaseClasses.MethodBase.CurrentMethod.Generator;
     if (RightHandSide.DataType.IsValueType
         && !LeftHandSide.DataType.IsValueType)
     {
         RightHandSide = Company.Utilities.Reflection.Emit.BaseClasses.MethodBase.CurrentMethod.Box(RightHandSide);
     }
     else if (!RightHandSide.DataType.IsValueType
         && LeftHandSide.DataType.IsValueType)
     {
         RightHandSide = Company.Utilities.Reflection.Emit.BaseClasses.MethodBase.CurrentMethod.UnBox(RightHandSide, LeftHandSide.DataType);
     }
     else if (!RightHandSide.DataType.IsValueType
         && !LeftHandSide.DataType.IsValueType
         && RightHandSide.DataType != LeftHandSide.DataType)
     {
         RightHandSide = Company.Utilities.Reflection.Emit.BaseClasses.MethodBase.CurrentMethod.Cast(RightHandSide, LeftHandSide.DataType);
     }
     if (LeftHandSide is FieldBuilder || LeftHandSide is IPropertyBuilder)
         Generator.Emit(OpCodes.Ldarg_0);
     if (RightHandSide is FieldBuilder || RightHandSide is IPropertyBuilder)
         Generator.Emit(OpCodes.Ldarg_0);
     RightHandSide.Load(Generator);
     if (RightHandSide.DataType != LeftHandSide.DataType)
     {
         if (ConversionOpCodes.ContainsKey(LeftHandSide.DataType))
         {
             Generator.Emit(ConversionOpCodes[LeftHandSide.DataType]);
         }
     }
     LeftHandSide.Save(Generator);
 }
Esempio n. 9
0
 /// <summary>
 /// Defines an else if statement
 /// </summary>
 /// <param name="ComparisonType">Comparison type</param>
 /// <param name="LeftHandSide">left hand side value</param>
 /// <param name="RightHandSide">right hand side value</param>
 public virtual void ElseIf(VariableBase LeftHandSide, Comparison ComparisonType, VariableBase RightHandSide)
 {
     ILGenerator Generator = Company.Utilities.Reflection.Emit.BaseClasses.MethodBase.CurrentMethod.Generator;
     Generator.Emit(OpCodes.Br, EndIfFinalLabel);
     Generator.MarkLabel(EndIfLabel);
     EndIfLabel = Generator.DefineLabel();
     Company.Utilities.Reflection.Emit.BaseClasses.MethodBase.CurrentMethod.Commands.Add(new ElseIf(EndIfLabel, ComparisonType, LeftHandSide, RightHandSide));
 }
Esempio n. 10
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="Value">Value to cast</param>
 /// <param name="ValueType">Desired type to cast to</param>
 public Cast(VariableBase Value,Type ValueType)
     : base()
 {
     this.Value = Value;
     this.ValueType = ValueType;
 }