changes for reading input files
authorjzhou <jzhou>
Wed, 9 May 2012 04:05:09 +0000 (04:05 +0000)
committerjzhou <jzhou>
Wed, 9 May 2012 04:05:09 +0000 (04:05 +0000)
Robust/src/ClassLibrary/MGC/Scanner.java
Robust/src/Runtime/bamboo/multicoreruntime.c

index 9b595ae1e59dc392dccb5ad749aeedad754794fa..31b4567e77b2d0a06eabac317961214eb7150c89 100644 (file)
@@ -1,14 +1,22 @@
 public class Scanner implements Iterator {\r
   private String sourcename;\r
+  private int currentpos;\r
 \r
   public Scanner (final String source) {\r
     this.sourcename = source;\r
+    this.currentpos = 0;\r
   }\r
 \r
   public void close () {\r
   }\r
 \r
-  public native double nextDouble ();\r
+  public double nextDouble () {\r
+      return Double.parseDouble(new String(next()));\r
+  }\r
 \r
-  public native int nextInt ();\r
-}
\ No newline at end of file
+  public int nextInt () {\r
+      return Integer.parseInt(new String(next()));\r
+  }\r
+  \r
+  private native char[] next();\r
+}\r
index 306392cd57bab4d19cc40313953db78e3062e651..57c971af4d1506f33e9b5ee0514499d70791ec4d 100644 (file)
@@ -349,7 +349,7 @@ long long ___System______numGCs____(struct ___System______numGCs_____params * __
 #endif
 
 #ifdef D___System______milliGcTime____
-long long ___System______milliGcTime____(struct ___System______milliGcTime_____params * ___params___) {
+long long CALL00(___System______milliGcTime____) {
 #ifdef MULTICORE_GC
   return GCtime/700000;
 #else
@@ -429,17 +429,23 @@ void CALL01(___System______printString____L___String___, struct ___String___ * _
 }
 #endif
 
-#ifdef D___Scanner______nextDouble____ 
-double ___Scanner______nextDouble____(struct ___Scanner______nextDouble_____params * ___params___) {
-  // TODO
-  return 0;
-}
+#ifdef D___Scanner______next____ 
+struct ArrayObject * CALL01(___Scanner______next____, struct ___Scanner___ * ___this___) {
+  int pos = VAR(___this___)->___currentpos___;
+#if defined(MULTICORE_GC)||defined(PMC_GC)
+  struct ArrayObject * result= allocate_newarray(NULL, CHARARRAYTYPE, 10);
+#else
+  struct ArrayObject * result=allocate_newarray(CHARARRAYTYPE, 10);
 #endif
-
-#ifdef D___Scanner______nextInt____ 
-int ___Scanner______nextInt____(struct ___Scanner______nextInt_____params * ___params___) {
-  // TODO
-  return 0;
+  int i = 0;
+  while(true) { //(VAR(___this___)->___sourcename___[pos]==' ')||(VAR(___this___)->___sourcename___[pos]=='\n')){
+         pos++;
+  }
+  do {
+         ((short *)(((char *)&result->___length___)+sizeof(int)))[i++]='\0';//(short)VAR(___this___)->___sourcename___[pos++]; // TODO
+  }while(true);//(VAR(___this___)->___sourcename___[pos]!=' ')&&(VAR(___this___)->___sourcename___[pos]!='\n'));
+  VAR(___this___)->___currentpos___ = pos;
+  return result;
 }
 #endif