Clone() public method

public Clone ( ) : BigWire
return BigWire
示例#1
0
        private BigWire GetWireFromString(string st)
        {
            if (st.StartsWith("("))
            {
                return(CreateParenthesesWire(st, false));
            }

            BigWire wire = null;

            if (varsToWires.ContainsKey(st))
            {
                wire = varsToWires[st];
                if (wire.IsOutput && wire.SourceGate == null)
                {
                    throw new Exception("Variable " + st + " was not initialized");
                }
            }

            if (wire != null)
            {
                if (wire.TargetGate != null)
                {
                    return(wire.Clone());
                }
                else
                {
                    return(wire);
                }
            }

            int value;

            try
            {
                value = Convert.ToInt32(st);
            }
            catch (Exception)
            {
                if (st.Contains("("))
                {
                    throw new Exception("No operation before opening ( in expression: " + st);
                }
                throw new Exception("variable '" + st + "' is not defined");
            }
            return(new BigWire(new BigZp(prime, value)));
        }