Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- trace("loaded");
- if(_root.installed != true)
- {
- trace("installed");
- _root.installed = true;
- _root.stack = [["map",0,"_root.test"],["sto","%m0","awesome"],["break"]];
- _root.ret = "";
- _root.toLoop = [];
- _root.endRet = false;
- _root.loopPositions = [];
- _root.acc = "";
- _root.mappable = [];
- _root.doTick = true;
- _root.programCounter = 0;
- _root.execute = function(a)
- {
- if(a[0] == "end")
- {
- _root.endRet = true;
- }
- trace(a);
- };
- _root.cpu = function()
- {
- trace("doCycle " + _root.programCounter);
- _root.toExecute = _root.stack[_root.programCounter];
- h = 0;
- while(h < _root.toExecute.length)
- {
- switch(_root.toExecute[h].slice(0,2))
- {
- case "%m":
- _root.toExecute[h] = _root.mappable[int(_root.toExecute[h].slice(2))];
- _root.stack[_root.programCounter[h]] = _root.mappable[int(_root.toExecute[h].slice(2))];
- break;
- case "%v":
- set("_root.toExecute[" + h + "]",_root.toExecute[h].slice(2));
- break;
- default:
- if(_root.toExecute[h].charAt(0) == "\\")
- {
- _root.toExecute[h] = _root.toExecute[h].slice(1);
- break;
- }
- }
- h++;
- }
- switch(_root.toExecute[0])
- {
- case "loop":
- _root.loopPositions.push(_root.programCounter);
- break;
- case "end":
- _root.execute(_root.toExecute);
- if(_root.endRet)
- {
- _root.loopPositions.pop();
- }
- else
- {
- _root.programCounter = _root.loopPositions[_root.loopPositions.length - 1];
- }
- _root.endRet = false;
- break;
- case "map":
- _root.mappable[_root.toExecute[1]] = _root.toExecute[2];
- break;
- case "sto":
- set(_root.toExecute[1],_root.toExecute[2]);
- break;
- case "halt":
- break;
- case "break":
- clearInterval(_root.cpuInterval);
- break;
- default:
- _root.execute(_root.toExecute);
- }
- _root.programCounter++;
- if(_root.programCounter >= _root.stack.length)
- {
- _root.stack = [["halt"]];
- }
- };
- _root.tickCpu = function()
- {
- if(_root.doTick)
- {
- _root.cpu();
- }
- };
- _root.cpuInterval = setInterval(_root.tickCpu,1);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement