package ceylon.language;

import java.io.IOException;

import com.redhat.ceylon.compiler.metadata.java.Ceylon;
import com.redhat.ceylon.compiler.metadata.java.Name;
import com.redhat.ceylon.compiler.metadata.java.TypeInfo;

@Ceylon @com.redhat.ceylon.compiler.metadata.java.Object
public class process extends Object {
	
    @SuppressWarnings("unchecked")
    private Iterable<? extends String> args = $empty.getEmpty();
    
    @TypeInfo("ceylon.language.Empty|ceylon.language.Sequence<ceylon.language.String>")
    public Iterable<? extends String> getArguments() {
        return args;
    }
    
    public void setupArguments(java.lang.String[] args) {
        String[] newArgs = new String[args.length];
        for (int i = 0; i < args.length; i++) {
            newArgs[i] = String.instance(args[i]);
        }
        this.args = new ArraySequence<String>(newArgs);
    }
    
//    shared Entries<String,String> switches { throw; }

//    shared Entries<String,String> properties { throw; }

    public void writeLine(@Name("line") @TypeInfo("ceylon.language.String") java.lang.String s) {
        java.lang.System.out.println(s);
    }
    
    public void write(@Name("string") @TypeInfo("ceylon.language.String") java.lang.String s) {
        java.lang.System.out.print(s);
    }
    
    @TypeInfo("ceylon.language.String") 
    public java.lang.String readLine() {
        try {
            return new java.io.BufferedReader( 
                    new java.io.InputStreamReader(java.lang.System.in))
                .readLine();
        } 
        catch (IOException e) {
            throw new Exception(
                    String.instance("could not read line from standard input"), 
                            e);
        }
    }
    
    public long getMilliseconds() {
    	return System.currentTimeMillis();
    }
    
    @Override
    public java.lang.String toString() {
    	return "process";
    }
    
    private process() {}
    private static final process value = new process();
    
    public static process getProcess() {
        return value;
    }
}

@@ -648,24 +648,51 @@
 g%5B%5D args) %7B%0A
+    %09if (args.length%3E0) %7B%0A%09
         Stri
@@ -731,16 +731,17 @@
 ength%5D;%0A
+%09
         
@@ -776,24 +776,25 @@
 gth; i++) %7B%0A
+%09
             
@@ -832,16 +832,17 @@
 gs%5Bi%5D);%0A
+%09
         
@@ -839,24 +839,25 @@
 %0A%09        %7D%0A
+%09
         this
@@ -896,24 +896,31 @@
 %3E(newArgs);%0A
+    %09%7D%0A
     %7D%0A    %0A/

fix case where there are no args