From 83b76a96f6a99afc9394f62c9ffefe10316505ac Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Emmanuel=20Beno=C3=AEt?= <tseeker@nocternity.net>
Date: Mon, 13 Nov 2017 18:51:15 +0100
Subject: [PATCH] Compiler - Output debugging instruction

---
 control.hh |  1 +
 opcomp.cc  | 27 +++++++++++++++++----------
 ops.cc     |  3 ++-
 3 files changed, 20 insertions(+), 11 deletions(-)

diff --git a/control.hh b/control.hh
index dfe7981..a78e204 100644
--- a/control.hh
+++ b/control.hh
@@ -68,6 +68,7 @@ enum E_OpType
 	OP_UI_PENTER ,
 	OP_UI_PEXIT ,
 	OP_UI_INPUT_DFT ,
+	OP_UI_ODBG ,
 };
 
 M_LSHIFT_OP( T_StringBuilder , E_OpType );
diff --git a/opcomp.cc b/opcomp.cc
index d34523b..73f2499 100644
--- a/opcomp.cc
+++ b/opcomp.cc
@@ -620,17 +620,24 @@ bool T_CompilerImpl_::compileNode(
 			auto& in( (T_InputInstrNode&) node );
 			T_OpValue value;
 			value.f = in.defValue( );
+			addInstruction( OP_UI_INPUT_DFT , {
+						uint32_t( output->inputs.indexOf( in.id( ) ) ) ,
+						uint32_t( constants.indexOf( value.u ) + 3 ) } ,
+					node.location( ) );
+		}
+		break;
 
-			addInstruction( OP_FP_LOAD ,
-					constants.indexOf( value.u ) + 3 ,
-					in.defValueLocation( ) );
-			addInstruction( OP_PUSH , in.defValueLocation( ) );
-			addInstruction( OP_FP_SSTORE_INT , 0 , in.defValueLocation( ) );
-
-			addInstruction( OP_CONST , output->inputs.indexOf( in.id( ) ) , in.idLocation( ) );
-			addInstruction( OP_PUSH , in.defValueLocation( ) );
-
-			addInstruction( OP_UI_INPUT_DFT , node.location( ) );
+	    case A_Node::OP_ODBG:
+		if ( exit ) {
+			auto& n( (T_OutputDebugInstrNode&) node );
+			if ( ! output->uiStrings.contains( n.description( ) ) ) {
+				output->uiStrings.add( n.description( ) );
+			}
+			processIdentifier( funcIndex , n.texture( ) , n.textureLocation( ) );
+			addInstruction( OP_UI_ODBG , {
+						uint32_t( n.mode( ) ) ,
+						uint32_t( output->uiStrings.indexOf( n.description( ) ) ) } ,
+					node.location( ) );
 		}
 		break;
 
diff --git a/ops.cc b/ops.cc
index 44d717a..6329939 100644
--- a/ops.cc
+++ b/ops.cc
@@ -139,7 +139,8 @@ static T_KeyValueTable< E_OpType , T_OpInfo > OpInfoTable_{ ([]() {
 	//
 	infos.add( E_OpType::OP_UI_PENTER , T_OpInfo{ "ui-prof-enter" , 1 } );
 	infos.add( E_OpType::OP_UI_PEXIT , T_OpInfo{ "ui-prof-exit" } );
-	infos.add( E_OpType::OP_UI_INPUT_DFT , T_OpInfo{ "ui-input-default" , 0 , OpStackMain{ -2 } } );
+	infos.add( E_OpType::OP_UI_INPUT_DFT , T_OpInfo{ "ui-input-default" , 2 } );
+	infos.add( E_OpType::OP_UI_ODBG , T_OpInfo{ "ui-odbg" , 2 , OpStackMain{ -1 } } );
 
 	return infos;
 })( ) };