Пример #1
0
        private HassiumObject query(HassiumObject[] args)
        {
            MySqlCommand command = new MySqlCommand(null, Value);
            command.CommandText = "INSERT INTO " + args[0] + "(";
            HassiumObject[] vals = ((HassiumArray)args[1]).Value;
            command.CommandText += vals[0].ToString();
            for (int x = 1; x < vals.Length; x++)
                command.CommandText += ", " + vals[x].ToString();
            command.CommandText += ") VALUES (";
            command.CommandText += "@" + vals[0].ToString();
            for (int x = 1; x < vals.Length; x++)
            command.CommandText += ", @" + vals[x].ToString();
            command.CommandText += ")";

            HassiumObject[] lits = ((HassiumArray)args[2]).Value;
            for (int x = 0; x < lits.Length; x++) {
            MySqlParameter param = new MySqlParameter("@" + vals[x].ToString(), lits[x].ToString());
            param.Value = lits[x].ToString();
            command.Parameters.Add(param);
            }
            // Console.WriteLine(command.CommandText);

            command.Prepare();
            command.ExecuteNonQuery();

            return null;
        }
 public HassiumStream getStream(VirtualMachine vm, HassiumObject[] args)
 {
     if (args.Length == 1)
     if (args[0].ToBool(vm).Bool)
         return new HassiumStream(new SslStream(TcpClient.GetStream(), false, new RemoteCertificateValidationCallback((sender, certificate, chain, sslPolicyErrors) => true), null));
     return new HassiumStream(TcpClient.GetStream());
 }
Пример #3
0
 private HassiumString uploadString(VirtualMachine vm, HassiumObject[] args)
 {
     if (args.Length == 2)
         return new HassiumString(WebClient.UploadString(args[0].ToString(vm).String, args[1].ToString(vm).String));
     else
         return new HassiumString(WebClient.UploadString(args[0].ToString(vm).String, args[1].ToString(vm).String, args[2].ToString(vm).String));
 }
Пример #4
0
        private HassiumNull authenticateSsl(VirtualMachine vm, HassiumObject[] args)
        {
            if (!(Stream is SslStream))
                throw new InternalException(vm, "Stream was not an SSL Stream!");
            ((SslStream)Stream).AuthenticateAsClient(args[0].ToString(vm).String);

            return HassiumObject.Null;
        }
Пример #5
0
 public HassiumString format(VirtualMachine vm, params HassiumObject[] args)
 {
     HassiumObject[] formatArgs = new HassiumObject[args.Length + 1];
     formatArgs[0] = this;
     for (int i = 0; i < args.Length; i++)
         formatArgs[i + 1] = args[i];
     return GlobalFunctions.format(vm, formatArgs);
 }
Пример #6
0
 private HassiumObject atan(VirtualMachine vm, HassiumObject[] args)
 {
     if (args[0] is HassiumInt)
         return new HassiumFloat(System.Math.Atan(args[0].ToInt(vm).Int));
     else if (args[0] is HassiumFloat)
         return new HassiumFloat(System.Math.Atan(args[0].ToFloat(vm).Float));
     return HassiumObject.Null;
 }
Пример #7
0
        public HassiumList getProcessList(VirtualMachine vm, HassiumObject[] args)
        {
            HassiumList list = new HassiumList(new HassiumObject[0]);
            foreach (Process process in Process.GetProcesses())
                list.add(vm, createFromProcess(process));

            return list;
        }
        public HassiumList get_environmentVariables(VirtualMachine vm, HassiumObject[] args)
        {
            HassiumList list = new HassiumList(new HassiumObject[0]);
            var variables = StartInfo.EnvironmentVariables;
            foreach (KeyValuePair<string, string> entry in variables)
                list.add(vm, new HassiumKeyValuePair(new HassiumString(entry.Key), new HassiumString(entry.Value)));

            return list;
        }
Пример #9
0
        public HassiumKeyValuePair(HassiumObject key, HassiumObject value)
        {
            Key = key;
            Value = value;
            AddType(TypeDefinition);

            AddAttribute("key",     new HassiumProperty(get_key, set_key));
            AddAttribute("value",   new HassiumProperty(get_value, set_value));
        }
Пример #10
0
        private HassiumObject select(HassiumObject[] args)
        {
            MySqlCommand command = new MySqlCommand(args[0].ToString(), Value);
            for (int x = 1; x < args.Length; x++)
            command.Parameters.AddWithValue(((HassiumArray)args[x]).Value[0].ToString(), ((HassiumArray)args[x]).Value[1].ToString());
            command.Prepare();

            return new HassiumSqlDataReader(command.ExecuteReader());
        }
