Beispiel #1
0
        public static void LoadLib()
        {
            lock (syncRoot)
            {
                if (initOnce)
                {
                    return;
                }


                nativeModuleLoader = new NativeModuleLoader("pixellib01", "pixellib01.dll");
                if (!nativeModuleLoader.LoadRequestProcs(typeof(NativePixelLibInterOp)))
                {
                    return;
                }
                //-------------------------------
                //1. get version
                int version = libGetVersion();
                //2. callback for pixellib
                managedListener    = new ManagedListenerDel(HandleCallFromNativePixelLib);
                myCallBackDelegate = System.Runtime.InteropServices.Marshal.GetFunctionPointerForDelegate(managedListener);
                int regResult = registerMxCallBack(myCallBackDelegate, 0);
                //3. test call back
                var result2 = testCallBack();
                //-------------------------------
                //ok
                //start graphic surface
                //-------------------------------
                initOnce = true;
            }
        }
Beispiel #2
0
        public VM()
        {
            Interpreter = new InterpreterBackend(this);
            JIT         = new JITBackend(this);

            modules       = new Dictionary <string, Scope>();
            loadedModules = new Dictionary <string, NeoChunk>();

            frames            = new Stack <Frame>();
            importSearchPaths = new Stack <string>();

            NativeModuleLoader.LoadNativeModules(Assembly.GetExecutingAssembly());

            try {
                FFILib.RegisterAssembly(typeof(string).Assembly);
                FFILib.RegisterAssembly(typeof(VM).Assembly);

                baseLib = LoadSTDModule("std/base");

                PushFrame("base.neo", "___init", -1);
                baseLib.Get("___init").Call(new[] { new FFITypeProxy(this) });
                PopFrame();
            } catch (NeoError e) {
                PrintStackTrace(e);
                Environment.Exit(1);
            }
        }
Beispiel #3
0
        //-------------------------------------------------


        public static void LoadLib()
        {
            lock (syncRoot)
            {
                if (initOnce)
                {
                    return;
                }

                //--------------------------
                //change location of dll ...
                //or embeded as resource file
                //--------------------------

                nativeModuleLoader = new NativeModuleLoader("libagg", "lion.dll");
                if (!nativeModuleLoader.LoadRequestProcs(typeof(NativeAggInterOp)))
                {
                    return;
                }

                //1. get version
                int version = libGetVersion();
                //2. callback for pixellib
                managedListener  = new ManagedListenerDel(HandleCallFromNativePixelLib);
                unmangedCallBack = System.Runtime.InteropServices.Marshal.GetFunctionPointerForDelegate(managedListener);
                int regResult = registerMxCallBack(unmangedCallBack, 0);
                //3. test call back
                var result2 = testCallBack();
                initOnce = true;
            }
        }
Beispiel #4
0
        private Scope LoadSTDModule(string rawPath)
        {
            var name = $"std/{rawPath.Substring(4)}";

            if (loadedModules.ContainsKey(name))
            {
                return(loadedModules[name].Scope);
            }

            var nativeModule = NativeModuleLoader.LoadNativeModule(rawPath);

            if (nativeModule == null)
            {
                return(LoadSTDSource(rawPath));
            }
            else
            {
                return(LoadNativeModule(nativeModule));
            }
        }
Beispiel #5
0
        private Scope LoadSTDModule(string rawPath)
        {
            var name = $"{rawPath.Substring(rawPath.LastIndexOf('/') + 1)}.neo";

            if (loadedModules.ContainsKey(name))
            {
                return(loadedModules[name].Scope);
            }

            var nativeModule = NativeModuleLoader.LoadNativeModule(rawPath);

            if (nativeModule == null)
            {
                return(LoadSTDSource(rawPath));
            }
            else
            {
                return(LoadNativeModule(nativeModule));
            }
        }