Пример #1
0
            public void WriteIn(string identifier)
            {
                Trace.WriteLine(string.Format("Writing into {0}", identifier));
                //the intercal model is stream-based - calling WriteIn reads as
                //many chars as there are in the array (or fewer if EOF is reached)
                //Console.Write("{0}?>", s);

                int[] idx = new int[1];

                if ((identifier[0] == ',') || (identifier[0] == ';'))
                {
                    ArrayVariable av = this.Variables[identifier] as ArrayVariable;
                    if (av.Rank != 1)
                    {
                        throw new IntercalException(Messages.E241);
                    }

                    for (int i = av.GetLowerBound(0); i <= av.GetUpperBound(0); i++)
                    {
                        idx[0] = i;

                        uint c = (uint)BinaryOut.ReadChar();

                        uint v = (c - this.LastIn) % 256;
                        this.LastIn = c;

                        Trace.WriteLine(string.Format("Writing '{0}' into index {1}", (char)c, i));
                        this[identifier, idx] = v;
                    }
                }
                else
                {
                    string input = TextIn.ReadLine();
                    try
                    {
                        //Note that this compiler today only works in wimpmode.  To do it
                        //right we will need to have satellite assemblies, one for each of
                        //many different languages.
                        this[identifier] = UInt32.Parse(input);
                    }
                    catch
                    {
                        Lib.Fail(String.Format(Messages.E579, input));
                    }
                }
            }