Пример #11
0
        private HassiumList downloadData(VirtualMachine vm, HassiumObject[] args)
        {
            HassiumList list = new HassiumList(new HassiumObject[0]);
            byte[] bytes = WebClient.DownloadData(args[0].ToString(vm).String);
            foreach (byte b in bytes)
                list.Add(vm, new HassiumChar((char)b));

            return list;
        }
Пример #12
0
 public HassiumObject Show(HassiumObject[] args)
 {
     //Application.Run((Form)Value);
     var frm = (Form) Value;
     ShowWindow(frm.Handle, 1);
     SetWindowPos(frm.Handle.ToInt32(), HWND_TOPMOST,
     frm.Left, frm.Top, frm.Width, frm.Height,
     SWP_NOACTIVATE);
     return null;
 }
        public HassiumConnectionListener _new(VirtualMachine vm, HassiumObject[] args)
        {
            HassiumConnectionListener connectionListener = new HassiumConnectionListener();
            connectionListener.TcpListener = new TcpListener(IPAddress.Parse(args[0].ToString(vm).String), (int)args[0].ToInt(vm).Int);
            connectionListener.AddAttribute("acceptConnection",    connectionListener.acceptConnection, 0);
            connectionListener.AddAttribute("pending",             connectionListener.pending, 0);
            connectionListener.AddAttribute("start",               connectionListener.start, 0);
            connectionListener.AddAttribute("stop",                connectionListener.stop, 0);

            return connectionListener;
        }
Пример #14
0
 public HassiumString get_Name(VirtualMachine vm, HassiumObject[] args)
 {
     try
     {
         return new HassiumString(Process.ProcessName);
     }
     catch
     {
         return new HassiumString("");
     }
 }
Пример #15
0
 public HassiumBool Is(VirtualMachine vm, HassiumObject obj)
 {
     foreach (var trait in Traits)
     {
         if (!obj.Attributes.ContainsKey(trait.Name))
             return new HassiumBool(false);
         if (obj.Attributes[trait.Name].Type() != vm.Globals[trait.Type].Type())
             return new HassiumBool(false);
     }
     return new HassiumBool(true);
 }
Пример #16
0
        private HassiumList uploadFile(VirtualMachine vm, HassiumObject[] args)
        {
            byte[] res;
            if (args.Length == 2)
                res = WebClient.UploadFile(args[0].ToString(vm).String, args[1].ToString(vm).String);
            else
                res = WebClient.UploadFile(args[0].ToString(vm).String, args[1].ToString(vm).String, args[2].ToString(vm).String);
            HassiumList list = new HassiumList(new HassiumObject[0]);
            foreach (byte b in res)
                list.Add(vm, new HassiumChar((char)b));

            return list;
        }
Пример #17
0
 public HassiumNull write(VirtualMachine vm, HassiumObject[] args)
 {
     if (args[0] is HassiumBool)
         writeBool(vm, args);
     else if (args[0] is HassiumChar)
         writeChar(vm, args);
     else if (args[0] is HassiumFloat)
         writeDouble(vm, args);
     else if (args[0] is HassiumInt)
         writeInt64(vm, args);
     else if (args[0] is HassiumList)
         writeList(vm, args);
     else if (args[0] is HassiumString)
         writeString(vm, args);
     else
         throw new InternalException(vm, "Cannot write type {0}!", args[0].Type());
     return HassiumObject.Null;
 }
Пример #18
0
        public HassiumList(HassiumObject[] elements)
        {
            AddType(TypeDefinition);
            List = new List<HassiumObject>(elements);

            AddAttribute("add",             add,       -1);
            AddAttribute("clear",           clear,      0);
            AddAttribute("contains",        contains,   1);
            AddAttribute("fill",            fill,    1, 2);
            AddAttribute("length",          new HassiumProperty(get_length));
            AddAttribute("peek",            peek,       0);
            AddAttribute("pop",             pop,        0);
            AddAttribute("push",            push,       1);
            AddAttribute("split",           split,   1, 2);
            AddAttribute("remove",          remove,    -1);
            AddAttribute("reverse",         reverse,    0);
            AddAttribute(HassiumObject.DISPOSE, Dispose, 0);
            AddAttribute(HassiumObject.TOLIST,      ToList,         0);
            AddAttribute(HassiumObject.TOSTRING,    ToString,    0, 1);
            AddAttribute(HassiumObject.TOTUPLE,     ToTuple,        0);
        }
Пример #19
0
 public HassiumNull writeInt64(VirtualMachine vm, HassiumObject[] args)
 {
     BinaryWriter.Write((Int64)args[0].ToInt(vm).Int);
     return HassiumObject.Null;
 }
Пример #20
0
 public override HassiumObject Add(VirtualMachine vm, HassiumObject self, SourceLocation location, params HassiumObject[] args)
 {
     return(FloatTypeDef.add(vm, this, location, args));
 }
Пример #21
0
 public HassiumNull writeChar(VirtualMachine vm, HassiumObject[] args)
 {
     BinaryWriter.Write(args[0].ToChar(vm).Char);
     return HassiumObject.Null;
 }
Пример #22
0
        public static HassiumString testfunc(VirtualMachine vm, HassiumObject self, SourceLocation location, params HassiumObject[] args)
        {
            Console.WriteLine("Hello from TestModule.TestClass.testfunc!");

            return(new HassiumString("I return things!"));
        }
Пример #23
0
 public static HassiumString format(VirtualMachine vm, HassiumObject self, SourceLocation location, params HassiumObject[] args)
 {
     return(new HassiumString(string.Format(args[0].ToString(vm, args[0], location).String, (self as HassiumFloat).Float)));
 }
Пример #24
0
 public HassiumInt get_Position(VirtualMachine vm, HassiumObject[] args)
 {
     return new HassiumInt(BinaryWriter.BaseStream.Position);
 }
Пример #25
0
            public static HassiumString tostring(VirtualMachine vm, HassiumObject self, SourceLocation location, params HassiumObject[] args)
            {
                var BigInt = (self as HassiumBigInt).BigInt;

                return(new HassiumString(BigInt.ToString()));
            }
Пример #26
0
 public static HassiumInt indexof(VirtualMachine vm, HassiumObject self, SourceLocation location, params HassiumObject[] args)
 {
     return(new HassiumInt((self as HassiumString).String.IndexOf(args[0].ToString(vm, args[0], location).String)));
 }
Пример #27
0
            public static HassiumInt get_length(VirtualMachine vm, HassiumObject self, SourceLocation location, params HassiumObject[] args)
            {
                var String = (self as HassiumString).String;

                return(new HassiumInt(String == null ? -1 : String.Length));
            }
Пример #28
0
 public static HassiumInt get_size(VirtualMachine vm, HassiumObject self, SourceLocation location, params HassiumObject[] args)
 {
     return(new HassiumInt((self as HassiumFile).FileInfo.Length));
 }
Пример #29
0
            public static HassiumObject index(VirtualMachine vm, HassiumObject self, SourceLocation location, params HassiumObject[] args)
            {
                var String = (self as HassiumString).String;

                return(new HassiumChar(String[(int)args[0].ToInt(vm, args[0], location).Int]));
            }
Пример #30
0
 public static HassiumString get_relpath(VirtualMachine vm, HassiumObject self, SourceLocation location, params HassiumObject[] args)
 {
     return((self as HassiumFile).RelativePath);
 }
Пример #31
0
 public static HassiumNull set_position(VirtualMachine vm, HassiumObject self, SourceLocation location, params HassiumObject[] args)
 {
     (self as HassiumFile).Reader.BaseStream.Position = args[0].ToInt(vm, args[0], location).Int;
     return(Null);
 }
Пример #32
0
 public static HassiumInt get_position(VirtualMachine vm, HassiumObject self, SourceLocation location, params HassiumObject[] args)
 {
     return(new HassiumInt((self as HassiumFile).Reader.BaseStream.Position));
 }
Пример #33
0
 public HassiumNull writeList(VirtualMachine vm, HassiumObject[] args)
 {
     foreach (HassiumObject obj in args[0].ToList(vm).List)
         write(vm, new HassiumObject[] { obj });
     return HassiumObject.Null;
 }
Пример #34
0
            public static HassiumObject lesserthanorequal(VirtualMachine vm, HassiumObject self, SourceLocation location, params HassiumObject[] args)
            {
                var String = (self as HassiumString).String;

                return(new HassiumBool(string.Compare(String, args[0].ToString(vm, args[0], location).String) <= 0));
            }
Пример #35
0
        private HassiumFileWriter _new(VirtualMachine vm, HassiumObject[] args)
        {
            HassiumFileWriter fileWriter = new HassiumFileWriter();

            if (args[0] is HassiumString)
                fileWriter.BinaryWriter = new BinaryWriter(new StreamWriter(args[0].ToString(vm).String).BaseStream);
            else if (args[0] is HassiumStream)
                fileWriter.BinaryWriter = new BinaryWriter(((HassiumStream)args[0]).Stream);
            fileWriter.BaseStream = new HassiumStream(fileWriter.BinaryWriter.BaseStream);
            fileWriter.AddAttribute(HassiumObject.DISPOSE, fileWriter.Dispose, 0);
            fileWriter.AddAttribute("baseStream",   new HassiumProperty(get_baseStream));
            fileWriter.AddAttribute("endOfFile",    new HassiumProperty(get_endOfFile));
            fileWriter.AddAttribute("flush",        fileWriter.flush, 0);
            fileWriter.AddAttribute("length",       new HassiumProperty(get_length));
            fileWriter.AddAttribute("position",     new HassiumProperty(get_position, set_position));
            fileWriter.AddAttribute("write",        fileWriter.write, 1);
            fileWriter.AddAttribute("writeBool",    fileWriter.writeBool, 1);
            fileWriter.AddAttribute("writeChar",    fileWriter.writeChar, 1);
            fileWriter.AddAttribute("writeDouble",  fileWriter.writeDouble, 1);
            fileWriter.AddAttribute("writeInt16",   fileWriter.writeInt16, 1);
            fileWriter.AddAttribute("writeInt32",   fileWriter.writeInt32, 1);
            fileWriter.AddAttribute("writeInt64",   fileWriter.writeInt64, 1);
            fileWriter.AddAttribute("writeLine",    fileWriter.writeLine, 1);
            fileWriter.AddAttribute("writeList",    fileWriter.writeList, 1);
            fileWriter.AddAttribute("writeString",  fileWriter.writeString, 1);

            return fileWriter;
        }
