#NEWLINE# def dump( self ) : #NEWLINE# #INDENT# self . source = '' #NEWLINE# def append( x , indsize = 3 ) : #NEWLINE# #INDENT# indent = ( ' ' * indsize ) #NEWLINE# self . source = ( ( ( self . source + indent ) + x ) + '\n' ) #NEWLINE# #UNINDENT# append ( 'from astbuilder import *' , 0 ) #NEWLINE# append ( 'def init(i, imod):' , 0 ) #NEWLINE# append ( 'kernel_cmodule = i.new_object()' ) #NEWLINE# append ( 'kernel_imodule = imod' ) #NEWLINE# for ( k , v ) in self . objects . iteritems ( ) : #NEWLINE# #INDENT# append ( ( k + ' = i.new_object()' ) ) #NEWLINE# #UNINDENT# for ( k , v ) in self . classes . iteritems ( ) : #NEWLINE# #INDENT# append ( ( k + ' = i.new_object()' ) ) #NEWLINE# append ( ( ( ( k + "['@tag'] = '" ) + k ) + " class'" ) ) #NEWLINE# append ( ( ( ( ( ( k + "Behavior = i.new_object({'_vt': Behavior,'parent':" ) + self . supers [ k ] ) + "Behavior, 'dict':{}, '@tag':'" ) + k ) + "Behavior'})" ) ) #NEWLINE# append ( ( ( ( ( k + 'Behavior' ) + "['@tag'] = '" ) + k ) + " behavior'" ) ) #NEWLINE# #UNINDENT# for ( name , val ) in self . classes . iteritems ( ) : #NEWLINE# #INDENT# append ( ( ( ( 'kernel_imodule[' + to_source ( name ) ) + '] = ' ) + name ) ) #NEWLINE# #UNINDENT# for ( name , val ) in self . objects . iteritems ( ) : #NEWLINE# #INDENT# append ( ( ( ( 'kernel_imodule[' + to_source ( name ) ) + '] = ' ) + name ) ) #NEWLINE# #UNINDENT# for ( name , obj ) in self . objects . iteritems ( ) : #NEWLINE# #INDENT# for ( key , v ) in obj . iteritems ( ) : #NEWLINE# #INDENT# append ( ( ( ( ( name + '[' ) + to_source ( key ) ) + '] = ' ) + v ) ) #NEWLINE# #UNINDENT# append ( ( ( name + "['@tag'] = " ) + to_source ( name ) ) ) #NEWLINE# #UNINDENT# for ( name , dc ) in self . funs . iteritems ( ) : #NEWLINE# #INDENT# if ( len ( dc ) > 0 ) : #NEWLINE# #INDENT# append ( ( name + "['dict'] = {}" ) ) #NEWLINE# #UNINDENT# for ( mname , v ) in dc . iteritems ( ) : #NEWLINE# #INDENT# append ( ( ( ( ( name + "['dict'][" ) + to_source ( mname ) ) + '] = ' ) + k ) ) #NEWLINE# #UNINDENT# #UNINDENT# for ( name , obj ) in self . classes . iteritems ( ) : #NEWLINE# #INDENT# for ( key , v ) in obj . iteritems ( ) : #NEWLINE# #INDENT# append ( ( ( ( ( name + '[' ) + to_source ( key ) ) + '] = ' ) + v ) ) #NEWLINE# #UNINDENT# #UNINDENT# for ( name , obj ) in self . classes . iteritems ( ) : #NEWLINE# #INDENT# append ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( name + '["compiled_class"] = i.create_compiled_class({"_vt": CompiledClass,' ) + '"_delegate": None,' ) + '"name": "' ) + name ) + '",' ) + '"super_class_name":"' ) + self . supers [ name ] ) + '",' ) + '"fields": ' ) + to_source ( self . fields [ name ] ) ) + ',' ) + '"module": kernel_cmodule,' ) + '"methods": {},' ) + '"own_methods":{}})' ) ) #NEWLINE# #UNINDENT# for ( name , dc ) in self . methods . iteritems ( ) : #NEWLINE# #INDENT# if ( len ( dc ) > 0 ) : #NEWLINE# #INDENT# append ( ( name + "['dict'] = {}" ) ) #NEWLINE# #UNINDENT# for ( mname , v ) in dc . iteritems ( ) : #NEWLINE# #INDENT# append ( ( ( ( ( name + "['compiled_class']['methods'][" ) + to_source ( mname ) ) + '] = ' ) + v ) ) #NEWLINE# append ( ( ( ( ( ( ( ( name + "['dict'][" ) + to_source ( mname ) ) + '] = i.function_from_cfunction(' ) + name ) + "['compiled_class']['methods'][" ) + to_source ( mname ) ) + '], kernel_imodule)' ) ) #NEWLINE# #UNINDENT# #UNINDENT# for ( name , dc ) in self . bv_methods . iteritems ( ) : #NEWLINE# #INDENT# for ( mname , v ) in dc . iteritems ( ) : #NEWLINE# #INDENT# append ( ( ( ( ( name + "['compiled_class']['own_methods'][" ) + to_source ( mname ) ) + '] = ' ) + v ) ) #NEWLINE# append ( ( ( ( ( ( ( ( name + "Behavior['dict'][" ) + to_source ( mname ) ) + '] = i.function_from_cfunction(' ) + name ) + "['compiled_class']['own_methods'][" ) + to_source ( mname ) ) + '], kernel_imodule)' ) ) #NEWLINE# #UNINDENT# #UNINDENT# append ( "for name, m, in Object['dict'].iteritems():" ) #NEWLINE# append ( "   Object_CompiledClass['methods'][name] = m['compiled_function']" ) #NEWLINE# append ( "for name, m, in ObjectBehavior['dict'].iteritems():" ) #NEWLINE# append ( "   Object_CompiledClass['own_methods'][name] = m['compiled_function']" ) #NEWLINE# append ( ( ( ( "kernel_cmodule.update(i.create_compiled_module({'name': 'core'," + "'ast': None," ) + "'parent_module':None," ) + "'@tag':'kernel compiled module'}))" ) ) #NEWLINE# append ( 'KernelModule = i.new_object({"_vt": ModuleBehavior,' ) #NEWLINE# append ( '"_delegate": None,' ) #NEWLINE# append ( '"parent": Object,' ) #NEWLINE# append ( '"dict": {},' ) #NEWLINE# append ( '"@tag": "KernelModule"})' ) #NEWLINE# append ( "kernel_imodule['_vt'] = KernelModule" ) #NEWLINE# append ( "kernel_imodule['_delegate'] = None" ) #NEWLINE# append ( "kernel_imodule['@tag'] = 'Kernel module instance'" ) #NEWLINE# append ( "KernelModule['compiled_module'] = kernel_cmodule" ) #NEWLINE# for ( k , v ) in self . module_funs . iteritems ( ) : #NEWLINE# #INDENT# append ( ( ( k + ' = ' ) + v ) ) #NEWLINE# #UNINDENT# for ( name , val ) in self . module_funs . iteritems ( ) : #NEWLINE# #INDENT# append ( ( ( ( 'kernel_imodule[' + to_source ( name ) ) + '] = ' ) + name ) ) #NEWLINE# #UNINDENT# f = open ( 'core_module.py' , 'w' ) #NEWLINE# f . write ( self . source ) #NEWLINE# f . close ( )