"""Common trace code generation."""
-import stdapi
+import specs.stdapi as stdapi
from dispatch import Dispatcher
print "};"
print
+ def visit_polymorphic(self, polymorphic):
+ pass
+
class DumpImplementer(stdapi.Visitor):
'''Dump an instance.'''
def visit_interface(self, interface, instance):
print ' Trace::localWriter.writeOpaque((const void *)&%s);' % instance
+ def visit_polymorphic(self, polymorphic, instance):
+ print ' switch (%s) {' % polymorphic.switch_expr
+ for cases, type in polymorphic.iterswitch():
+ for case in cases:
+ print ' %s:' % case
+ self.visit(type, 'static_cast<%s>(%s)' % (type, instance));
+ print ' break;'
+ print ' }'
+
dump_instance = DumpImplementer().visit
print " if (%s) {" % instance
print " %s = new %s(%s);" % (instance, interface_wrap_name(interface), instance)
print " }"
+
+ def visit_polymorphic(self, type, instance):
+ # XXX: There might be polymorphic values that need wrapping in the future
+ pass
class Unwrapper(Wrapper):