/// <summary> /// Performs a binary arithmetic operation and returns the result. /// </summary> /// <param name="type">The type of operation to perform.</param> /// <param name="self">The first value to use.</param> /// <returns>The result of the operation.</returns> /// <exception cref="System.InvalidOperationException"> /// If the operation cannot be performed with the given values. /// </exception> /// <exception cref="System.InvalidArgumentException"> /// If the argument is an invalid value. /// </exception> ILuaValue ILuaValueVisitor.Arithmetic(BinaryOperationType type, LuaValues.LuaTable self) { var ret = LuaValueBase.AttempMetamethod(type, self, this); if (ret != null) { return(ret); } throw new InvalidOperationException(Errors.CannotArithmetic(LuaValueType.Table)); }
public static void Initialize(ILuaEnvironment E) { ILuaTable io = new LuaValues.LuaTable(); io.SetItemRaw(new LuaString("close"), new close(E)); io.SetItemRaw(new LuaString("flush"), new flush(E)); io.SetItemRaw(new LuaString("input"), new input(E)); io.SetItemRaw(new LuaString("lines"), new lines(E)); io.SetItemRaw(new LuaString("open"), new open(E)); io.SetItemRaw(new LuaString("output"), new output(E)); io.SetItemRaw(new LuaString("read"), new read(E)); io.SetItemRaw(new LuaString("tmpfile"), new tmpfile(E)); io.SetItemRaw(new LuaString("type"), new type(E)); io.SetItemRaw(new LuaString("write"), new write(E)); _input = E.Settings.Stdin; _output = E.Settings.Stdout; var _globals = E.GlobalsTable; _globals.SetItemRaw(new LuaString("io"), io); _globals.SetItemRaw(new LuaString("dofile"), new dofile(E)); _globals.SetItemRaw(new LuaString("load"), new load(E)); _globals.SetItemRaw(new LuaString("loadfile"), new loadfile(E)); _globals.SetItemRaw(new LuaString("_STDIN"), _CreateFile(E.Settings.Stdin, E)); _globals.SetItemRaw(new LuaString("_STDOUT"), _CreateFile(E.Settings.Stdout, E)); }
/// <summary> /// Performs a binary arithmetic operation and returns the result. /// </summary> /// <param name="type">The type of operation to perform.</param> /// <param name="self">The first value to use.</param> /// <returns>The result of the operation.</returns> /// <exception cref="System.InvalidOperationException"> /// If the operation cannot be performed with the given values. /// </exception> /// <exception cref="System.InvalidArgumentException"> /// If the argument is an invalid value. /// </exception> public override ILuaValue Arithmetic(BinaryOperationType type, LuaValues.LuaTable self) { return(self.Arithmetic(type, values_[0])); }
static ILuaTable _CreateFile(Stream backing, ILuaEnvironment E) { ILuaTable ret = new LuaValues.LuaTable(); ret.SetItemRaw(_stream, new LuaValues.LuaUserData<Stream>(backing)); ret.SetItemRaw(new LuaString("close"), new close(E)); ret.SetItemRaw(new LuaString("flush"), new flush(E)); ret.SetItemRaw(new LuaString("lines"), new lines(E)); ret.SetItemRaw(new LuaString("read"), new read(E)); ret.SetItemRaw(new LuaString("seek"), new seek(E)); ret.SetItemRaw(new LuaString("write"), new write(E)); return ret; }