diff --git a/src/pike_types.c b/src/pike_types.c
index a500594e484bf8574779b6f82dd7d67f1dd20307..34c9dc2e907f8c4dd49dcdc9c15c8a5c0019c241 100644
--- a/src/pike_types.c
+++ b/src/pike_types.c
@@ -755,8 +755,17 @@ void debug_push_int_type(INT_TYPE min, INT_TYPE max)
   TYPE_STACK_DEBUG("push_int_type");
 }
 
+static int (*program_id_to_id)(int) = NULL;
+
+PMOD_EXPORT void set_program_id_to_id( int (*to)(int) )
+{
+    program_id_to_id = to;
+}
+
 void debug_push_object_type(int flag, INT32 id)
 {
+  if( program_id_to_id )
+      id = program_id_to_id(id);
   *(++Pike_compiler->type_stackp) = mk_type(T_OBJECT,
                                             (void *)(ptrdiff_t)flag,
                                             (void *)(ptrdiff_t)id, 0);
diff --git a/src/pike_types.h b/src/pike_types.h
index 8991d7bd73154be95310de6b13b09a06c0792cb8..d83b2e781518609e914434ee6ccf019a9795fa39 100644
--- a/src/pike_types.h
+++ b/src/pike_types.h
@@ -324,6 +324,10 @@ struct pike_string *type_to_string(struct pike_type *t);
 int pike_type_allow_premature_toss(struct pike_type *type);
 void register_attribute_handler(struct pike_string *attr,
 				struct svalue *handler);
+
+/* used by the precompiler to get the correct object types */
+PMOD_EXPORT void set_program_id_to_id( int (*to)(int) );
+
 /* Prototypes end here */
 
 #define visit_type_ref(T, REF_TYPE, EXTRA)			\