Ejemplo n.º 1
0
    public Perl5Interpreter()
    {
        ExportedObjects = new Dictionary <int, Variable>();
        ExportedID      = 8;
        string location = System.Reflection.Assembly.GetExecutingAssembly().Location;

        string[] paths = new string[] { "perl5/Niecza/blib/lib", "perl5/Niecza/blib/arch" };

        for (int i = 0; i < 2; i++)
        {
            // Try to construct the path in a platform portable manner
            string p5lib = Path.GetDirectoryName(Path.GetDirectoryName(location));
            foreach (string part in paths[i].Split('/'))
            {
                p5lib = Path.Combine(p5lib, part);
            }
            paths[i] = p5lib;
        }
        Set_p5embed_create_LoS(delegate(int len, IntPtr data) {
            int id          = ExportedID++;
            IntPtr[] target = new IntPtr[len];
            Marshal.Copy(data, target, 0, len);

            string[] args = new string[len];
            for (int i = 0; i < len; i++)
            {
                args[i] = UnmarshalString(target[i]);
            }
            ExportedObjects[id] = Builtins.BoxLoS(args);
            return(id);
        });
        Initialize(paths[0], paths[1]);
    }