Beispiel #1
0
        /// <inheritdoc />
        internal override bool DeepEquals(LToken other)
        {
            var y = other as LTable;

            if (y == null)
            {
                return(false);
            }
            if (ReferenceEquals(this, y))
            {
                return(true);
            }
            if (store.Count != y.store.Count)
            {
                return(false);
            }
            var count = store.Count;

            for (int i = 0; i < count; i++)
            {
                if (!DeepEquals(store[i], y.store[i]))
                {
                    return(false);
                }
            }
            return(true);
        }
Beispiel #2
0
 public static bool DeepEquals(LToken x, LToken y)
 {
     if (x == null || y == null)
     {
         return(x == null && y == null);
     }
     return(x.DeepEquals(y));
 }
Beispiel #3
0
 /// <summary>
 /// Initializes a new Lua table field with the specified name and value.
 /// </summary>
 /// <param name="name">Name of the field. Use <c>null</c> for positional field.</param>
 /// <param name="value">Value of the field. Can be <c>null</c>, which means <see cref="LValue.Nil"/>.</param>
 /// <exception cref="ArgumentException"><paramref name="name"/>.<see cref="LValue.TokenType"/> is <see cref="LTokenType.Nil"/>.</exception>
 public LField(LValue name, LToken value)
 {
     if (name != null && name.TokenType == LTokenType.Nil)
     {
         throw new ArgumentException("Cannot use nil as field name.");
     }
     Name   = name;
     _Value = value ?? LValue.Nil;
 }
Beispiel #4
0
        /// <inheritdoc />
        internal override bool DeepEquals(LToken other)
        {
            var y = other as LField;

            if (y == null)
            {
                return(false);
            }
            return(DeepEquals(Name, y.Name) && DeepEquals(_Value, y._Value));
        }
Beispiel #5
0
        public new static LField Load(LuaTableTextReader reader)
        {
            if (reader == null)
            {
                throw new ArgumentNullException(nameof(reader));
            }
            if (reader.CurrentToken == LuaTableReaderToken.None)
            {
                reader.Read();
            }
            SkipComments(reader);
            LValue key = null;

            if (reader.CurrentToken == LuaTableReaderToken.Key)
            {
                key = new LValue(reader.CurrentValue);
                reader.Read();
                SkipComments(reader);
            }
            LToken value = LToken.Load(reader);

            return(new LField(key, value));
        }
Beispiel #6
0
 /// <inheritdoc />
 internal override bool DeepEquals(LToken other)
 {
     return(Equals(other));
 }
Beispiel #7
0
 /// <summary>
 /// Initializes a new positional Lua table field with the specified name and value.
 /// </summary>
 /// <inheritdoc cref="LField(LValue,LToken)"/>
 public LField(LToken value) : this(null, value)
 {
 }
Beispiel #8
0
 internal abstract bool DeepEquals(LToken other);
Beispiel #9
0
 /// <summary>
 /// Inserts a field at the end of the table expression.
 /// </summary>
 /// <param name="name">The name of the new field to be appended.</param>
 /// <param name="value">The value of the new field to be appended. <c>null</c> will be treated the same as <see cref="LValue.Nil"/>.</param>
 public void Add(LValue name, LToken value)
 {
     store.Add(new LField(name, value));
 }
Beispiel #10
0
 /// <summary>
 /// Inserts a new positional field at the end of the table expression.
 /// </summary>
 /// <param name="value">The value of the new field to be appended. <c>null</c> will be treated the same as <see cref="LValue.Nil"/>.</param>
 public void Add(LToken value)
 {
     Add(null, value);
 }