dascii.java

来自「用Java实现的编译器。把源代码编译成SPARC汇编程序」· Java 代码 · 共 60 行

JAVA
60
字号
// $Id: dAsciiz.java,v 1.5 2000/10/21 23:18:10 mdeeds Exp $package java6035.tools.ASM;/** * dAsciiz *	 * represents an .asciiz directive in ASM file. ".ascii str" stores the * string in memory	as a sequence of bytes without the terminating null character */public class dAscii extends ASMDirective{    public String str;    /**     * Create a new ASCII string directive.       * @param str is the string to represent.      **/    public dAscii(String str)    {		super(ASMDirective.ASCII);				this.str = str;    }    /**     * Quotes the string in a way that can be understood by other tools.     * Turns quotes into \", backslashes into \\, and newlines into \n.     */    public static String quotify(String str)    {        String out = "";        int i;                for (i = 0; i < str.length(); i++)        {            if (str.charAt(i) == '\\')                out += "\\\\";            else if (str.charAt(i) == '\"')                out += "\\\"";            else if (str.charAt(i) == '\n')                out += "\\n";            else                out += str.charAt(i);        }        return out;    }    /**     * Returns the string representation.  Special characters in the string     * are replaced with their backslash-quoted representation.     */    public String toString()    {		return ".ascii \""+quotify(str)+"\"";    }}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?