Exemplo n.º 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);
        }
Exemplo n.º 2
0
 public static bool DeepEquals(LToken x, LToken y)
 {
     if (x == null || y == null)
     {
         return(x == null && y == null);
     }
     return(x.DeepEquals(y));
 }
Exemplo n.º 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;
 }
Exemplo n.º 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));
        }
Exemplo n.º 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));
        }
Exemplo n.º 6
0
 /// <inheritdoc />
 internal override bool DeepEquals(LToken other)
 {
     return(Equals(other));
 }
Exemplo n.º 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)
 {
 }
Exemplo n.º 8
0
 internal abstract bool DeepEquals(LToken other);
Exemplo n.º 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));
 }
Exemplo n.º 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);
 }