Check-in [e77018c3ea]

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Add configuration ROM to RatufaCoat; Correct potential memory leak in RatufaCoat; Implement Java instruction write types in RatufaCoat
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: e77018c3eaf4037377542b8b5d04ff62b7e52e28
User & Date: stephanie.gawroriski 2019-06-14 15:37:53
Context
2019-06-14
18:18
Remove note strings in the bootstrap. check-in: 48adcac4bf user: stephanie.gawroriski tags: trunk
15:37
Add configuration ROM to RatufaCoat; Correct potential memory leak in RatufaCoat; Implement Java instruction write types in RatufaCoat check-in: e77018c3ea user: stephanie.gawroriski tags: trunk
15:01
Write of SummerCoat's config ROM area. check-in: 895f1a5e6b user: stephanie.gawroriski tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to ratufacoat/sjmerc.c.

    17     17   /** Default RAM size. */
    18     18   #if defined(SJME_IS_DOS)
    19     19   	#define SJME_DEFAULT_RAM_SIZE SJME_JINT_C(65536)
    20     20   #else
    21     21   	#define SJME_DEFAULT_RAM_SIZE SJME_JINT_C(16777216)
    22     22   #endif
    23     23   
           24  +/** Default size of configuration ROM. */
           25  +#define SJME_DEFAULT_CONF_SIZE SJME_JINT_C(65536)
           26  +
    24     27   /** Magic number for ROMs. */
    25     28   #define SJME_ROM_MAGIC_NUMBER SJME_JINT_C(0x58455223)
    26     29   
    27     30   /** Magic number for JARs. */
    28     31   #define SJME_JAR_MAGIC_NUMBER SJME_JINT_C(0x00456570)
    29     32   
    30     33   /** Check magic for BootRAM. */
    31     34   #define SJME_BOOTRAM_CHECK_MAGIC SJME_JINT_C(0xFFFFFFFF)
    32     35   
           36  +/** End of configuration. */
           37  +#define SJME_CONFIG_END SJME_JINT_C(0)
           38  +
           39  +/** Java VM Version. */
           40  +#define SJME_CONFIG_JAVA_VM_VERSION SJME_JINT_C(1)
           41  +
           42  +/** Java VM Name. */
           43  +#define SJME_CONFIG_JAVA_VM_NAME SJME_JINT_C(2)
           44  +
           45  +/** Java VM Vendor. */
           46  +#define SJME_CONFIG_JAVA_VM_VENDOR SJME_JINT_C(3)
           47  +
           48  +/** Java VM E-Mail. */
           49  +#define SJME_CONFIG_JAVA_VM_EMAIL SJME_JINT_C(4)
           50  +
           51  +/** Java VM URL. */
           52  +#define SJME_CONFIG_JAVA_VM_URL SJME_JINT_C(5)
           53  +
           54  +/** The guest depth. */
           55  +#define SJME_CONFIG_GUEST_DEPTH SJME_JINT_C(6)
           56  +
           57  +/** Main class. */
           58  +#define SJME_CONFIG_MAIN_CLASS SJME_JINT_C(7)
           59  +
           60  +/** Main program arguments. */
           61  +#define SJME_CONFIG_MAIN_ARGUMENTS SJME_JINT_C(8)
           62  +
           63  +/** Is this a MIDlet? */
           64  +#define SJME_CONFIG_IS_MIDLET SJME_JINT_C(9)
           65  +
           66  +/** Define system propertly. */
           67  +#define SJME_CONFIG_DEFINE_PROPERTY SJME_JINT_C(10)
           68  +
           69  +/** Classpath to use. */
           70  +#define SJME_CONFIG_CLASS_PATH SJME_JINT_C(11)
           71  +
           72  +/** Number of available options. */
           73  +#define SJME_CONFIG_NUM_OPTIONS SJME_JINT_C(12)
           74  +
    33     75   /** Maximum CPU registers. */
    34     76   #define SJME_MAX_REGISTERS SJME_JINT_C(64)
    35     77   
    36     78   /** Maximum system call arguments. */
    37     79   #define SJME_MAX_SYSCALLARGS SJME_JINT_C(8)
    38     80   
    39     81   /** The zero register. */
