private void IntroduceMetaData(Expression exp) { //first we need to get the index int index = exp.Args1.ConvertToInternalType().GetValueAs <int>(); //we then get the metadata if (exp.Args1.Equals("Int_0")) { Register.AddToRegister(exp.Args2, ("Str_" + InTrans.Hash).ConvertToInternalType()); } else if (exp.Args1.Equals("Int_1")) { Register.AddToRegister(exp.Args2, ("Str_" + InTrans.SendTo).ConvertToInternalType()); } else if (exp.Args1.Equals("Int_2")) { Register.AddToRegister(exp.Args2, ("Lon_" + InTrans.Time).ConvertToInternalType()); } else if (exp.Args1.Equals("Int_3")) { Register.AddToRegister(exp.Args2, ("Str_" + InTrans.From).ConvertToInternalType()); } else if (exp.Args1.Equals("Int_4")) { Register.AddToRegister(exp.Args2, ("Int_" + InTrans.ComputeOutgoingValues()).ConvertToInternalType()); } else { throw new ArgumentException("Wrong Index"); } }
/// <summary> /// Loads an <see cref="AI"/> to the <see cref="Register"/> with the set parameters /// </summary> /// <param name="type">The <see cref="Type"/> of <see cref="AI"/></param> /// <param name="name">The name of the <see cref="AI"/></param> /// <param name="inventory">The <see cref="Inventory"/> of the <see cref="AI"/></param> /// <param name="level">The level of the <see cref="AI"/></param> public AI(Type type, string name, Inventory inventory, short level) { this.type = type; this.name = name; this.level = level; this.inventory = inventory; Register.AddToRegister(this); }
/// <summary> /// Creates a new <see cref="AI"/> of <see cref="Type"/> <paramref name="type"/> with the set <paramref name="name"/> and adds it to the <see cref="Register"/> /// </summary> /// <param name="type">The <see cref="Type"/> of <see cref="AI"/></param> /// <param name="name">The name of the <see cref="AI"/></param> public AI(Type type, string name) { this.type = type; this.name = name; level = 1; inventory = new Inventory(); Register.AddToRegister(this); }
/// <summary> /// Copys a register into another register /// </summary> /// <param name="exp"></param> private void Copy(Expression exp) { //first we get the register value: ISCType obj = Register.GetFromRegister(exp.Args1); //we then move the obj to args2 Register.AddToRegister(exp.Args2, obj); }
/// <summary> /// Introduces a value (like 1, "100") into a register /// </summary> /// <param name="exp"></param> private void IntroduceValue(Expression exp) { //first we convert args1 to an isctype ISCType obj = exp.Args1.ConvertToInternalType(); //we then store it in args2 Register.AddToRegister(exp.Args2, obj); }
private void IntroduceStateVariable(Expression exp) { //first we get the state variable from args1 var variable = State.GetFromRegister(exp.Args1); //we then copy to args2 Register.AddToRegister(exp.Args2, variable); }
private void SwitchRegister(Expression exp) { //get both values var args1Obj = Register.GetFromRegister(exp.Args1); var args2Obj = Register.GetFromRegister(exp.Args2); Register.AddToRegister(exp.Args2, args1Obj); Register.AddToRegister(exp.Args1, args2Obj); }
/// <summary> /// Loads the specified <see cref="Building"/> of <see cref="Type"/> <paramref name="type"/> with the set parameters and adds it to the <see cref="Register"/> /// </summary> /// <param name="type">The <see cref="Type"/> of <see cref="Building"/></param> /// <param name="value">The value of this <see cref="Building"/></param> /// <param name="name">The name of this <see cref="Building"/></param> /// <param name="desc">The description of this <see cref="Building"/></param> /// <param name="inventory">The <see cref="Inventory"/> of this <see cref="Building"/></param> /// <param name="level">The level of this <see cref="Building"/></param> public Building(Type type, double value, string name, string desc, Inventory inventory, short level) { this.type = type; this.value = value; this.name = name; this.desc = desc; this.inventory = inventory; this.level = level; Register.AddToRegister(this); }
private void IntroduceTransactionData(Expression exp) { //first we need to get the index int index = exp.Args1.ConvertToInternalType().GetValueAs <int>(); //we then get the data of the data entry ISCType data = Data[index].ConvertToInternalType(); //we then write data into args2 Register.AddToRegister(exp.Args2, data); }
/// <summary> /// adds two registers together and stores them inside another register /// </summary> /// <param name="exp"></param> private void Add(Expression exp) { //we get args1 and args2 as isctypes var args1Obj = Register.GetFromRegister(exp.Args1); var args2Obj = Register.GetFromRegister(exp.Args2); //we add them together var obj = args1Obj.Add(args2Obj); //we store in args3 now Register.AddToRegister(exp.Args3, obj); }
/// <summary> /// Multiplies two registers together and stores them inside another register /// </summary> /// <param name="exp"></param> private void Multiply(Expression exp) { //first get args 1 and args2 var args1Obj = Register.GetFromRegister(exp.Args1); var args2Obj = Register.GetFromRegister(exp.Args2); //we multiply them together var obj = args1Obj.Multiply(args2Obj); //we store in args3 now Register.AddToRegister(exp.Args3, obj); }
private void Negate(Expression exp) { var args1Obj = Register.GetFromRegister(exp.Args1); if (args1Obj.IsEqual(new SC_Int(0))) { Register.AddToRegister(exp.Args1, new SC_Int(1)); } else { Register.AddToRegister(exp.Args1, new SC_Int(0)); } }
/// <summary> /// Creates a new <see cref="Building"/> of <see cref="Type"/> <paramref name="type"/> with the set parameters and adds it to the <see cref="Register"/> /// </summary> /// <param name="type">The <see cref="Type"/> of <see cref="Building"/></param> /// <param name="value">The value of this <see cref="Building"/></param> /// <param name="name">The name of this <see cref="Building"/></param> /// <param name="desc">The description of this <see cref="Building"/></param> /// <param name="noInv">Set to <see langword="true"/> if populating <see cref="Database"/></param> public Building(Type type, double value, string name, string desc, bool noInv = false) { this.type = type; this.value = value; this.name = name; this.desc = desc; level = 1; if (!noInv) { inventory = new Inventory(); Register.AddToRegister(this); } }
private void IntroduceData(Expression exp) { //we first get args1 as int var index = exp.Args1.ConvertToInternalType().GetValueAs <int>(); try { //write data to args2 Register.AddToRegister(exp.Args2, Data[index].ConvertToInternalType()); } catch (Exception) { throw new ArgumentException("Data register probl doesnt exists!"); } }
private void Or(Expression exp) { //get both values var args1Obj = Register.GetFromRegister(exp.Args1); var args2Obj = Register.GetFromRegister(exp.Args2); if (args1Obj.IsEqual(new SC_Int(1)) || args2Obj.IsEqual(new SC_Int(1))) { Register.AddToRegister(exp.Args3, new SC_Int(1)); } else { Register.AddToRegister(exp.Args3, new SC_Int(0)); } }
private void IsEqual(Expression exp) { //get both values var args1Obj = Register.GetFromRegister(exp.Args1); var args2Obj = Register.GetFromRegister(exp.Args2); //we branch if (!args2Obj.IsEqual(args1Obj)) { Register.AddToRegister(exp.Args3, new SC_Int(0)); } else { Register.AddToRegister(exp.Args3, new SC_Int(1)); } }