+PyCode class implementation.
+This class is similar to the built-in code objects.
+It avoids wrapping existing code object, instead,
+it plays its role without exposing real code objects.
+SInce in C Python the only way to crate a code object
+by somehow call into the builtin compile, we implement
+the creation of our code object by defining out own compile,
+wich ()at the moment) calls back into the real compile,
+hijacks the code object and creates our code object from that.
+compile is found in the builtin.py file.
+# look at this if it makes sense
+# think of a proper base class???
+from appfile import AppFile
+#appfile = AppFile(__name__, ["interpreter"])
+ """Represents a code object, in the way we need it.
+ """ initialize all attributes to just something. """
+ self.co_varnames = None
+ self.co_freevars = None
+ self.co_cellvars = None
+ # The rest doesn't count for hash/cmp
+ self.co_firstlineno = 0 #first source line number
+ self.co_lnotab = "" # string (encoding addr<->lineno mapping)
+ ### codeobject initialization ###
+ def _from_code(self, code):
+ """ Initialize the code object from a real one.
+ This is just a hack, until we have our own compile.
+ At the moment, we just fake this.
+ This method is called by our compile builtin function.
+ assert(type(code is types.CodeType))
+ # simply try to suck in all attributes we know of
+ for name in self.__dict__.keys():
+ value = getattr(code, name)
+ setattr(self, name, value)