Пример #1
0
        /// <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);
        }
Пример #2
0
        /// <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);
        }
Пример #3
0
        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);
        }
Пример #4
0
        /// <summary>
        /// Adds a statevariable to the code. If you want persistent storage, you need to set these vars
        /// </summary>
        /// <param name="name">The name of the State. Internally will always have "S_" prefix</param>
        /// <param name="value">The startvalue</param>
        public Smartcontract AddVariable(string name, ISCType value)
        {
            IsFinalized = false;

            if (Code.Variables.ContainsKey(name))
            {
                Code.Variables[name] = value;
            }
            else
            {
                Code.Variables.Add(name, value);
            }
            return(this);
        }