if (isTopLevelSpec(spec)) { assert main == null : "Found more than one top-level stream"; main = spec; iter.remove(); } else { result += spec.accept(this); } } assert main != null : "Did not find any top-level stream"; result += main.accept(this); return result;
if (isTopLevelSpec(spec)) { assert main == null : "Found more than one top-level stream"; main = spec; iter.remove(); } else { result += spec.accept(this); }
    public Object visitProgram(Program prog) {		// Nothing special here either. Just accumulate all of the		// structures and streams.		String result = "";		for (Iterator iter = prog.getStructs().iterator(); iter.hasNext();) {			TypeStruct struct = (TypeStruct) iter.next();			if (struct.getName().equals("String"))				continue;			if (libraryFormat && struct.getName().equals("float2"))				continue;			if (libraryFormat && struct.getName().equals("float3"))				continue;			if (libraryFormat && struct.getName().equals("float4"))				continue;			result += indent + "class " + struct.getName()					+ " extends Structure implements Serializable {\n";			addIndent();			for (int i = 0; i < struct.getNumFields(); i++) {				String name = struct.getField(i);				Type type = struct.getType(name);				result += indent + convertType(type) + " " + name + ";\n";			}			unIndent();			result += indent + "}\n";		}		for (Iterator iter = prog.getHelpers().iterator(); iter.hasNext();) {			TypeHelper th = (TypeHelper) iter.next();			result += visitTypeHelper(th);		}		if (!libraryFormat) {			result += indent + "class StreamItVectorLib {\n";			addIndent();			result += indent + "public static native float2 add2(float2 a, float2 b);\n";			result += indent + "public static native float3 add3(float3 a, float3 b);\n";			result += indent + "public static native float4 add4(float4 a, float4 b);\n";			result += indent + "public static native float2 sub2(float2 a, float2 b);\n";			result += indent + "public static native float3 sub3(float3 a, float3 b);\n";			result += indent + "public static native float4 sub4(float4 a, float4 b);\n";			result += indent + "public static native float2 mul2(float2 a, float2 b);\n";			result += indent + "public static native float3 mul3(float3 a, float3 b);\n";			result += indent + "public static native float4 mul4(float4 a, float4 b);\n";			result += indent + "public static native float2 div2(float2 a, float2 b);\n";			result += indent + "public static native float3 div3(float3 a, float3 b);\n";			result += indent + "public static native float4 div4(float4 a, float4 b);\n";			result += indent + "public static native float2 addScalar2(float2 a, float b);\n";			result += indent + "public static native float3 addScalar3(float3 a, float b);\n";			result += indent + "public static native float4 addScalar4(float4 a, float b);\n";			result += indent + "public static native float2 subScalar2(float2 a, float b);\n";			result += indent + "public static native float3 subScalar3(float3 a, float b);\n";			result += indent + "public static native float4 subScalar4(float4 a, float b);\n";			result += indent + "public static native float2 scale2(float2 a, float b);\n";			result += indent + "public static native float3 scale3(float3 a, float b);\n";			result += indent + "public static native float4 scale4(float4 a, float b);\n";			result += indent + "public static native float2 scaleInv2(float2 a, float b);\n";			result += indent + "public static native float3 scaleInv3(float3 a, float b);\n";			result += indent + "public static native float4 scaleInv4(float4 a, float b);\n";			result += indent + "public static native float sqrtDist2(float2 a, float2 b);\n";			result += indent + "public static native float sqrtDist3(float3 a, float3 b);\n";			result += indent + "public static native float sqrtDist4(float4 a, float4 b);\n";			result += indent + "public static native float dot3(float3 a, float3 b);\n";			result += indent + "public static native float3 cross3(float3 a, float3 b);\n";			result += indent + "public static native float2 max2(float2 a, float2 b);\n";			result += indent + "public static native float3 max3(float3 a, float3 b);\n";			result += indent + "public static native float2 min2(float2 a, float2 b);\n";			result += indent + "public static native float3 min3(float3 a, float3 b);\n";			result += indent + "public static native float2 neg2(float2 a);\n";			result += indent + "public static native float3 neg3(float3 a);\n";			result += indent + "public static native float4 neg4(float4 a);\n";			result += indent + "public static native float2 floor2(float2 a);\n";			result += indent + "public static native float3 floor3(float3 a);\n";			result += indent + "public static native float4 floor4(float4 a);\n";			result += indent + "public static native float2 normalize2(float2 a);\n";			result += indent + "public static native float3 normalize3(float3 a);\n";			result += indent + "public static native float4 normalize4(float4 a);\n";			result += indent + "public static native boolean greaterThan3(float3 a, float3 b);\n";			result += indent + "public static native boolean lessThan3(float3 a, float3 b);\n";			result += indent + "public static native boolean equals3(float3 a, float3 b);\n";			unIndent();			result += indent + "}\n";		}		StreamSpec main = null;		for (Iterator iter = prog.getStreams().iterator(); iter.hasNext();) {			StreamSpec spec = ((StreamSpec) iter.next());			if (isTopLevelSpec(spec)) {				assert main == null : "Found more than one top-level stream";				main = spec;				iter.remove();			} else {				result += spec.accept(this);			}		}		assert main != null : "Did not find any top-level stream";		result += main.accept(this);		return result;	}