public class Object {
public native int hashcode();
+ public String toString() {
+ return String.valueOf(this);
+ }
+
+
public boolean equals(Object o) {
if (o==this)
return true;
public String(char string[]) {
this.string=string;
}
+
+ public static String valueOf(Object o) {
+ return o.toString();
+ }
+
+ /* public static String valueOf(int x) {
+ int length=0;
+ int tmp=x;
+ do {
+ tmp=tmp/10;
+ length=length+1;
+ } while(tmp!=0);
+ char chararray[]=new chararray[length];
+ do {
+ length--;
+ chararray[length]=x%10;
+ x=x/10;
+ } while (length!=0);
+ return new String(chararray);
+ }*/
+
}
public class System {
- public static native void printInt(int x);
+ /* public static void printInt(int x) {
+ String s=String.valueOf(x);
+ printString(s);
+ }*/
+
public static native void printString(String s);
+ public static native void printInt(int x);
}
type="void *";
else
type=elementtype.getSafeSymbol()+" ";
+
+ if (fen.needsBoundsCheck()) {
+ output.println("if ("+generateTemp(fm, fen.getIndex())+"< 0 || "+generateTemp(fm, fen.getIndex())+" >= "+generateTemp(fm,fen.getSrc()) + "->___length___)");
+ output.println("failedboundschk();");
+ }
+
output.println(generateTemp(fm, fen.getDst())+"=(("+ type+"*)(((char *) &("+ generateTemp(fm,fen.getSrc())+"->___length___))+sizeof(int)))["+generateTemp(fm, fen.getIndex())+"];");
}
else
type=elementtype.getSafeSymbol()+" ";
+ if (fsen.needsBoundsCheck()) {
+ output.println("if ("+generateTemp(fm, fsen.getIndex())+"< 0 || "+generateTemp(fm, fsen.getIndex())+" >= "+generateTemp(fm,fsen.getDst()) + "->___length___)");
+ output.println("failedboundschk();");
+ }
+
output.println("(("+type +"*)(((char *) &("+ generateTemp(fm,fsen.getDst())+"->___length___))+sizeof(int)))["+generateTemp(fm, fsen.getIndex())+"]="+generateTemp(fm,fsen.getSrc())+";");
}
this.dst=dst;
}
+ public boolean needsBoundsCheck() {
+ return true;
+ }
+
public TempDescriptor getIndex() {
return index;
}
this.dst=dst;
}
+ public boolean needsBoundsCheck() {
+ return true;
+ }
+
public TempDescriptor getSrc() {
return src;
}
Lex.Lexer l = new Lex.Lexer(fr);
java_cup.runtime.lr_parser g;
g = new Parse.Parser(l);
- ParseNode p=(ParseNode) g./*debug_*/parse().value;
+ ParseNode p=(ParseNode) g.debug_parse().value;
state.addParseNode(p);
if (l.numErrors()!=0) {
System.out.println("Error parsing Object.java");
Parse/Parser.java Parse/Sym.java: Parse/java14.cup
cd Parse && \
- java -cp ../../cup:$(CLASSPATH) java_cup.Main -parser Parser -symbols Sym < java14.cup
+ java -cp ../../cup:$(CLASSPATH) java_cup.Main -debug -nonterms -parser Parser -symbols Sym < java14.cup
%.class: %.java
javac -cp ../cup:.:$(CLASSPATH) $<
RESULT=pn;
:};
-flag_list_opt ::= LPAREN flag_list:fl RPAREN {:RESULT=fl;:}
+flag_list_opt ::= LBRACE flag_list:fl RBRACE {:RESULT=fl;:}
| {: RESULT = new ParseNode("empty"); :}
;
// | name DOT THIS
;
class_instance_creation_expression ::=
- NEW class_or_interface_type:type LPAREN argument_list_opt:args RPAREN flag_effects_opt:feo {:
+ NEW class_or_interface_type:type LPAREN argument_list_opt:args RPAREN flag_list_opt:feo {:
ParseNode pn=new ParseNode("createobject");
pn.addChild(type);
pn.addChild(args);
}
void ___System______printInt____I(int x) {
- printf("%d\n",x);
+ printf("%d",x);
}
void ___System______printString____L___String___(struct ___String___ * s) {
((short *)(((char *)& chararray->___length___)+sizeof(int)))[i]=(short)str[i]; }
return strobj;
}
+
+void failedboundschk() {
+ printf("Array out of bounds\n");
+ exit(-1);
+}
+
+void failednullptr() {
+ printf("Dereferenced a null pointer\n");
+ exit(-1);
+}
void * allocate_new(int type);
void * allocate_newarray(int type, int length);
struct ___String___ * NewString(char *str,int length);
+
+void failedboundschk();
+void failednullptr();
#endif
--- /dev/null
+#!/bin/bash
+ROBUSTROOT=~/research/Robust/src
+MAINFILE=$1
+shift
+mkdir tmpbuilddirectory
+java -cp $ROBUSTROOT/../cup/:$ROBUSTROOT Main.Main -classlibrary $ROBUSTROOT/ClassLibrary/ -dir tmpbuilddirectory -mainclass $MAINFILE $@
+gcc -I$ROBUSTROOT/Runtime -Itmpbuilddirectory -O0 -g tmpbuilddirectory/methods.c $ROBUSTROOT/Runtime/runtime.c -o $MAINFILE.bin
\ No newline at end of file