Compiler - OP_USE_TEXTURE + various operators

This commit is contained in:
Emmanuel BENOîT 2017-11-13 16:58:38 +01:00
parent b9d9589d80
commit d6fb6f9831
3 changed files with 47 additions and 22 deletions

View file

@ -35,8 +35,17 @@ enum E_OpType
OP_FP_SUB ,
OP_FP_MUL ,
OP_FP_DIV ,
OP_FP_POW ,
//
OP_FP_NEG ,
OP_FP_INV ,
OP_FP_NOT ,
OP_FP_SIN ,
OP_FP_COS ,
OP_FP_TAN ,
OP_FP_SQRT ,
OP_FP_EXP ,
OP_FP_LN ,
//
OP_INIT_PIPELINE ,
OP_INIT_PROGRAM ,
@ -47,6 +56,7 @@ enum E_OpType
OP_FB_TOGGLE ,
OP_USE_PIPELINE ,
OP_USE_PROGRAM ,
OP_USE_TEXTURE ,
//
OP_FULLSCREEN ,
OP_CLEAR ,

View file

@ -315,6 +315,7 @@ bool T_CompilerImpl_::compileNode(
break;
case A_Node::ILIST: break;
case A_Node::OP_LOCALS: break;
case A_Node::DECL_FN:
{
@ -521,6 +522,15 @@ bool T_CompilerImpl_::compileNode(
}
break;
case A_Node::OP_USE_TEXTURE:
if ( exit ) {
auto& tn( (T_UseTextureInstrNode&) node );
processIdentifier( funcIndex , tn.samplerId( ) , tn.samplerIdLocation( ) );
processIdentifier( funcIndex , tn.id( ) , tn.idLocation( ) );
addInstruction( OP_USE_TEXTURE , tn.bank( ) , tn.location( ) );
}
break;
//- RENDERING -------------------------------------------------------------------------
@ -586,26 +596,21 @@ bool T_CompilerImpl_::compileNode(
}
break;
case A_Node::EXPR_ADD:
if ( exit ) {
addInstruction( OP_FP_ADD , node.location( ) );
}
break;
case A_Node::EXPR_SUB:
if ( exit ) {
addInstruction( OP_FP_SUB , node.location( ) );
}
break;
case A_Node::EXPR_MUL:
if ( exit ) {
addInstruction( OP_FP_MUL , node.location( ) );
}
break;
case A_Node::EXPR_DIV:
if ( exit ) {
addInstruction( OP_FP_DIV , node.location( ) );
}
break;
case A_Node::EXPR_ADD: if ( exit ) { addInstruction( OP_FP_ADD , node.location( ) ); } break;
case A_Node::EXPR_SUB: if ( exit ) { addInstruction( OP_FP_SUB , node.location( ) ); } break;
case A_Node::EXPR_MUL: if ( exit ) { addInstruction( OP_FP_MUL , node.location( ) ); } break;
case A_Node::EXPR_DIV: if ( exit ) { addInstruction( OP_FP_DIV , node.location( ) ); } break;
case A_Node::EXPR_POW: if ( exit ) { addInstruction( OP_FP_POW , node.location( ) ); } break;
case A_Node::EXPR_NEG: if ( exit ) { addInstruction( OP_FP_NEG , node.location( ) ); } break;
case A_Node::EXPR_INV: if ( exit ) { addInstruction( OP_FP_INV , node.location( ) ); } break;
case A_Node::EXPR_NOT: if ( exit ) { addInstruction( OP_FP_NOT , node.location( ) ); } break;
case A_Node::EXPR_SIN: if ( exit ) { addInstruction( OP_FP_SIN , node.location( ) ); } break;
case A_Node::EXPR_COS: if ( exit ) { addInstruction( OP_FP_COS , node.location( ) ); } break;
case A_Node::EXPR_TAN: if ( exit ) { addInstruction( OP_FP_TAN , node.location( ) ); } break;
case A_Node::EXPR_SQRT: if ( exit ) { addInstruction( OP_FP_SQRT , node.location( ) ); } break;
case A_Node::EXPR_EXP: if ( exit ) { addInstruction( OP_FP_EXP , node.location( ) ); } break;
case A_Node::EXPR_LN: if ( exit ) { addInstruction( OP_FP_LN , node.location( ) ); } break;
//- EXPRESSIONS - TERMINAL NODES ------------------------------------------------------

14
ops.cc
View file

@ -107,8 +107,17 @@ static T_KeyValueTable< E_OpType , T_OpInfo > OpInfoTable_{ ([]() {
infos.add( E_OpType::OP_FP_SUB , T_OpInfo{ "fp-sub" , 0 , OpStackFPU{ -1 } } );
infos.add( E_OpType::OP_FP_MUL , T_OpInfo{ "fp-mul" , 0 , OpStackFPU{ -1 } } );
infos.add( E_OpType::OP_FP_DIV , T_OpInfo{ "fp-div" , 0 , OpStackFPU{ -1 } } );
infos.add( E_OpType::OP_FP_MUL , T_OpInfo{ "fp-neg" , 0 } );
infos.add( E_OpType::OP_FP_DIV , T_OpInfo{ "fp-inv" , 0 } );
infos.add( E_OpType::OP_FP_POW , T_OpInfo{ "fp-pow" , 0 , OpStackFPU{ -1 } } );
//
infos.add( E_OpType::OP_FP_NEG , T_OpInfo{ "fp-neg" , 0 } );
infos.add( E_OpType::OP_FP_INV , T_OpInfo{ "fp-inv" , 0 } );
infos.add( E_OpType::OP_FP_NOT , T_OpInfo{ "fp-not" , 0 } );
infos.add( E_OpType::OP_FP_SIN , T_OpInfo{ "fp-sin" , 0 } );
infos.add( E_OpType::OP_FP_COS , T_OpInfo{ "fp-cos" , 0 } );
infos.add( E_OpType::OP_FP_TAN , T_OpInfo{ "fp-tan" , 0 } );
infos.add( E_OpType::OP_FP_SQRT , T_OpInfo{ "fp-sqrt" , 0 } );
infos.add( E_OpType::OP_FP_EXP , T_OpInfo{ "fp-exp" , 0 } );
infos.add( E_OpType::OP_FP_LN , T_OpInfo{ "fp-ln" , 0 } );
//
infos.add( E_OpType::OP_INIT_PIPELINE , T_OpInfo{ "pipeline" , 1 , OpStackMain{ -1 } } );
infos.add( E_OpType::OP_INIT_PROGRAM , T_OpInfo{ "program" , 1 , OpStackMain{ -1 } } );
@ -119,6 +128,7 @@ static T_KeyValueTable< E_OpType , T_OpInfo > OpInfoTable_{ ([]() {
infos.add( E_OpType::OP_FB_TOGGLE , T_OpInfo{ "fb-toggle" , 2 } );
infos.add( E_OpType::OP_USE_PIPELINE , T_OpInfo{ "use-pipeline" , 0 , OpStackMain{ -1 } } );
infos.add( E_OpType::OP_USE_PROGRAM , T_OpInfo{ "use-program" , 0 , OpStackMain{ -1 } } );
infos.add( E_OpType::OP_USE_TEXTURE , T_OpInfo{ "use-texture" , 1 , OpStackMain{ -2 } } );
//
infos.add( E_OpType::OP_FULLSCREEN , T_OpInfo{ "fullscreen" } );
infos.add( E_OpType::OP_CLEAR , T_OpInfo{ "clear" , 0 , OpStackMain{ -4 } } );