Пример #36
0
 public static HassiumBool startsswith(VirtualMachine vm, HassiumObject self, SourceLocation location, params HassiumObject[] args)
 {
     return(new HassiumBool((self as HassiumString).String.StartsWith(args[0].ToString(vm, args[0], location).String)));
 }
Пример #37
0
 public static HassiumString get_name(VirtualMachine vm, HassiumObject self, SourceLocation location, params HassiumObject[] args)
 {
     return(new HassiumString(Path.GetFileName((self as HassiumFile).AbsolutePath.String)));
 }
Пример #38
0
 public static HassiumChar tochar(VirtualMachine vm, HassiumObject self, SourceLocation location, params HassiumObject[] args)
 {
     return(new HassiumChar((self as HassiumString).String[0]));
 }
Пример #39
0
        public static Dictionary <string, HassiumObject> GetConstants()
        {
            var res = new Dictionary <string, HassiumObject>();

            res.Add("I", new HComplex(0, 1));

            #region Constants
            var cts = new HassiumObject();
            cts.Attributes.Add("Pi", new InternalFunction(x => (HComplex)Constants.Pi, 0, true));
            cts.Attributes.Add("E", new InternalFunction(x => (HComplex)Constants.E, 0, true));
            cts.Attributes.Add("Catalan", new InternalFunction(x => (HComplex)Constants.Catalan, 0, true));
            cts.Attributes.Add("Degree", new InternalFunction(x => (HComplex)Constants.Degree, 0, true));
            cts.Attributes.Add("Epsilon", new InternalFunction(x => (HComplex)Constants.Epsilon, 0, true));
            cts.Attributes.Add("EulerGamma", new InternalFunction(x => (HComplex)Constants.EulerGamma, 0, true));
            cts.Attributes.Add("Glaisher", new InternalFunction(x => (HComplex)Constants.Glaisher, 0, true));
            cts.Attributes.Add("Khinchin", new InternalFunction(x => (HComplex)Constants.Khinchin, 0, true));
            cts.Attributes.Add("Phi", new InternalFunction(x => (HComplex)Constants.Phi, 0, true));
            cts.Attributes.Add("SpeedOfLight", new InternalFunction(x => (HComplex)Constants.SpeedOfLight, 0, true));
            cts.Attributes.Add("Tau", new InternalFunction(x => (HComplex)Constants.Tau, 0, true));

            res.Add("Constants", cts);
            #endregion

            #region Functions
            var imp = new HassiumObject();

            var funcs =
                typeof(Functions).GetMethods(BindingFlags.Public |
                                             BindingFlags.Static);
            var ln = "";
            try
            {
                foreach (var x in funcs)
                {
                    if (Attribute.IsDefined(x, typeof(MathFunc)))
                    {
                        if ((Attribute.GetCustomAttribute(x, typeof(MathFunc)) as MathFunc).Hide)
                        {
                            continue;
                        }
                    }
                    var n = x.Name;
                    ln = n;
                    if (Attribute.IsDefined(x, typeof(MathFunc)))
                    {
                        if ((Attribute.GetCustomAttribute(x, typeof(MathFunc)) as MathFunc).Name != "")
                        {
                            n = (Attribute.GetCustomAttribute(x, typeof(MathFunc)) as MathFunc).Name;
                        }
                    }

                    if (imp.Attributes.Any(f => f.Key == n))
                    {
                        continue;
                    }

                    if (funcs.Any(f => f.Name == n && f.GetParameters().Length != x.GetParameters().Length))
                    {
                        var overloads =
                            funcs.Where(f => f.Name == n && f.GetParameters().Length != x.GetParameters().Length);
                        var parameters = overloads.Select(f => f.GetParameters().Length).ToList();
                        parameters.Insert(0, x.GetParameters().Length);


                        imp.Attributes.Add(n, new InternalFunction(a =>
                        {
                            return(new HComplex((Complex)overloads.First(f => f.GetParameters().Length == a.Length)
                                                .Invoke(null, a.Select(y => (object)y.HComplex().Value).ToArray())));
                        }, parameters.ToArray()));
                    }
                    else
                    {
                        imp.Attributes.Add(n, new InternalFunction(a => new HComplex((Complex)x.Invoke(null, a.Select(y => (object)y.HComplex().Value).ToArray())), x.GetParameters().Length));
                    }
                }
            }
            catch
            {
                throw new ParseException("Error while loading function: " + ln, -1);
            }


            imp.Attributes.Add("integrate",
                               new InternalFunction(
                                   x =>
                                   new HComplex(Functions.Integrate(
                                                    y => HassiumMethod.GetFunc1(x[0])(new HComplex(y)).HComplex().Value, x[1].HComplex().Value,
                                                    x[2].HComplex().Value)), 3));


            res.Add("IMP", imp);
            #endregion

            return(res);
        }