................................................................................
   458    500   	
   459    501   	/** ROM. */
   460    502   	void* rom;
   461    503   	
   462    504   	/** The size of ROM. */
   463    505   	sjme_jint romsize;
   464    506   	
          507  +	/** Configuration ROM. */
          508  +	void* config;
          509  +	
          510  +	/** Size of of the configuration ROM. */
          511  +	sjme_jint configsize;
          512  +	
   465    513   	/** Preset ROM. */
   466    514   	void* presetrom;
   467    515   	
   468    516   	/* Native functions. */
   469    517   	sjme_nativefuncs* nativefuncs;
   470    518   	
   471    519   	/** Linearly fair CPU execution engine. */
................................................................................
   717    765   				((rv >> SJME_JINT_C(8)) & SJME_JINT_C(0x0000FF00)) |
   718    766   				((rv << SJME_JINT_C(8)) & SJME_JINT_C(0x00FF0000)) |
   719    767   				((rv << SJME_JINT_C(24)) & SJME_JINT_C(0xFF000000)));
   720    768   #endif
   721    769   			return rv;
   722    770   	}
   723    771   }
          772  +
          773  +/**
          774  + * Writes a Java value to memory.
          775  + *
          776  + * @param jvm JVM pointer.
          777  + * @param size The size of the value to write.
          778  + * @param ptr The pointer to read to.
          779  + * @param off The offset.
          780  + * @param value The value to write.
          781  + * @since 2019/06/14
          782  + */
          783  +void sjme_memjwrite(sjme_jvm* jvm, sjme_jint size, void* ptr, sjme_jint off,
          784  +	sjme_jint value)
          785  +{
          786  +	/* Get the true pointer. */
          787  +	ptr = SJME_POINTER_OFFSET(ptr, off);
          788  +	
          789  +	/* Check against JVM areas. */
          790  +	if (jvm != NULL)
          791  +	{
          792  +		/* Ignore writes to ROM. */
          793  +		if (ptr >= jvm->rom &&
          794  +			ptr < SJME_POINTER_OFFSET(jvm->rom, jvm->romsize))
          795  +			return;
          796  +	}
          797  +	
          798  +	/* Write value to memory. */
          799  +	switch (size)
          800  +	{
          801  +			/* Byte */
          802  +		case 1:
          803  +			*((sjme_jbyte*)ptr) = (sjme_jbyte)value;
          804  +			break;
          805  +		
          806  +			/* Short */
          807  +		case 2:
          808  +#if defined(SJME_LITTLE_ENDIAN)
          809  +			value = (value & SJME_JINT_C(0xFFFF0000)) |
          810  +				(((value << SJME_JINT_C(8)) & SJME_JINT_C(0xFF00)) |
          811  +				((value >> SJME_JINT_C(8)) & SJME_JINT_C(0x00FF)));
          812  +#endif
          813  +			*((sjme_jshort*)ptr) = (sjme_jshort)value;
          814  +			break;
          815  +			
          816  +			/* Integer */
          817  +		case 4:
          818  +		default:
          819  +#if defined(SJME_LITTLE_ENDIAN)
          820  +			value = (((value >> SJME_JINT_C(24)) & SJME_JINT_C(0x000000FF)) |
          821  +				((value >> SJME_JINT_C(8)) & SJME_JINT_C(0x0000FF00)) |
          822  +				((value << SJME_JINT_C(8)) & SJME_JINT_C(0x00FF0000)) |
          823  +				((value << SJME_JINT_C(24)) & SJME_JINT_C(0xFF000000)));
          824  +#endif
          825  +			*((sjme_jint*)ptr) = value;
          826  +			break;
          827  +	}
          828  +}
   724    829   
   725    830   /**
   726    831    * Read Java value from memory and increment pointer.
   727    832    *
          833  + * @param jvm The JVM.
   728    834    * @param size The size of value to read.
   729    835    * @param ptr The pointer to read from.
   730    836    * @return The resulting value.
   731    837    * @since 2019/06/08
   732    838    */
   733    839   sjme_jint sjme_memjreadp(sjme_jvm* jvm, sjme_jint size, void** ptr)
   734    840   {
................................................................................
   739    845   	
   740    846   	/* Increment pointer. */
   741    847   	*ptr = SJME_POINTER_OFFSET(*ptr, size);
   742    848   	
   743    849   	/* Return result. */
   744    850   	return rv;
   745    851   }
          852  +
          853  +/**
          854  + * Write Java value to memory and increment pointer.
          855  + *
          856  + * @param jvm The JVM.
          857  + * @param size The size of value to write.
          858  + * @param ptr The pointer to read from.
          859  + * @param value The value to write.
          860  + * @since 2019/06/14
          861  + */
          862  +void sjme_memjwritep(sjme_jvm* jvm, sjme_jint size, void** ptr,
          863  +	sjme_jint value)
          864  +{
          865  +	/* Write pointer value. */
          866  +	sjme_memjwrite(jvm, size, *ptr, 0, value);
          867  +	
          868  +	/* Increment pointer. */
          869  +	*ptr = SJME_POINTER_OFFSET(*ptr, size);
          870  +}
   746    871   
   747    872   /**
   748    873    * Decodes a variable unsigned int operation argument.
   749    874    *
   750    875    * @param ptr The pointer to read from.
   751    876    * @return The resulting decoded value.
   752    877    * @since 2019/06/09
................................................................................
  1275   1400   								break;
  1276   1401   						}
  1277   1402   					}
  1278   1403   					
  1279   1404   					/* Store value */
  1280   1405   					else
  1281   1406   					{
  1282         -						if (error != NULL)
  1283         -							*error = SJME_ERROR_NOJAVAWRITE;
  1284         -						
  1285         -						return cycles;
         1407  +						switch (op & SJME_MEM_DATATYPE_MASK)
         1408  +						{	
         1409  +							case SJME_DATATYPE_BYTE:
         1410  +								sjme_memjwrite(jvm, 1, tempp, ib, r[ic]);
         1411  +								break;
         1412  +								
         1413  +							case SJME_DATATYPE_CHARACTER:
         1414  +							case SJME_DATATYPE_SHORT:
         1415  +								sjme_memjwrite(jvm, 2, tempp, ib, r[ic]);
         1416  +								break;
         1417  +								
         1418  +							case SJME_DATATYPE_OBJECT:
         1419  +							case SJME_DATATYPE_INTEGER:
         1420  +							case SJME_DATATYPE_FLOAT:
         1421  +							default:
         1422  +								sjme_memjwrite(jvm, 4, tempp, ib, r[ic]);
         1423  +								break;
         1424  +						}
  1286   1425   					}
  1287   1426   				}
  1288   1427   				break;
  1289   1428   				
  1290   1429   				/* Atomic decrement and get. */
  1291   1430   			case SJME_OP_ATOMIC_INT_DECREMENT_AND_GET:
  1292   1431   				{
................................................................................
  1825   1964   	/* Bootstrap entry arguments. */
  1826   1965   	/* (int __rambase, int __ramsize, int __rombase, int __romsize, */
  1827   1966   	/* int __confbase, int __confsize) */
  1828   1967   	cpu->r[SJME_ARGBASE_REGISTER + 0] = SJME_POINTER_TO_JINT(ram);
  1829   1968   	cpu->r[SJME_ARGBASE_REGISTER + 1] = ramsize;
  1830   1969   	cpu->r[SJME_ARGBASE_REGISTER + 2] = SJME_POINTER_TO_JINT(rom);
  1831   1970   	cpu->r[SJME_ARGBASE_REGISTER + 3] = jvm->romsize;
  1832         -	cpu->r[SJME_ARGBASE_REGISTER + 4] = 0;
  1833         -	cpu->r[SJME_ARGBASE_REGISTER + 5] = 0;
  1834         -	
         1971  +	cpu->r[SJME_ARGBASE_REGISTER + 4] = SJME_POINTER_TO_JINT(jvm->config);
         1972  +	cpu->r[SJME_ARGBASE_REGISTER + 5] = jvm->configsize;
  1835   1973   	
  1836   1974   	/* Address where the BootRAM is read from. */
  1837   1975   	rp = SJME_POINTER_OFFSET(bootjar, bootoff);
  1838   1976   	
  1839   1977   	/* Copy initial base memory bytes, which is pure big endian. */
  1840   1978   	byteram = (sjme_jbyte*)ram;
  1841   1979   	n = sjme_memjreadp(jvm, 4, &rp);
................................................................................
  1949   2087   			/* Free CPU state. */
  1950   2088   			sjme_free(oldcpu);
  1951   2089   		}
  1952   2090   	}
  1953   2091   	
  1954   2092   	/* Delete major JVM data areas. */
  1955   2093   	sjme_free(jvm->ram);
         2094  +	sjme_free(jvm->config);
  1956   2095   	if (jvm->presetrom == NULL)
  1957   2096   		sjme_free(jvm->rom);
  1958   2097   	
  1959   2098   	/* Destroyed okay. */
  1960   2099   	return 1;
  1961   2100   }
         2101  +
         2102  +/** Initializes the configuration space. */
         2103  +void sjme_configinit(void* conf, sjme_jint confsize, sjme_jvm* jvm,
         2104  +	sjme_jvmoptions* options, sjme_nativefuncs* nativefuncs, sjme_jint* error)
         2105  +{
         2106  +#define SJME_CONFIG_FORMAT_INTEGER SJME_JINT_C(1)
         2107  +#define SJME_CONFIG_FORMAT_KEYVALUE SJME_JINT_C(2)
         2108  +#define SJME_CONFIG_FORMAT_STRING SJME_JINT_C(3)
         2109  +#define SJME_CONFIG_FORMAT_STRINGS SJME_JINT_C(4)
         2110  +	void* wp;
         2111  +	void* basep;
         2112  +	void* sizep;
         2113  +	sjme_jint opt, format, iv, it;
         2114  +	char* sa;
         2115  +	char* sb;
         2116  +	
         2117  +	/* Write pointer starts at the base area. */
         2118  +	wp = conf;
         2119  +	
         2120  +	/* Go through all possible options to make a value. */
         2121  +	for (opt = SJME_JINT_C(1); opt < SJME_CONFIG_NUM_OPTIONS; opt++)
         2122  +	{
         2123  +		/* Used to specify the format. */
         2124  +		format = 0;
         2125  +		
         2126  +		/* Reset. */
         2127  +		sa = NULL;
         2128  +		sb = NULL;
         2129  +		iv = 0;
         2130  +		
         2131  +		/* Depends on the option. */
         2132  +		switch (opt)
         2133  +		{
         2134  +			/* Java VM Version. */
         2135  +			case SJME_CONFIG_JAVA_VM_VERSION:
         2136  +				format = SJME_CONFIG_FORMAT_STRING;
         2137  +				sa = "0.3.0";
         2138  +				break;
         2139  +			
         2140  +			/* Java VM Name. */
         2141  +			case SJME_CONFIG_JAVA_VM_NAME:
         2142  +				format = SJME_CONFIG_FORMAT_STRING;
         2143  +				sa = "SquirrelJME RatufaCoat";
         2144  +				break;
         2145  +			
         2146  +			/* Java VM Vendor. */
         2147  +			case SJME_CONFIG_JAVA_VM_VENDOR:
         2148  +				format = SJME_CONFIG_FORMAT_STRING;
         2149  +				sa = "Stephanie Gawroriski";
         2150  +				break;
         2151  +			
         2152  +			/* Java VM E-Mail. */
         2153  +			case SJME_CONFIG_JAVA_VM_EMAIL:
         2154  +				format = SJME_CONFIG_FORMAT_STRING;
         2155  +				sa = "xerthesquirrel@gmail.com";
         2156  +				break;
         2157  +			
         2158  +			/* Java VM URL. */
         2159  +			case SJME_CONFIG_JAVA_VM_URL:
         2160  +				format = SJME_CONFIG_FORMAT_STRING;
         2161  +				sa = "https://squirreljme.cc/";
         2162  +				break;
         2163  +			
         2164  +			/* The guest depth. */
         2165  +			case SJME_CONFIG_GUEST_DEPTH:
         2166  +				break;
         2167  +			
         2168  +			/* Main class. */
         2169  +			case SJME_CONFIG_MAIN_CLASS:
         2170  +				break;
         2171  +			
         2172  +			/* Main program arguments. */
         2173  +			case SJME_CONFIG_MAIN_ARGUMENTS:
         2174  +				break;
         2175  +			
         2176  +			/* Is this a MIDlet? */
         2177  +			case SJME_CONFIG_IS_MIDLET:
         2178  +				break;
         2179  +			
         2180  +			/* Define system propertly. */
         2181  +			case SJME_CONFIG_DEFINE_PROPERTY:
         2182  +				break;
         2183  +			
         2184  +			/* Classpath to use. */
         2185  +			case SJME_CONFIG_CLASS_PATH:
         2186  +				break;
         2187  +			
         2188  +				/* Unknown, ignore. */
         2189  +			default:
         2190  +				continue;
         2191  +		}
         2192  +		
         2193  +		/* No known way to write this? */
         2194  +		if (format == 0)
         2195  +			continue;
         2196  +		
         2197  +		/* Write option key. */
         2198  +		sjme_memjwritep(jvm, 2, &wp, opt);
         2199  +		
         2200  +		/* Store size location for later write. */
         2201  +		sizep = wp;
         2202  +		sjme_memjwritep(jvm, 2, &wp, 0);
         2203  +		
         2204  +		/* Base write pointer. */
         2205  +		basep = wp;
         2206  +		
         2207  +		/* Depends on the format. */
         2208  +		switch (format)
         2209  +		{
         2210  +				/* Integer. */
         2211  +			case SJME_CONFIG_FORMAT_INTEGER:
         2212  +				sjme_memjwritep(jvm, 4, &wp, iv);
         2213  +				break;
         2214  +			
         2215  +				/* Key/value pair. */
         2216  +			case SJME_CONFIG_FORMAT_KEYVALUE:
         2217  +				break;
         2218  +			
         2219  +				/* String value. */
         2220  +			case SJME_CONFIG_FORMAT_STRING:
         2221  +				{
         2222  +					// Record string length
         2223  +					int iv = strlen(sa);
         2224  +					sjme_memjwritep(jvm, 2, &wp, iv);
         2225  +					
         2226  +					// Record characters
         2227  +					for (it = 0; it < iv; it++)
         2228  +						sjme_memjwritep(jvm, 1, &wp, (sjme_jint)sa[it]);
         2229  +				}
         2230  +				break;
         2231  +			
         2232  +				/* Multiple strings. */
         2233  +			case SJME_CONFIG_FORMAT_STRINGS:
         2234  +				break;
         2235  +		}
         2236  +		
         2237  +		/* Write to the actual size! */
         2238  +		sjme_memjwrite(jvm, 2, sizep, 0,
         2239  +			SJME_POINTER_TO_JINT(wp) - SJME_POINTER_TO_JINT(basep));
         2240  +	}
         2241  +	
         2242  +	/* Write end of config. */
         2243  +	sjme_memjwritep(jvm, 2, &wp, SJME_CONFIG_END);
         2244  +	
         2245  +#undef SJME_CONFIG_FORMAT_INTEGER
         2246  +#undef SJME_CONFIG_FORMAT_KEYVALUE
         2247  +#undef SJME_CONFIG_FORMAT_STRING
         2248  +#undef SJME_CONFIG_FORMAT_STRINGS
         2249  +}
  1962   2250   
  1963   2251   /** Creates a new instance of the JVM. */
  1964   2252   sjme_jvm* sjme_jvmnew(sjme_jvmoptions* options, sjme_nativefuncs* nativefuncs,
  1965   2253   	sjme_jint* error)
  1966   2254   {
  1967   2255   	sjme_jvmoptions nulloptions;
  1968   2256   	void* ram;
  1969   2257   	void* rom;
         2258  +	void* conf;
  1970   2259   	sjme_jvm* rv;
  1971   2260   	sjme_jint i, l, romsize;
  1972   2261   	
  1973   2262   	/* We need native functions. */
  1974   2263   	if (nativefuncs == NULL)
  1975   2264   		return NULL;
  1976   2265   	
  1977   2266   	/* Allocate VM state. */
  1978   2267   	rv = sjme_malloc(sizeof(*rv));
  1979         -	if (rv == NULL)
         2268  +	conf = sjme_malloc(SJME_DEFAULT_CONF_SIZE);
         2269  +	if (rv == NULL || conf == NULL)
  1980   2270   	{
  1981   2271   		if (error != NULL)
  1982   2272   			*error = SJME_ERROR_NOMEMORY;
  1983   2273   		
         2274  +		sjme_free(rv);
         2275  +		sjme_free(conf);
         2276  +		
  1984   2277   		return NULL;
  1985   2278   	}
  1986   2279   	
  1987   2280   	/* If there were no options specified, just use a null set. */
  1988   2281   	if (options == NULL)
  1989   2282   	{
  1990   2283   		memset(&nulloptions, 0, sizeof(nulloptions));
................................................................................
  1997   2290   	
  1998   2291   	/* Allocate RAM. */
  1999   2292   	ram = sjme_malloc(options->ramsize);
  2000   2293   	if (ram == NULL)
  2001   2294   	{
  2002   2295   		if (error != NULL)
  2003   2296   			*error = SJME_ERROR_NOMEMORY;
         2297  +			
         2298  +		sjme_free(rv);
         2299  +		sjme_free(conf);
  2004   2300   		
  2005   2301   		return NULL;
  2006   2302   	}
  2007   2303   	
  2008   2304   	/* Needed by the VM. */
  2009   2305   	rv->ram = ram;
  2010   2306   	rv->ramsize = options->ramsize;
................................................................................
  2021   2317   		rom = sjme_loadrom(nativefuncs, &romsize, error);
  2022   2318   		
  2023   2319   		/* Could not load the ROM? */
  2024   2320   		if (rom == NULL)
  2025   2321   		{
  2026   2322   			sjme_free(rv);
  2027   2323   			sjme_free(ram);
         2324  +			sjme_free(conf);
         2325  +			
  2028   2326   			return NULL;
  2029   2327   		}
  2030   2328   	}
  2031   2329   	
  2032   2330   	/* If we are copying from the preset ROM, duplicate it. */
  2033   2331   	if (options->presetrom != NULL && options->copyrom != 0)
  2034   2332   	{
................................................................................
  2039   2337   		rom = sjme_malloc(options->romsize);
  2040   2338   		if (rom == NULL)
  2041   2339   		{
  2042   2340   			if (error != NULL)
  2043   2341   				*error = SJME_ERROR_NOMEMORY;
  2044   2342   			
  2045   2343   			sjme_free(ram);
         2344  +			sjme_free(conf);
         2345  +			
  2046   2346   			return NULL;
  2047   2347   		}
  2048   2348   		
  2049   2349   		/* Copy large chunks at a time. */
  2050   2350   		for (i = 0; i < options->romsize;)
  2051   2351   		{
  2052   2352   			/* Byte left to move? */
................................................................................
  2073   2373   	rv->romsize = romsize;
  2074   2374   	
  2075   2375   	/* Initialize the BootRAM and boot the CPU. */
  2076   2376   	if (sjme_initboot(rom, ram, options->ramsize, rv, error) == 0)
  2077   2377   	{
  2078   2378   		sjme_free(rv);
  2079   2379   		sjme_free(ram);
         2380  +		sjme_free(conf);
  2080   2381   		
  2081   2382   		/* If a pre-set ROM is not being used, make sure it gets cleared. */
  2082   2383   		if (options->presetrom)
  2083   2384   			sjme_free(rom);
  2084   2385   		
  2085   2386   		return NULL;
  2086   2387   	}
         2388  +	
         2389  +	/* Initialize configuration space. */
         2390  +	rv->config = conf;
         2391  +	rv->configsize = SJME_DEFAULT_CONF_SIZE;
         2392  +	sjme_configinit(conf, SJME_DEFAULT_CONF_SIZE, rv, options, nativefuncs,
         2393  +		error);
  2087   2394   	
  2088   2395   	/* The JVM is ready to use. */
  2089   2396   	return rv;
  2090   2397   }

Changes to runt/apis/cldc-compact/cc/squirreljme/jvm/ConfigRomType.java.

    59     59   	/** Define system propertly. */
    60     60   	public static final short DEFINE_PROPERTY =
    61     61   		10;
    62     62   	
    63     63   	/** Classpath to use. */
    64     64   	public static final short CLASS_PATH =
    65     65   		11;
           66  +	
           67  +	/** Number of available options. */
           68  +	public static final short NUM_OPTIONS =
           69  +		12;
    66     70   }
    67     71   

Changes to runt/libs/summercoat-vm/cc/squirreljme/vm/summercoat/ConfigRomWriter.java.

    53     53   			throw new IOException("AE0e " + len);
    54     54   		
    55     55   		// Key, value, and the data
    56     56   		__dos.writeShort(__opt);
    57     57   		__dos.writeShort(len);
    58     58   		__dos.write(__b, 0, len);
    59     59   	}
           60  +	
           61  +	/**
           62  +	 * Writes the specified integer.
           63  +	 *
           64  +	 * @param __dos The output stream.
           65  +	 * @param __opt The option to write.
           66  +	 * @param __v The value to write.
           67  +	 * @throws IOException On write errors.
           68  +	 * @throws NullPointerException On null arguments.
           69  +	 * @since 2019/06/14
           70  +	 */
           71  +	public static final void writeInteger(DataOutputStream __dos, int __opt,
           72  +		int __v)
           73  +		throws IOException, NullPointerException
           74  +	{
           75  +		if (__dos == null)
           76  +			throw new NullPointerException("NARG");
           77  +		
           78  +		// Write data area
           79  +		try (ByteArrayOutputStream baos = new ByteArrayOutputStream();
           80  +			DataOutputStream xdos = new DataOutputStream(baos))
           81  +		{
           82  +			xdos.writeInt(__v);
           83  +			
           84  +			// Write in
           85  +			ConfigRomWriter.writeData(__dos, __opt, baos.toByteArray());
           86  +		}
           87  +	}
    60     88   	
    61     89   	/**
    62     90   	 * Writes key/value.
    63     91   	 *
    64     92   	 * @param __dos The output stream.
    65     93   	 * @param __opt The option to write.
    66     94   	 * @param __k The key.
................................................................................
    79    107   		// Write data area
    80    108   		try (ByteArrayOutputStream baos = new ByteArrayOutputStream();
    81    109   			DataOutputStream xdos = new DataOutputStream(baos))
    82    110   		{
    83    111   			xdos.writeUTF(__k);
    84    112   			xdos.writeUTF(__v);
    85    113   			
    86         -			// Write in
    87         -			ConfigRomWriter.writeData(__dos, __opt, baos.toByteArray());
    88         -		}
    89         -	}
    90         -	
    91         -	/**
    92         -	 * Writes the specified integer.
    93         -	 *
    94         -	 * @param __dos The output stream.
    95         -	 * @param __opt The option to write.
    96         -	 * @param __v The value to write.
    97         -	 * @throws IOException On write errors.
    98         -	 * @throws NullPointerException On null arguments.
    99         -	 * @since 2019/06/14
   100         -	 */
   101         -	public static final void writeInteger(DataOutputStream __dos, int __opt,
   102         -		int __v)
   103         -		throws IOException, NullPointerException
   104         -	{
   105         -		if (__dos == null)
   106         -			throw new NullPointerException("NARG");
   107         -		
   108         -		// Write data area
   109         -		try (ByteArrayOutputStream baos = new ByteArrayOutputStream();
   110         -			DataOutputStream xdos = new DataOutputStream(baos))
   111         -		{
   112         -			xdos.writeInt(__v);
   113         -			
   114    114   			// Write in
   115    115   			ConfigRomWriter.writeData(__dos, __opt, baos.toByteArray());
   116    116   		}
   117    117   	}
   118    118   	
   119    119   	/**
   120    120   	 * Writes the specified string.

Changes to runt/libs/summercoat-vm/cc/squirreljme/vm/summercoat/SummerCoatFactory.java.

   214    214   						ConfigRomType.DEFINE_PROPERTY,
   215    215   						e.getKey(), e.getValue());
   216    216   				}
   217    217   			
   218    218   			// Class path
   219    219   			ConfigRomWriter.writeStrings(dos, ConfigRomType.CLASS_PATH,
   220    220   				SummerCoatFactory.classPathToStringArray(__cp));
          221  +			
          222  +			// End
          223  +			dos.writeShort(ConfigRomType.END);
   221    224   		}
   222    225   		
   223    226   		// {@squirreljme.error AE0d Could not write to configuration ROM.}
   224    227   		catch (IOException e)
   225    228   		{
   226    229   			throw new VMException("AE0d", e);
   227    230   		}