public class BufferedOutputStream extends OutputStream {
OutputStream o;
-
+ public BufferedOutputStream(OutputStream o) {
+ this.o=o;
+ }
+ public void write(byte []b, int off, int len) {
+ o.write(b, off, len);
+ }
+
+ public void flush() {
+ o.flush();
+ }
+
+ public void close() {
+ o.close();
+ }
}
public class BufferedWriter extends Writer {
Writer out;
+ public BufferedWriter(Writer out) {
+ this.out=out;
+ }
+
public void write(String s) {
out.write(s);
}
out.flush();
}
+ public void close() {
+ out.close();
+ }
+
}
-public class FileOutputStream {
+public class FileOutputStream extends OutputStream {
private int fd;
public FileOutputStream(String pathname) {
fd=nativeOpen(pathname.getBytes());
}
+ public FileOutputStream(String pathname, boolean append) {
+ if(append)
+ fd=nativeAppend(pathname.getBytes());
+ else
+ fd=nativeOpen(pathname.getBytes());
+ }
+
public FileOutputStream(String pathname, int mode) {
if(mode==0)
fd=nativeAppend(pathname.getBytes());
private static native int nativeOpen(byte[] filename);
private static native int nativeAppend(byte[] filename);
- private static native void nativeWrite(int fd, byte[] array);
+ private static native void nativeWrite(int fd, byte[] array, int off, int len);
private static native void nativeClose(int fd);
private static native void nativeFlush(int fd);
}
public void write(byte[] b) {
- nativeWrite(fd, b);
+ nativeWrite(fd, b, 0, b.length);
}
public void flush() {
--- /dev/null
+public class FileWriter extends OutputStreamWriter {
+ public FileWriter(String file, boolean append) {
+ super(new FileOutputStream(file, append));
+ }
+
+}
public void write(byte[] b) {
}
+
+ public void write(byte[] b, int off, int len) {
+ }
+
+ public void flush() {
+ }
+
+ public void close() {
+ }
}
--- /dev/null
+public class OutputStreamWriter extends Writer {
+ OutputStream fos;
+ public OutputStreamWriter(OutputStream fos) {
+ this.fos=fos;
+ }
+
+
+
+
+}
-public class SocketInputStream {
+public class SocketInputStream extends InputStream {
Socket s;
public SocketInputStream(Socket s) {
this.s=s;
public class Socket {
/* File Descriptor */
int fd;
-
+ SocketInputStream sin;
+ SocketOutputStream sout;
+
public Socket() {
+ sin=new SocketInputStream(this);
+ sout=new SocketOutputStream(this);
+ }
+
+ public InputStream getInputStream() {
+ return sin;
+ }
+
+ public OutputStream getOutputStream() {
+ return sout;
}
public Socket(String host, int port) {
--- /dev/null
+public class SocketOutputStream extends OutputStream {
+ Socket s;
+ public SocketOutputStream(Socket s) {
+ this.s=s;
+ }
+
+
+}
return new String(chararray);
}
+ public static String valueOf(long x) {
+ int length=0;
+ long tmp;
+ if (x<0)
+ tmp=-x;
+ else
+ tmp=x;
+ do {
+ tmp=tmp/10;
+ length=length+1;
+ } while(tmp!=0);
+
+ char chararray[];
+ if (x<0)
+ chararray=new char[length+1];
+ else
+ chararray=new char[length];
+ int voffset;
+ if (x<0) {
+ chararray[0]='-';
+ voffset=1;
+ x=-x;
+ } else
+ voffset=0;
+
+ do {
+ chararray[--length+voffset]=(char)(x%10+'0');
+ x=x/10;
+ } while (length!=0);
+ return new String(chararray);
+ }
+
public int hashCode() {
if (cachedHashcode!=0)
return cachedHashcode;
public static void error() {
System.printString("Error (Use Breakpoint on ___System______error method for more information!)\n");
}
+
+ public static native void exit(int status);
}
public class Writer {
-
public void write(String s) {
}
public void flush() {
}
+
+ public void close() {
+ }
}
}
private void generateFlatReturnNode(FlatMethod fm, LocalityBinding lb, FlatReturnNode frn, PrintWriter output) {
- if (frn.getReturnTemp()!=null)
- output.println("return "+generateTemp(fm, frn.getReturnTemp(), lb)+";");
- else
+ if (frn.getReturnTemp()!=null) {
+ if (frn.getReturnTemp().getType().isPtr())
+ output.println("return (struct "+fm.getMethod().getReturnType().getSafeSymbol()+"*)"+generateTemp(fm, frn.getReturnTemp(), lb)+";");
+ else
+ output.println("return "+generateTemp(fm, frn.getReturnTemp(), lb)+";");
+ } else
output.println("return;");
}
readSourceFile(state, ClassLibraryPrefix+"FileOutputStream.java");
readSourceFile(state, ClassLibraryPrefix+"File.java");
readSourceFile(state, ClassLibraryPrefix+"InetAddress.java");
-
+ readSourceFile(state, ClassLibraryPrefix+"SocketInputStream.java");
+ readSourceFile(state, ClassLibraryPrefix+"SocketOutputStream.java");
if (state.TASK) {
#include "mem.h"
#include "runtime.h"
-void CALL12(___FileOutputStream______nativeWrite____I__AR_B, int fd, int fd, struct ArrayObject * ___array___) {
- int length=VAR(___array___)->___length___;
+void CALL34(___FileOutputStream______nativeWrite____I__AR_B_I_I, int fd, int off, int len, int fd, struct ArrayObject * ___array___, int off, int len) {
char * string= (((char *)& VAR(___array___)->___length___)+sizeof(int));
- int status=write(fd, string, length);
+ int status=write(fd, &string[off], len);
}
void CALL11(___FileOutputStream______nativeClose____I, int fd, int fd) {
#endif
}
+void CALL11(___System______exit____I,int ___status___, int ___status___) {
+ exit(___status___);
+}
+
void CALL01(___System______printString____L___String___,struct ___String___ * ___s___) {
struct ArrayObject * chararray=VAR(___s___)->___value___;
int i;
#define CALL12(name,rest, alt1, alt2) name(struct name ## _params * ___params___, rest)
#define CALL23(name, rest, rest2, alt1, alt2, alt3) name(struct name ## _params * ___params___, rest, rest2)
#define CALL24(name, rest, rest2, alt1, alt2, alt3, alt4) name(struct name ## _params * ___params___, rest, rest2)
+#define CALL34(name, rest, rest2, rest3, alt1, alt2, alt3, alt4) name(struct name ## _params * ___params___, rest, rest2, rest3)
#else
#define VAR(name) name
#define CALL00(name) name()
#define CALL12(name,rest, alt1, alt2) name(alt1, alt2)
#define CALL23(name, rest, rest2, alt1, alt2, alt3) name(alt1, alt2, alt3)
#define CALL24(name, rest, rest2, alt1, alt2, alt3, alt4) name(alt1, alt2, alt3, alt4)
+#define CALL34(name, rest, rest2, rest3, alt1, alt2, alt3, alt4) name(alt1, alt2, alt3, alt4)
#endif
#ifdef TASK