OSDN Git Service

git-svn-id: http://svn.osdn.jp/svnroot/mimic/trunk@215 47198e57-cb75-475f-84c4-a814cd...
authornyatla <nyatla@47198e57-cb75-475f-84c4-a814cd6f29e0>
Tue, 16 Apr 2013 09:55:09 +0000 (09:55 +0000)
committernyatla <nyatla@47198e57-cb75-475f-84c4-a814cd6f29e0>
Tue, 16 Apr 2013 09:55:09 +0000 (09:55 +0000)
misc/MiMicVM/api.js/MiMicCore-mini.js [new file with mode: 0644]
misc/MiMicVM/api.js/MiMicILAsm.js
misc/MiMicVM/api.js/make_LPCXpresso1769_all.bat

diff --git a/misc/MiMicVM/api.js/MiMicCore-mini.js b/misc/MiMicVM/api.js/MiMicCore-mini.js
new file mode 100644 (file)
index 0000000..bb0b47f
--- /dev/null
@@ -0,0 +1 @@
+var MiMicLib={VERSION:"MiMicJsAPI/1.0.2",getNow:function getNow(){return(new Date()).getTime()},isUndef:function isUndef(b){return typeof b==="undefined"},isArray:function isArray(b){return b instanceof Array},cloneAssoc:function cloneAssoc(b){var d={};for(var c in b){d[c]=b[c]}return d},hexout:function hexout(b,c){try{var f=["","0","00","000","0000","00000","000000","0000000"];var d=(b>>>0).toString(16).toLowerCase();if(d.length>c){throw new MiMicException(EE.NG)}var a=c-d.length;return f[a]+d}catch(g){throw new MiMicException(g)}},assocToStr:function assocToStr(b){var c="";for(k in b){c+=k+":"+b[k]+","}return c}};var MiMicError={OK:[0,"OK"],NG:[1073741824,"NG"],isOK:function(a){return(1073741824&a)==0},MID_MiMic:3735552,CAID_RemoteMCU:256,CAID_LPCXPresso1769:512};function MiMicException(){var d;if(typeof arguments.callee.caller=="function"){if(arguments.callee.caller.name.toString().length>0){d="function '"+arguments.callee.caller.name+"."}else{var b=arguments.callee.caller.toString();d="closure '"+b.substring(0,b.indexOf("{"))+"...'"}}else{d="root document"}var c="";switch(arguments.length){case 0:this.code=MiMicError.NG[0];this.message=d+" code(0x"+this.code.toString(16)+")"+MiMicError.NG[1];return;case 1:var a=arguments[0];if(a instanceof MiMicException){this.code=a.code;c="  \nfrom "+a.message}else{if(typeof a=="object"&&a.length==2){this.code=a[0];c=a[1]}else{this.code=MiMicError.NG[0];c=MiMicError.NG[1]+" "+(((typeof a)!="undefined")?a.toString():"v==undefined")}}this.message=d+" code(0x"+this.code.toString(16)+")"+c;return;case 2:var a=arguments[0];if(a instanceof MiMicException){this.code=a.code;this.message=d+" code(0x"+this.code.toString(16)+")\nfrom "+a.message+":"+arguments[1];return}else{if(typeof a!="string"&&a.length==2){this.code=a[0];this.message=d+" code(0x"+this.code.toString(16)+")"+a[1]+":"+arguments[1]}else{break}}return;default:break}throw new MiMicException("Invalid MiMicException argument.")}MiMicException.prototype={code:MiMicError.OK,message:"",alert:function(){alert(this.message)},toString:function(){return"MiMicException:"+this.message}};var MiMicRemoteMcuInterface;(function(){var EE=function(i_base){return{NG:[i_base|0,"Unknown exception in MiMicRemoteMcuInterface"],TCP_CONNECT:[i_base|1,"TCP CONNECT FAILED"],HTTP:[i_base|2,"HTTP FAILED"]}}(MiMicError.NG[0]|MiMicError.MID_MiMic|MiMicError.CAID_RemoteMCU);MiMicRemoteMcuInterface=function MiMicRemoteMcuInterface(i_path){this._mimic_path=i_path+((i_path.indexOf("/")==-1)?"/mvm/":"")};MiMicRemoteMcuInterface.prototype={_mimic_path:null,_keep_alive:null,_last_xhr_res_time:0,_xhrGet:function(i_url,i_async,i_callback){var xhr=window.XDomainRequest?new XDomainRequest():new XMLHttpRequest();var prog=0;try{if(i_async){xhr.onreadystatechange=function(){if(xhr.readyState==4){this._last_xhr_res_time=MiMicLib.getNow();i_callback(xhr)}}}xhr.open("GET",i_url,i_async);prog=1;xhr.send(null);if(!i_async){this._last_xhr_res_time=MiMicLib.getNow()}prog=2}catch(e){throw new MiMicException(function(){switch(prog){case 1:return EE.HTTP}return EE.TCP_CONNECT}(),"url="+i_url)}return xhr},_isOnline_parseResponse:function(res){function isok(i_s){function parse_version_tag(i_v){var t=i_v.split("/");var n=t[1].split(".");return{name:t[0],major:parseInt(n[0]),minor:parseInt(n[1])}}try{var l=i_s.split(";");var rmcu=parse_version_tag(l[0]);var mcut=l[1];return((rmcu.name=="ModRemoteMcu")&&(rmcu.major==1)&&(rmcu.minor>=0))}catch(e){throw MiMicException(e)}}try{if(res.status!=200){return false}var ret=eval("("+res.responseText+")");if(!isok(ret.application)){return false}}catch(e){return false}return true},_parseMvmResult:function(i_mvmresult){function isok(i_s){var l=i_s.split(";");return((l[0].indexOf("ModRemoteMcu/1.")==0)&&(l[1]=="Json/1.0"))}var ret=eval("("+i_mvmresult+")");if(isok(ret.version)){if(ret.result!=undefined){if(ret.result!=0||ret.stream!=undefined){return ret}}}throw new MiMicException(EE.NG,"Invalid json version:'"+ret.version+"'")},isConnected:function isConnected(){return this._keep_alive!=null},execBc:function execBc(i_bc){try{if(this._keep_alive==null){throw new MiMicException(EE.NG,"disconnected")}var res=this._xhrGet("http://"+this._mimic_path+"mvm.api?v=1&bc="+i_bc,false);if(res.status!=200){throw new MiMicException(EE.HTTP,"i_bc="+i_bc+",XHR.status="+res.status)}return this._parseMvmResult(res.responseText,false)}catch(e){throw new MiMicException(e)}},connect:function connect(i_callback){try{var _t=this;if(this._keep_alive!=null){return}function xhrStatus(i_is_async,i_cb){try{return _t._xhrGet("http://"+_t._mimic_path+"status.api",i_is_async,i_cb)}catch(e){return null}}function intervalProc(){var now=MiMicLib.getNow();var lt=now-_t._last_xhr_res_time;if(lt<3000){return}var res=xhrStatus(false,null);if((res==null)||(!_t._isOnline_parseResponse(res))){if(_t._keep_alive!=null){clearInterval(_t._keep_alive.tid);_t._keep_alive=null;i_callback(false)}}i_callback(true)}var res=xhrStatus(false,null);if((res==null)||(!_t._isOnline_parseResponse(res))){throw new MiMicException("Bad response from "+this._mimic_path)}this._keep_alive={tid:setInterval(intervalProc,500)}}catch(e){throw new MiMicException(e)}return},disconnect:function disconnect(){try{if(this._keep_alive!=null){clearInterval(this._keep_alive.tid);this._keep_alive=null}}catch(e){throw new MiMicException(e)}}}}());
\ No newline at end of file
index 417f828..cbe84bf 100644 (file)
@@ -332,9 +332,8 @@ MiMicILAsm.prototype=
                        if(code==null){\r
                                return "";\r
                        }\r
-\r
                        for(var i=0;i<opr_tbl.length;i++){\r
-                               if(opr_tbl[i][0]==code.op){\r
+                               if(opr_tbl[i][0]==code.op.toUpperCase()){\r
                                        //オペコードの解析\r
                                        return opr_tbl[i][1].call(this,code);\r
                                }\r
index 6166301..fad02ad 100644 (file)
@@ -29,6 +29,7 @@ REM make a x.All-mini.js
 java -jar D:\application.files\yuicompressor-2.4.6\build\yuicompressor-2.4.6.jar -o LPC1769.All-mini.js "LPC1769.All.js\r
 java -jar D:\application.files\yuicompressor-2.4.6\build\yuicompressor-2.4.6.jar -o LPCXPresso1769.All-mini.js "LPCXPresso1769.All.js\r
 java -jar D:\application.files\yuicompressor-2.4.6\build\yuicompressor-2.4.6.jar -o MbedM3.All-mini.js "MbedM3.All.js\r
+java -jar D:\application.files\yuicompressor-2.4.6\build\yuicompressor-2.4.6.jar -o MiMicCore-mini.js "MiMicCore.js\r
 \r
 \r
  \r