We planned to upgrade GitLab and Mattermost to the latest version this Friday morning (early). You may experience some downtime!

Commit 574228ee authored by Joost Rijneveld's avatar Joost Rijneveld

Added trap 1 instruction to print unicode characters

parent 093270d3
......@@ -162,6 +162,7 @@ public class Instruction
* Traps
*/
protected final static int TR_PR_INT = 0 ;
protected final static int TR_PR_CHAR = 1 ;
/**
* Metas
......
......@@ -9,6 +9,8 @@
package nl.uu.cs.ssm ;
import java.awt.Color;
import java.io.UnsupportedEncodingException;
import java.nio.ByteBuffer;
public class Machine
{
......@@ -479,7 +481,15 @@ public class Machine
case Instruction.TR_PR_INT :
messenger.println( "" + pop() ) ;
break ;
case Instruction.TR_PR_CHAR :
ByteBuffer b = ByteBuffer.allocate(4);
b.putInt(pop());
try {
messenger.println( "" + new String(b.array(), "UTF-32") ) ;
} catch (UnsupportedEncodingException e) {
messenger.println("Error: UTF-32 encoding missing.");
}
break;
default : break ;
}
break ;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment