@@ -330,9 +330,32 @@ void CodeFragment::constructOperation(sp::utree const& _t, CompilerState& _s)
330330 if (nonStandard)
331331 return ;
332332
333- std::map<std::string, Instruction> const c_arith = { { " +" , Instruction::ADD }, { " -" , Instruction::SUB }, { " *" , Instruction::MUL }, { " /" , Instruction::DIV }, { " %" , Instruction::MOD }, { " &" , Instruction::AND }, { " |" , Instruction::OR }, { " ^" , Instruction::XOR } };
334- std::map<std::string, pair<Instruction, bool >> const c_binary = { { " <" , { Instruction::LT , false } }, { " <=" , { Instruction::GT , true } }, { " >" , { Instruction::GT , false } }, { " >=" , { Instruction::LT , true } }, { " S<" , { Instruction::SLT , false } }, { " S<=" , { Instruction::SGT , true } }, { " S>" , { Instruction::SGT , false } }, { " S>=" , { Instruction::SLT , true } }, { " =" , { Instruction::EQ , false } }, { " !=" , { Instruction::EQ , true } } };
335- std::map<std::string, Instruction> const c_unary = { { " !" , Instruction::ISZERO } };
333+ std::map<std::string, Instruction> const c_arith = {
334+ { " +" , Instruction::ADD },
335+ { " -" , Instruction::SUB },
336+ { " *" , Instruction::MUL },
337+ { " /" , Instruction::DIV },
338+ { " %" , Instruction::MOD },
339+ { " &" , Instruction::AND },
340+ { " |" , Instruction::OR },
341+ { " ^" , Instruction::XOR }
342+ };
343+ std::map<std::string, pair<Instruction, bool >> const c_binary = {
344+ { " <" , { Instruction::LT , false } },
345+ { " <=" , { Instruction::GT , true } },
346+ { " >" , { Instruction::GT , false } },
347+ { " >=" , { Instruction::LT , true } },
348+ { " S<" , { Instruction::SLT , false } },
349+ { " S<=" , { Instruction::SGT , true } },
350+ { " S>" , { Instruction::SGT , false } },
351+ { " S>=" , { Instruction::SLT , true } },
352+ { " =" , { Instruction::EQ , false } },
353+ { " !=" , { Instruction::EQ , true } }
354+ };
355+ std::map<std::string, Instruction> const c_unary = {
356+ { " !" , Instruction::ISZERO },
357+ { " ~" , Instruction::NOT }
358+ };
336359
337360 vector<CodeFragment> code;
338361 CompilerState ns = _s;
@@ -449,14 +472,15 @@ void CodeFragment::constructOperation(sp::utree const& _t, CompilerState& _s)
449472 m_asm << end.tag ();
450473 m_asm.donePaths ();
451474 }
452- else if (us == " WHILE" )
475+ else if (us == " WHILE" || us == " UNTIL " )
453476 {
454477 requireSize (2 );
455478 requireDeposit (0 , 1 );
456479
457480 auto begin = m_asm.append ();
458481 m_asm.append (code[0 ].m_asm );
459- m_asm.append (Instruction::ISZERO );
482+ if (us == " WHILE" )
483+ m_asm.append (Instruction::ISZERO );
460484 auto end = m_asm.appendJumpI ();
461485 m_asm.append (code[1 ].m_asm , 0 );
462486 m_asm.appendJump (begin);
@@ -541,17 +565,6 @@ void CodeFragment::constructOperation(sp::utree const& _t, CompilerState& _s)
541565 // At end now.
542566 m_asm.append (end);
543567 }
544- else if (us == " ~" )
545- {
546- requireSize (1 );
547- requireDeposit (0 , 1 );
548-
549- m_asm.append (code[0 ].m_asm , 1 );
550- m_asm.append ((u256)1 );
551- m_asm.append ((u256)0 );
552- m_asm.append (Instruction::SUB );
553- m_asm.append (Instruction::SUB );
554- }
555568 else if (us == " SEQ" )
556569 {
557570 unsigned ii = 0 ;
@@ -567,6 +580,10 @@ void CodeFragment::constructOperation(sp::utree const& _t, CompilerState& _s)
567580 m_asm.append (i.m_asm );
568581 m_asm.popTo (1 );
569582 }
583+ else if (us == " PANIC" )
584+ {
585+ m_asm.appendJump (m_asm.errorTag ());
586+ }
570587 else if (us.find_first_of (" 1234567890" ) != 0 && us.find_first_not_of (" QWERTYUIOPASDFGHJKLZXCVBNM1234567890_" ) == string::npos)
571588 m_asm.append ((u256)varAddress (s));
572589 else
0 commit comments