src/erjang/EAtom.java
return "'" + encode_escapes(value) + "'";
EAtom testAtom()
CharSequence seq
src/erjang/EAtom.java
StringBuffer sb = new StringBuffer();
		for (int i = 0; i < seq.length(); i++) {
			char ch = seq.charAt(i);
			if ((ch >= 0x20 && ch <= 0xff) && ch != '\'' && ch != 0x7f) {
				sb.append(ch);
String encode_escapes(CharSequence seq)
String name
src/erjang/EAtom.java
"intern", "(" + STRING_TYPE.getDescriptor() + ")"
						+ type.getDescriptor());
		return type;
boolean isAtom(String name)
src/erjang/EList.java
return this;
ECons testNonEmptyList()
src/erjang/ENil.java
return this;
ENil testNil()
src/erjang/EObject.java
public ECons testNonEmptyList() {
		return null;
EAtom testAtom()
src/erjang/EObject.java
public ESeq testSeq() {
	public EPID testPID() {
	public ENumber testNumber() {
	public ECons testCons() {
	public EInteger testInteger() {
		return null;
ETuple testTuple()
src/erjang/EPair.java
return this;
ECons testNonEmptyList()
EObject h  EObject t
src/erjang/ERT.java
return t.cons(h);
	public static final EAtom ATOM_TRUE = EAtom.intern("true");
	public static final EAtom ATOM_FALSE = EAtom.intern("false");
	
	public static boolean eq(EObject o1, EObject o2) { return o1==null?o2==null:o1.equals(o2);
ETerm cons(EObject h, EObject t)
EObject o1  EAtom o2
src/erjang/ERT.java
return o1==o2;
boolean eq(EObject o1, EAtom o2)
EAtom o1  EObject o2
src/erjang/ERT.java
return o1==o2;
boolean eq(EAtom o1, EObject o2)
EAtom o1  EAtom o2
src/erjang/ERT.java
return o1==o2;
boolean eq(EAtom o1, EAtom o2)
byte[] data  int off
src/erjang/EString.java
this.data = data;
		this.off = off;
private EString(byte[] data, int off)
obj instanceof String
src/erjang/EString.java
return stringValue().equals(obj);
		return (char) (data[off+index] & 0xff);
		return data.length-off;
		if (end == length()) return new EString(data, off+start);
		if (offset < 0 || length < 0 || (offset+length) > length())
	/* (non-Javadoc)
	 * @see erjang.ESeq#cons(erjang.EObject)
	 */
	@Override
	public EList cons(EObject h) {
		return new EList(h, this);
else if (obj instanceof String)
src/erjang/EString.java
if (off == data.length) return ENil.NIL;
		return new EString(data, off+1);
ESeq tail()
src/erjang/EString.java
return new EInteger(data[off] & 0xff);
EInteger head()
src/erjang/EString.java
return length() == 0 ? ENil.NIL : null;
ENil testNil()
src/erjang/EString.java
return length() == 0 ? null : this;
ECons testNonEmptyList()
Type typ
src/erjang/beam/CompilerVisitor.java
switch (typ.getSort()) {
				case Type.DOUBLE:
					return "Double";
				case Type.INT:
					return "Integer";
				case Type.BOOLEAN:
					return "Atom";
				default:
					throw new Error();
String primTypeName(Type typ)
ETerm value  int size
src/erjang/beam/CompilerVisitor.java
if (value instanceof EAtom)
					return "atom_" + EUtil.toJavaIdentifier((EAtom) value);
				if (value instanceof ENumber)
					return EUtil.toJavaIdentifier("num_"
							+ value.toString().replace('.', '_').replace('-',
									'_'));
				if (value instanceof EString)
					return "str_" + size;
				else
					return "cst_" + size;
String getConstantName(ETerm value, int size)
BeamOpcode opcode  Arg[] in  Arg out
src/erjang/beam/CompilerVisitor.java
switch (opcode) {
				case put_list:
					push(in[0], EOBJECT_TYPE);
					push(in[1], EOBJECT_TYPE);
					mv.visitMethodInsn(INVOKESTATIC,
							ERT_TYPE.getInternalName(), "cons", "("
									+ EOBJECT_TYPE.getDescriptor()
									+ EOBJECT_TYPE.getDescriptor() + ")"
									+ ECONS_TYPE.getDescriptor());
					pop(out, ECONS_TYPE);
					return;
void visitInsn(BeamOpcode opcode, Arg[] in, Arg out)
BeamOpcode opcode  int val  Arg out
src/erjang/beam/CompilerVisitor.java
switch (opcode) {
				case put_tuple:
					mv.visitTypeInsn(NEW, out.type.getInternalName());
					mv.visitInsn(DUP);
					mv.visitMethodInsn(INVOKESPECIAL, out.type
							.getInternalName(), "<init>", "()V");
					pop(out, out.type);

					return;
void visitInsn(BeamOpcode opcode, int val, Arg out)
BeamOpcode opcode  Arg val  Arg out  int pos
src/erjang/beam/CompilerVisitor.java
if (opcode == BeamOpcode.put) {
					push(out, out.type);
					push(val, EOBJECT_TYPE);
					mv.visitFieldInsn(PUTFIELD, out.type.getInternalName(),
							"elm" + pos, EOBJECT_TYPE.getDescriptor());
					return;
void visitInsn(BeamOpcode opcode, Arg val, Arg out, int pos)
opcode == BeamOpcode.get_tuple_element
src/erjang/beam/CompilerVisitor.java
push(val, val.type);
					mv.visitFieldInsn(GETFIELD, val.type.getInternalName(),
							"elm" + pos, EOBJECT_TYPE.getDescriptor());
					pop(out, EOBJECT_TYPE);
					return;
else if (opcode == BeamOpcode.get_tuple_element)
opcode == BeamOpcode.set_tuple_element
src/erjang/beam/CompilerVisitor.java
push(out, out.type);
					push(val, val.type);
					mv.visitFieldInsn(PUTFIELD, val.type.getInternalName(),
							"elm" + pos, EOBJECT_TYPE.getDescriptor());
					return;
			/**
			 * @param pos
			 */
			private void push_int(int pos) {
				if (pos >= -1 && pos <= 5) {
					mv.visitInsn(ICONST_0 + pos);
else if (opcode == BeamOpcode.set_tuple_element)
arg1 != null
src/erjang/beam/CompilerVisitor.java
mv.visitInsn(DUP);
							mv.visitVarInsn(ASTORE, scratch_reg);
test
						if (arg1 != null)
BeamOpcode test  int failLabel  Arg arg 
					int arity  Type tupleType
src/erjang/beam/CompilerVisitor.java
if (test != BeamOpcode.test_arity)
					throw new Error();

				push(arg, ETUPLE_TYPE);
				mv.visitMethodInsn(INVOKEVIRTUAL,
						ETUPLE_TYPE.getInternalName(), "count", "()I");
				push_int(arity);
				mv.visitJumpInsn(IF_ICMPNE, getLabel(failLabel));
				push(arg, ETUPLE_TYPE);
				mv.visitTypeInsn(CHECKCAST, tupleType.getInternalName());
				pop(arg, tupleType);
void visitTest(BeamOpcode test, int failLabel, Arg arg,
					int arity, Type tupleType)
BeamOpcode opcode  Arg[] ys
src/erjang/beam/CompilerVisitor.java
if (opcode == BeamOpcode.allocate_zero
						|| opcode == BeamOpcode.allocate_heap_zero) {

					mv.visitFieldInsn(GETSTATIC, ENIL_TYPE.getInternalName(),
							"NIL", ENIL_TYPE.getDescriptor());
					for (int i = 0; i < ys.length; i++) {
						if (i != (ys.length - 1))
							mv.visitInsn(DUP);
						pop(ys[i], ENIL_TYPE);
void visitInsn(BeamOpcode opcode, Arg[] ys)
opcode == BeamOpcode.get_list
src/erjang/beam/CompilerVisitor.java
push(ys[0], ECONS_TYPE);
					mv.visitInsn(DUP);
					mv.visitMethodInsn(INVOKEVIRTUAL, ECONS_TYPE
							.getInternalName(), "head", "()"
							+ EOBJECT_TYPE.getDescriptor());
					pop(ys[1], EOBJECT_TYPE);
					mv.visitMethodInsn(INVOKEVIRTUAL, ECONS_TYPE
							.getInternalName(), "tail", "()"
							+ EOBJECT_TYPE.getDescriptor());
					pop(ys[2], EOBJECT_TYPE);
					return;
else if (opcode == BeamOpcode.get_list)
opcode == BeamOpcode.apply
src/erjang/beam/CompilerVisitor.java
for (int i = 0; i < ys.length; i++) {
						push(ys[i], EOBJECT_TYPE);
else if (opcode == BeamOpcode.apply)
opcode == BeamOpcode.apply_last
src/erjang/beam/CompilerVisitor.java
for (int i = 0; i < ys.length; i++) {
						push(ys[i], EOBJECT_TYPE);
else if (opcode == BeamOpcode.apply_last)
opcode == BeamOpcode.send
src/erjang/beam/CompilerVisitor.java
for (int i = 0; i < ys.length; i++) {
						push(ys[i], EOBJECT_TYPE);
else if (opcode == BeamOpcode.send)
BeamOpcode opcode  ExtFunc efun 
					Arg[] freevars
src/erjang/beam/CompilerVisitor.java
if (opcode == BeamOpcode.make_fun2) {

					String funtype = EFUN_TYPE.getInternalName() + efun.no;
					for (int i = 0; i < freevars.length; i++) {
						push(freevars[i], EOBJECT_TYPE);
void visitInsn(BeamOpcode opcode, ExtFunc efun,
					Arg[] freevars)
Arg in  int failLabel  Arg[] values 
					int[] targets
src/erjang/beam/CompilerVisitor.java
int[] hash = new int[values.length];
				Label[] label = new Label[values.length];
				for (int i = 0; i < values.length; i++) {
					hash[i] = values[i].value.hashCode();
					label[i] = new Label();
void visitSelectValue(Arg in, int failLabel, Arg[] values,
					int[] targets)
Arg in  int failLabel  int[] arities 
					int[] targets
src/erjang/beam/CompilerVisitor.java
push(in, ETUPLE_TYPE);

				mv.visitMethodInsn(INVOKEVIRTUAL,
						ETUPLE_TYPE.getInternalName(), "count", "()I");

				Label[] targetLabels = new Label[targets.length];
				for (int i = 0; i < targets.length; i++) {
					targetLabels[i] = new Label();
void visitSelectTuple(Arg in, int failLabel, int[] arities,
					int[] targets)
int label
src/erjang/beam/CompilerVisitor.java
mv.visitJumpInsn(GOTO, getLabel(label));
void visitJump(int label)
int i
src/erjang/beam/CompilerVisitor.java
return Type.getType("L" + ETUPLE_TYPE.getInternalName() + i
						+ ";");
Type getTubleType(int i)
ETuple ext
src/erjang/beam/ExtFunc.java
super(Kind.EXT_FUNC, ext.elm(3).asInt());
		this.mod = ext.elm(1).testAtom();
		this.fun = ext.elm(2).testAtom();
public ExtFunc(ETuple ext)
EObject src
src/erjang/beam/analysis/BeamTypeAnalysis.java
if (src instanceof ETuple2) {
					ETuple2 tup = (ETuple2) src;
					if (tup.elem1 == ATOM_ATOM) {
						return new Arg(tup.elem2, EATOM_TYPE);
Arg decode_value(EObject src)
tup.elem1 == LITERAL_ATOM
src/erjang/beam/analysis/BeamTypeAnalysis.java
return new Arg(tup.elem2);
else if (tup.elem1 == LITERAL_ATOM)
tup.elem1 == INTEGER_ATOM
src/erjang/beam/analysis/BeamTypeAnalysis.java
if (tup.elem2.testInteger() != null) {
							return new Arg(tup.elem2, Type.INT_TYPE);
else if (tup.elem1 == INTEGER_ATOM)
tup.elem1 == FLOAT_ATOM
src/erjang/beam/analysis/BeamTypeAnalysis.java
return new Arg(tup.elem2, Type.DOUBLE_TYPE);
else if (tup.elem1 == FLOAT_ATOM)
src == NIL_ATOM
src/erjang/beam/analysis/BeamTypeAnalysis.java
return new Arg(ENil.NIL, ENIL_TYPE);
else if (src == NIL_ATOM)
src/erjang/EAtom.java
return "'" + value + "'";
	
	public boolean isAtom(String name)
	{
	
 
	



		
					"intern", "(" + STRING_TYPE.getDescriptor() + ")" + type.getDescriptor());
		
		return type;
EAtom asAtom()
EObject h  ETerm t
src/erjang/ERT.java
if (t instanceof ECons) {
			return ((ECons) t).cons(h);
ETerm cons(EObject h, ETerm t)