예제 #1
0
파일: loader.cs 프로젝트: bitdotgames/bhl
        public CompiledModule Load(string module_name)
        {
            Entry ent;

            if (!name2entry.TryGetValue(module_name, out ent))
            {
                return(null);
            }

            byte[] res     = null;
            int    res_len = 0;

            DecodeBin(ent, ref res, ref res_len);

            mod_stream.SetData(res, 0, res_len);

            return(CompiledModule.FromStream(types, mod_stream));
        }
예제 #2
0
    public static VM MakeVM(CompiledModule orig_cm, Types ts = null)
    {
        if (ts == null)
        {
            ts = new Types();
        }

        //let's serialize/unserialize the compiled module so that
        //it's going to go thru the full compilation cycle
        var ms = new MemoryStream();

        CompiledModule.ToStream(orig_cm, ms);
        var cm = CompiledModule.FromStream(ts, new MemoryStream(ms.GetBuffer()), add_symbols_to_types: true);

        var vm = new VM(ts);

        vm.RegisterModule(cm);
        return(vm);
    }