Пример #40
0
            public static HassiumNull set_extension(VirtualMachine vm, HassiumObject self, SourceLocation location, params HassiumObject[] args)
            {
                moveto(vm, self, location, new HassiumString(Path.ChangeExtension((self as HassiumFile).AbsolutePath.String, args[0].ToString(vm, args[0], location).String)));

                return(Null);
            }
Пример #41
0
            public static HassiumObject divide(VirtualMachine vm, HassiumObject self, SourceLocation location, params HassiumObject[] args)
            {
                var Float = (self as HassiumFloat).Float;

                return(new HassiumFloat(Float / args[0].ToFloat(vm, args[0], location).Float));
            }
Пример #42
0
            public static HassiumList tolist(VirtualMachine vm, HassiumObject self, SourceLocation location, params HassiumObject[] args)
            {
                var String = (self as HassiumString).String;

                return(iter(vm, self, location, args) as HassiumList);
            }
Пример #43
0
            public static HassiumObject greaterthan(VirtualMachine vm, HassiumObject self, SourceLocation location, params HassiumObject[] args)
            {
                var Float = (self as HassiumFloat).Float;

                return(new HassiumBool(Float > args[0].ToFloat(vm, args[0], location).Float));
            }
Пример #44
0
 public static HassiumString tostring(VirtualMachine vm, HassiumObject self, SourceLocation location, params HassiumObject[] args)
 {
     return(self as HassiumString);
 }
Пример #45
0
 public HassiumNull writeBool(VirtualMachine vm, HassiumObject[] args)
 {
     BinaryWriter.Write(args[0].ToBool(vm).Bool);
     return HassiumObject.Null;
 }
Пример #46
0
            public static HassiumString toupper(VirtualMachine vm, HassiumObject self, SourceLocation location, params HassiumObject[] args)
            {
                var String = (self as HassiumString).String;

                return(new HassiumString(String.ToUpper()));
            }
Пример #47
0
 public HassiumNull writeDouble(VirtualMachine vm, HassiumObject[] args)
 {
     BinaryWriter.Write(args[0].ToFloat(vm).Float);
     return HassiumObject.Null;
 }
Пример #48
0
            public static HassiumBool contains(VirtualMachine vm, HassiumObject self, SourceLocation location, params HassiumObject[] args)
            {
                var String = (self as HassiumString).String;

                return(new HassiumBool(String.Contains(args[0].ToString(vm, args[0], location).String)));
            }
Пример #49
0
 public HassiumNull writeLine(VirtualMachine vm, HassiumObject[] args)
 {
     string str = args[0].ToString(vm).String;
     foreach (char c in str)
         BinaryWriter.Write(c);
     BinaryWriter.Write('\r');
     BinaryWriter.Write('\n');
     return HassiumObject.Null;
 }
Пример #50
0
 public HassiumObject StoreReference(HassiumObject value)
 {
     Frame.Modify(Index, value);
     return value;
 }
Пример #51
0
 public HassiumNull writeString(VirtualMachine vm, HassiumObject[] args)
 {
     BinaryWriter.Write(args[0].ToString(vm).String);
     return HassiumObject.Null;
 }
