blueloveTH hace 1 año
padre
commit
b6993532fa
Se han modificado 5 ficheros con 81 adiciones y 83 borrados
  1. 0 1
      include/pocketpy/common/_generated.h
  2. 0 80
      python/_set.py
  3. 81 0
      python/builtins.py
  4. 0 0
      src/common/_generated.c
  5. 0 2
      src/interpreter/vm.c

+ 0 - 1
include/pocketpy/common/_generated.h

@@ -5,7 +5,6 @@ const char* load_kPythonLib(const char* name);
 
 
 extern const char kPythonLibs__enum[];
 extern const char kPythonLibs__enum[];
 extern const char kPythonLibs__long[];
 extern const char kPythonLibs__long[];
-extern const char kPythonLibs__set[];
 extern const char kPythonLibs_bisect[];
 extern const char kPythonLibs_bisect[];
 extern const char kPythonLibs_builtins[];
 extern const char kPythonLibs_builtins[];
 extern const char kPythonLibs_cmath[];
 extern const char kPythonLibs_cmath[];

+ 0 - 80
python/_set.py

@@ -1,80 +0,0 @@
-class set:
-    def __init__(self, iterable=None):
-        iterable = iterable or []
-        self._a = {}
-        self.update(iterable)
-
-    def add(self, elem):
-        self._a[elem] = None
-        
-    def discard(self, elem):
-        self._a.pop(elem, None)
-
-    def remove(self, elem):
-        del self._a[elem]
-        
-    def clear(self):
-        self._a.clear()
-
-    def update(self, other):
-        for elem in other:
-            self.add(elem)
-
-    def __len__(self):
-        return len(self._a)
-    
-    def copy(self):
-        return set(self._a.keys())
-    
-    def __and__(self, other):
-        return {elem for elem in self if elem in other}
-
-    def __sub__(self, other):
-        return {elem for elem in self if elem not in other}
-    
-    def __or__(self, other):
-        ret = self.copy()
-        ret.update(other)
-        return ret
-
-    def __xor__(self, other): 
-        _0 = self - other
-        _1 = other - self
-        return _0 | _1
-
-    def union(self, other):
-        return self | other
-
-    def intersection(self, other):
-        return self & other
-
-    def difference(self, other):
-        return self - other
-
-    def symmetric_difference(self, other):      
-        return self ^ other
-    
-    def __eq__(self, other):
-        if not isinstance(other, set):
-            return NotImplemented
-        return len(self ^ other) == 0
-
-    def isdisjoint(self, other):
-        return len(self & other) == 0
-    
-    def issubset(self, other):
-        return len(self - other) == 0
-    
-    def issuperset(self, other):
-        return len(other - self) == 0
-
-    def __contains__(self, elem):
-        return elem in self._a
-    
-    def __repr__(self):
-        if len(self) == 0:
-            return 'set()'
-        return '{'+ ', '.join([repr(i) for i in self._a.keys()]) + '}'
-    
-    def __iter__(self):
-        return iter(self._a.keys())

+ 81 - 0
python/builtins.py

@@ -181,3 +181,84 @@ def complex(*args, **kwargs):
 def long(*args, **kwargs):
 def long(*args, **kwargs):
     import _long
     import _long
     return _long.long(*args, **kwargs)
     return _long.long(*args, **kwargs)
+
+class set:
+    def __init__(self, iterable=None):
+        iterable = iterable or []
+        self._a = {}
+        self.update(iterable)
+
+    def add(self, elem):
+        self._a[elem] = None
+        
+    def discard(self, elem):
+        self._a.pop(elem, None)
+
+    def remove(self, elem):
+        del self._a[elem]
+        
+    def clear(self):
+        self._a.clear()
+
+    def update(self, other):
+        for elem in other:
+            self.add(elem)
+
+    def __len__(self):
+        return len(self._a)
+    
+    def copy(self):
+        return set(self._a.keys())
+    
+    def __and__(self, other):
+        return {elem for elem in self if elem in other}
+
+    def __sub__(self, other):
+        return {elem for elem in self if elem not in other}
+    
+    def __or__(self, other):
+        ret = self.copy()
+        ret.update(other)
+        return ret
+
+    def __xor__(self, other): 
+        _0 = self - other
+        _1 = other - self
+        return _0 | _1
+
+    def union(self, other):
+        return self | other
+
+    def intersection(self, other):
+        return self & other
+
+    def difference(self, other):
+        return self - other
+
+    def symmetric_difference(self, other):      
+        return self ^ other
+    
+    def __eq__(self, other):
+        if not isinstance(other, set):
+            return NotImplemented
+        return len(self ^ other) == 0
+
+    def isdisjoint(self, other):
+        return len(self & other) == 0
+    
+    def issubset(self, other):
+        return len(self - other) == 0
+    
+    def issuperset(self, other):
+        return len(other - self) == 0
+
+    def __contains__(self, elem):
+        return elem in self._a
+    
+    def __repr__(self):
+        if len(self) == 0:
+            return 'set()'
+        return '{'+ ', '.join([repr(i) for i in self._a.keys()]) + '}'
+    
+    def __iter__(self):
+        return iter(self._a.keys())

La diferencia del archivo ha sido suprimido porque es demasiado grande
+ 0 - 0
src/common/_generated.c


+ 0 - 2
src/interpreter/vm.c

@@ -200,8 +200,6 @@ void VM__ctor(VM* self) {
         bool ok;
         bool ok;
         ok = py_exec(kPythonLibs_builtins, "<builtins>", EXEC_MODE, &self->builtins);
         ok = py_exec(kPythonLibs_builtins, "<builtins>", EXEC_MODE, &self->builtins);
         if(!ok) goto __ABORT;
         if(!ok) goto __ABORT;
-        ok = py_exec(kPythonLibs__set, "<builtins>", EXEC_MODE, &self->builtins);
-        if(!ok) goto __ABORT;
         break;
         break;
     __ABORT:
     __ABORT:
         py_printexc();
         py_printexc();

Algunos archivos no se mostraron porque demasiados archivos cambiaron en este cambio