コード例 #1
0
        /**
         * 卸载ram,如果并没有安装过ram,则什么也不会发生
         * @param type 需要卸载的内存类型
         */
        public void uninstall(int type)
        {
            Ram.Ram ram = null;
            switch (type)
            {
            case RamConst.RAM_RUNTIME_TYPE:
                ram    = runRam;
                runRam = null;
                break;

            case RamConst.RAM_GRAPH_TYPE:
                ram      = graphRam;
                graphRam = null;
                break;

            case RamConst.RAM_BUFFER_TYPE:
                ram       = bufferRam;
                bufferRam = null;
                break;

            case RamConst.RAM_STRING_TYPE:
                ram    = strRam;
                strRam = null;
                break;

            case RamConst.RAM_TEXT_TYPE:
                ram     = textRam;
                textRam = null;
                break;
            }
            if (ram != null)
            {
                resetRamAddress();
            }
        }
コード例 #2
0
 public RamManager(RuntimeRam runRam, StringRam strRam, Stack stack)
 {
     if (runRam == null || strRam == null || stack == null)
     {
         //throw new IllegalArgumentException("param can't be null");
     }
     this.stack = stack;
     install(runRam);
     install(strRam);
 }
コード例 #3
0
        /**
         * 往里面添加内存模块,每种类型的内存最多只能安装一个.<p>
         * ram为null不会抛出异常,且不会改变RamManager的任何状态
         * @param ram 需要安装的内存
         * @throws IllegalStateException 已经安装了这种类型的内存
         * @see #uninstall
         */
        public void install(Ram.Ram ram)
        {
            if (ram == null)
            {
                return;
            }
            switch (ram.getRamType())
            {
            case RamConst.RAM_RUNTIME_TYPE:
                if (runRam != null)
                {
                    //throw new IllegalStateException("Runtime Ram was installed!");
                }
                runRam = (RuntimeRam)ram;
                break;

            case RamConst.RAM_GRAPH_TYPE:
                if (graphRam != null)
                {
                    //throw new IllegalStateException("Graph Ram was installed!");
                }
                graphRam = (RelativeRam)ram;
                screen   = graphRam.getScreenModel();
                break;

            case RamConst.RAM_BUFFER_TYPE:
                if (bufferRam != null)
                {
                    //throw new IllegalStateException("Buffer Ram was installed!");
                }
                bufferRam = (RelativeRam)ram;
                break;

            case RamConst.RAM_STRING_TYPE:
                if (strRam != null)
                {
                    //throw new IllegalStateException("String Ram was installed!");
                }
                strRam = (StringRam)ram;
                break;

            case RamConst.RAM_TEXT_TYPE:
                if (textRam != null)
                {
                    //throw new IllegalStateException("Text Ram was installed!");
                }
                textRam = (RelativeRam)ram;
                break;
            }
            resetRamAddress();
        }