Пример #52
0
        public HassiumCGI()
        {
            if (Environment.GetEnvironmentVariables().Contains("QUERY_STRING"))
            {
                var query_string = Environment.GetEnvironmentVariable("QUERY_STRING");
                var query_args = new Dictionary<string, string>();

                foreach (var currentArg in query_string.Split('&'))
                {
                    if (!currentArg.Contains('=')) query_args.Add(currentArg, "");
                    else
                    {
                        var key = currentArg.Split('=')[0];
                        var value = HttpUtility.UrlDecode(currentArg.Split('=')[1]);
                        query_args.Add(key, value);
                    }
                }

                _get =
                    new HassiumDictionary(
                        query_args.Select(
                            x => new HassiumKeyValuePair(new HassiumString(x.Key), new HassiumString(x.Value)))
                        .ToList());
            }
            else _get = new HassiumDictionary(new List<HassiumKeyValuePair>());

            Attributes.Add("get", new HassiumProperty((vm, args) => _get));
            Attributes.Add("post", new HassiumProperty((vm, args) =>
            {
                if (_post == null)
                {
                    var query_string = "";
                    if (Environment.GetEnvironmentVariable("CONTENT_LENGTH") != null)
                    {
                        int PostedDataLength = Convert.ToInt32(Environment.GetEnvironmentVariable("CONTENT_LENGTH"));
                        for (int i = 0; i < PostedDataLength; i++)
                            query_string += Convert.ToChar(Console.Read()).ToString();
                    }
                    else
                    {
                        var stdin = new StreamReader(Console.OpenStandardInput());
                        query_string = stdin.ReadToEnd();
                    }
                    if (!string.IsNullOrWhiteSpace(query_string))
                    {
                        var query_args = new Dictionary<string, string>();

                        foreach (var currentArg in query_string.Split('&'))
                        {
                            if (!currentArg.Contains('=')) query_args.Add(currentArg, "");
                            else
                            {
                                var key = currentArg.Split('=')[0];
                                var value = HttpUtility.UrlDecode(currentArg.Split('=')[1]);
                                query_args.Add(key, value);
                            }
                        }

                        _post = new HassiumDictionary(
                            query_args.Select(
                                x => new HassiumKeyValuePair(new HassiumString(x.Key), new HassiumString(x.Value)))
                            .ToList());
                    }
                    else _post = new HassiumDictionary(new List<HassiumKeyValuePair>());
                }
                return _post;
            }));

            Attributes.Add("documentRoot",
                new HassiumProperty((vm, args) => new HassiumString(Environment.GetEnvironmentVariable("DOCUMENT_ROOT") ?? "undefined")));
            Attributes.Add("remote", new HassiumProperty((vm, args) =>
            {
                var remote = new HassiumObject();
                remote.Attributes.Add("ip",
                    new HassiumProperty((vm1, args1) => new HassiumString(Environment.GetEnvironmentVariable("REMOTE_ADDR") ?? "undefined")));
                remote.Attributes.Add("host",
                    new HassiumProperty((vm1, args1) => new HassiumString(Environment.GetEnvironmentVariable("REMOTE_HOST") ?? "undefined")));
                remote.Attributes.Add("port",
                    new HassiumProperty((vm1, args1) => new HassiumString(Environment.GetEnvironmentVariable("REMOTE_PORT") ?? "undefined")));
                remote.Attributes.Add("user",
                    new HassiumProperty((vm1, args1) => new HassiumString(Environment.GetEnvironmentVariable("REMOTE_USER") ?? "undefined")));
                remote.Attributes.Add("ident",
                    new HassiumProperty((vm1, args1) => new HassiumString(Environment.GetEnvironmentVariable("REMOTE_IDENT") ?? "undefined")));
                return remote;
            }));
            Attributes.Add("request", new HassiumProperty((vm, args) =>
            {
                var request = new HassiumObject();
                request.Attributes.Add("method",
                    new HassiumProperty(
                        (vm1, args1) => new HassiumString(Environment.GetEnvironmentVariable("REQUEST_METHOD") ?? "undefined")));
                request.Attributes.Add("uri",
                    new HassiumProperty(
                        (vm1, args1) => new HassiumString(Environment.GetEnvironmentVariable("REQUEST_URI") ?? "undefined")));
                request.Attributes.Add("scheme",
                    new HassiumProperty(
                        (vm1, args1) => new HassiumString(Environment.GetEnvironmentVariable("REQUEST_SCHEME") ?? "undefined")));
                return request;
            }));
            Attributes.Add("server", new HassiumProperty((vm, args) =>
            {
                var server = new HassiumObject();
                server.Attributes.Add("admin",
                    new HassiumProperty((vm1, args1) => new HassiumString(Environment.GetEnvironmentVariable("SERVER_ADMIN") ?? "undefined")));
                server.Attributes.Add("address",
                    new HassiumProperty((vm1, args1) => new HassiumString(Environment.GetEnvironmentVariable("SERVER_ADDR") ?? "undefined")));
                server.Attributes.Add("name",
                    new HassiumProperty((vm1, args1) => new HassiumString(Environment.GetEnvironmentVariable("SERVER_NAME") ?? "undefined")));
                server.Attributes.Add("port",
                    new HassiumProperty((vm1, args1) => new HassiumString(Environment.GetEnvironmentVariable("SERVER_PORT") ?? "undefined")));
                server.Attributes.Add("protocol",
                    new HassiumProperty((vm1, args1) => new HassiumString(Environment.GetEnvironmentVariable("SERVER_PROTOCOL") ?? "undefined")));
                server.Attributes.Add("software",
                    new HassiumProperty((vm1, args1) => new HassiumString(Environment.GetEnvironmentVariable("SERVER_SOFTWARE") ?? "undefined")));
                server.Attributes.Add("signature",
                    new HassiumProperty((vm1, args1) => new HassiumString(Environment.GetEnvironmentVariable("SERVER_SIGNATURE") ?? "undefined")));
                return server;
            }));
            Attributes.Add("http", new HassiumProperty((vm, args) =>
            {
                var http = new HassiumObject();
                http.Attributes.Add("accept", new HassiumProperty((vm1, args1) =>
                {
                    var accept = new HassiumObject();
                    accept.Attributes.Add("mimeType",
                        new HassiumProperty((vm2, args2) => new HassiumString(Environment.GetEnvironmentVariable("HTTP_ACCEPT") ?? "undefined")));
                    accept.Attributes.Add("charset",
                        new HassiumProperty((vm2, args2) => new HassiumString(Environment.GetEnvironmentVariable("HTTP_ACCEPT_CHARSET") ?? "undefined")));
                    accept.Attributes.Add("encoding",
                        new HassiumProperty((vm2, args2) => new HassiumString(Environment.GetEnvironmentVariable("HTTP_ACCEPT_ENCODING") ?? "undefined")));
                    accept.Attributes.Add("language",
                        new HassiumProperty((vm2, args2) => new HassiumString(Environment.GetEnvironmentVariable("HTTP_ACCEPT_LANGUAGE") ?? "undefined")));
                    return accept;
                }));
                http.Attributes.Add("cacheControl",
                    new HassiumProperty(
                        (vm1, args1) => new HassiumString(Environment.GetEnvironmentVariable("HTTP_CACHE_CONTROL") ?? "undefined")));
                http.Attributes.Add("connection",
                    new HassiumProperty(
                        (vm1, args1) => new HassiumString(Environment.GetEnvironmentVariable("HTTP_CONNECTION") ?? "undefined")));
                http.Attributes.Add("cookie",
                    new HassiumProperty((vm1, args1) => new HassiumString(Environment.GetEnvironmentVariable("HTTP_COOKIE") ?? "undefined")));
                http.Attributes.Add("doNotTrack",
                    new HassiumProperty((vm1, args1) => new HassiumBool(Environment.GetEnvironmentVariable("HTTP_DNT") == "1")));
                http.Attributes.Add("userMail",
                    new HassiumProperty((vm1, args1) => new HassiumString(Environment.GetEnvironmentVariable("HTTP_FROM") ?? "undefined")));
                http.Attributes.Add("host",
                    new HassiumProperty((vm1, args1) => new HassiumString(Environment.GetEnvironmentVariable("HTTP_HOST") ?? "undefined")));
                http.Attributes.Add("referer",
                    new HassiumProperty(
                        (vm1, args1) => new HassiumString(Environment.GetEnvironmentVariable("HTTP_REFERER") ?? "undefined")));
                http.Attributes.Add("userAgent",
                    new HassiumProperty(
                        (vm1, args1) => new HassiumString(Environment.GetEnvironmentVariable("HTTP_USER_AGENT") ?? "undefined")));
                http.Attributes.Add("upgradeInsecureRequests",
                    new HassiumProperty(
                        (vm1, args1) => new HassiumBool(Environment.GetEnvironmentVariable("HTTP_UPGRADE_INSECURE_REQUESTS") == "1")));
                return http;
            }));
            Attributes.Add("isHttps",
                new HassiumProperty((vm, args) => new HassiumBool(Environment.GetEnvironmentVariable("HTTP_COOKIE") == "on")));
            Attributes.Add("path",
                new HassiumProperty((vm, args) => new HassiumString(Environment.GetEnvironmentVariable("PATH") ?? "undefined")));
            Attributes.Add("script", new HassiumProperty((vm, args) =>
            {
                var script = new HassiumObject();
                script.Attributes.Add("fileName",
                    new HassiumProperty((vm1, args1) => new HassiumString(Environment.GetEnvironmentVariable("SCRIPT_FILENAME") ?? "undefined")));
                script.Attributes.Add("name",
                    new HassiumProperty((vm1, args1) => new HassiumString(Environment.GetEnvironmentVariable("SCRIPT_NAME") ?? "undefined")));
                return script;
            }));
            Attributes.Add("gatewayInterface",
                new HassiumProperty((vm, args) => new HassiumString(Environment.GetEnvironmentVariable("GATEWAY_INTERFACE") ?? "undefined")));
            Attributes.Add("authType",
                new HassiumProperty((vm, args) => new HassiumString(Environment.GetEnvironmentVariable("AUTH_TYPE") ?? "undefined")));

            Attributes.Add("content", new HassiumProperty((vm, args) =>
            {
                var content = new HassiumObject();
                content.Attributes.Add("length",
                    new HassiumProperty((vm1, args1) => new HassiumString(Environment.GetEnvironmentVariable("CONTENT_LENGTH") ?? "undefined")));
                content.Attributes.Add("type",
                    new HassiumProperty((vm1, args1) => new HassiumString(Environment.GetEnvironmentVariable("CONTENT_TYPE") ?? "undefined")));
                return content;
            }));

            Attributes.Add("context", new HassiumProperty((vm, args) =>
            {
                var context = new HassiumObject();
                context.Attributes.Add("documentRoot",
                    new HassiumProperty((vm1, args1) => new HassiumString(Environment.GetEnvironmentVariable("CONTEXT_DOCUMENT_ROOT") ?? "undefined")));
                context.Attributes.Add("prefix",
                    new HassiumProperty((vm1, args1) => new HassiumString(Environment.GetEnvironmentVariable("CONTEXT_PREFIX") ?? "undefined")));
                return context;
            }));
            Attributes.Add("uniqueId",
                new HassiumProperty((vm, args) => new HassiumString(Environment.GetEnvironmentVariable("UNIQUE_ID") ?? "undefined")));
            Attributes.Add("currentDirectory",
                new HassiumProperty((vm, args) => new HassiumString(Environment.GetEnvironmentVariable("PWD") ?? "undefined")));
            Attributes.Add("shellLevel",
                new HassiumProperty((vm, args) => new HassiumString(Environment.GetEnvironmentVariable("SHLVL") ?? "undefined")));

            /*Attributes.Add("session", new HassiumProperty("session", arg =>
            {
                var session = new HassiumDictionary(_sessionvalue.ToDictionary());
                session.Attributes.Add("start", new InternalFunction(x =>
                {
                    Console.WriteLine("Set-Cookie");
                    _sessionfolder = x[0].ToString();
                    _sessionvalue = new HassiumDictionary(new Dictionary<HassiumObject, HassiumObject>());
                    session.Value = _sessionvalue.Value;
                    _sessionstarted = true;
                    return null;
                }, 1));
                session.Attributes.Add("stop", new InternalFunction(x =>
                {
                    _sessionstarted = false;
                    _sessionfolder = "";
                    _sessionvalue = new HassiumDictionary(new Dictionary<HassiumObject, HassiumObject>());
                    session.Value = _sessionvalue.Value;
                    return null;
                }, 0));

                session.OnValueChanged +=
                    delegate {
                                 _sessionvalue = session;
                    };

                return session;
            }, null, true));*/
        }
