[pypy-svn] r27875 - in pypy/dist/pypy/translator/js2: . jssrc

fijal at codespeak.net fijal at codespeak.net
Mon May 29 20:00:48 CEST 2006


Author: fijal
Date: Mon May 29 20:00:47 2006
New Revision: 27875

Added:
   pypy/dist/pypy/translator/js2/jssrc/
   pypy/dist/pypy/translator/js2/jssrc/misc.js
Modified:
   pypy/dist/pypy/translator/js2/js.py
Log:
Added missing javascript source file


Modified: pypy/dist/pypy/translator/js2/js.py
==============================================================================
--- pypy/dist/pypy/translator/js2/js.py	(original)
+++ pypy/dist/pypy/translator/js2/js.py	Mon May 29 20:00:47 2006
@@ -48,7 +48,7 @@
         self.filename = self.cli.tmpfile
 
         data = self.filename.open().read()
-        src_filename = _path_join(os.path.dirname(__file__), 'src', 'misc.js')
+        src_filename = _path_join(os.path.dirname(__file__), 'jssrc', 'misc.js')
         f = self.cli.tmpfile.open("w")
         s = open(src_filename).read()
         f.write(s)

Added: pypy/dist/pypy/translator/js2/jssrc/misc.js
==============================================================================
--- (empty file)
+++ pypy/dist/pypy/translator/js2/jssrc/misc.js	Mon May 29 20:00:47 2006
@@ -0,0 +1,72 @@
+var in_browser;
+try {
+    dummy = alert;
+    in_browser = true;
+} catch (e) {
+    in_browser = false;
+}
+
+function log(s) {
+    if (in_browser) {
+        var logdiv = document.getElementById('logdiv');
+        logdiv.innerHTML = new Date().getTime() + ': ' + s + "<br/>" + logdiv.innerHTML;
+    } else {
+        print('log: ' + s);
+    }
+}
+
+function alloc_and_set(L0, len, elem) {
+    l = [];
+    for(i = 0; i < len; ++i){
+        l[i] = elem;
+    }
+    return(l);
+}
+
+function strconcat(s1, s2) {
+    return(s1+s2);
+}
+
+function stritem(cl, s, it) {
+    return(s[it]);
+}
+
+function delitem(fn, l, i) {
+    for(j = i; j < l.length-1; ++j) {
+        l[j] = l[j+1];
+    }
+    l.length--;
+}
+
+function strcmp(s1, s2) {
+    if ( s1 < s2 ) {
+        return ( -1 );
+    } else if ( s1 == s2 ) {
+        return ( 0 );
+    }
+    return (1);
+}
+
+function startswith(s1, s2) {
+    if (s1.length<s2.length) {
+        return(false);
+    }
+    for (i = 0; i < s2.length; ++i){
+        if (s1[i]!=s2[i]) {
+            return(false);
+        }
+    }
+    return(true);
+}
+
+function endswith(s1, s2) {
+    if (s2.length>s1.length) {
+        return(false);
+    }
+    for (i = s1.length-s2.length; i<s1.length; ++i) {
+        if (s1[i]!=s2[i-s1.length+s2.length]) {
+            return(false);
+        }
+    }
+    return(true);
+}



More information about the Pypy-commit mailing list