Пример #53
0
 public HassiumNull flush(VirtualMachine vm, HassiumObject[] args)
 {
     BinaryWriter.Flush();
     return HassiumObject.Null;
 }
Пример #54
0
 public static HassiumString get_extension(VirtualMachine vm, HassiumObject self, SourceLocation location, params HassiumObject[] args)
 {
     return(new HassiumString((self as HassiumFile).FileInfo.Extension));
 }
Пример #55
0
            public static HassiumBigInt log(VirtualMachine vm, HassiumObject self, SourceLocation location, params HassiumObject[] args)
            {
                var BigInt = (self as HassiumBigInt).BigInt;

                return(_new(vm, self, location, new HassiumFloat(BigInteger.Log(BigInt, args[0].ToFloat(vm, args[0], location).Float))));
            }
Пример #56
0
 public static HassiumBool get_isclosed(VirtualMachine vm, HassiumObject self, SourceLocation location, params HassiumObject[] args)
 {
     return(new HassiumBool((self as HassiumFile).closed));
 }
Пример #57
0
            public static HassiumInt toint(VirtualMachine vm, HassiumObject self, SourceLocation location, params HassiumObject[] args)
            {
                var BigInt = (self as HassiumBigInt).BigInt;

                return(new HassiumInt(BitConverter.ToInt64(BigInt.ToByteArray(), 0)));
            }
Пример #58
0
            public static HassiumList tolist(VirtualMachine vm, HassiumObject self, SourceLocation location, params HassiumObject[] args)
            {
                var BigInt = (self as HassiumBigInt).BigInt;

                return(new HassiumByteArray(BigInt.ToByteArray(), new HassiumObject[0]));
            }
Пример #59
0
            public static HassiumFloat tofloat(VirtualMachine vm, HassiumObject self, SourceLocation location, params HassiumObject[] args)
            {
                var String = (self as HassiumString).String;

                return(new HassiumFloat(Convert.ToDouble(String)));
            }
Пример #60
0
 public static HassiumNull exit(VirtualMachine vm, HassiumObject self, SourceLocation location, params HassiumObject[] args)
 {
     return(close(vm, self, location, args));
 }