Return by reference and pass by reference working with objects. Closures might present problems, however
This commit is contained in:
@@ -65,7 +65,7 @@ obj future<T> {
|
||||
status = pthread_create(&thread,wrapper)
|
||||
}
|
||||
|
||||
fun get_status() {
|
||||
fun get_status():int {
|
||||
return status
|
||||
}
|
||||
|
||||
|
||||
@@ -70,7 +70,7 @@ fun load_grammer(gram_str: string::string): grammer {
|
||||
doLeftSide = true
|
||||
} else {
|
||||
if (doLeftSide) {
|
||||
leftSide = symbol::symbol(word, true)
|
||||
leftSide = symbol::symbol(word, false)
|
||||
gram.non_terminals.add(leftSide)
|
||||
} else {
|
||||
if (word[0] == '"') {
|
||||
|
||||
@@ -46,7 +46,7 @@ obj map<T,U> (Object) {
|
||||
fun contains_key(key: T): bool {
|
||||
return keys.contains(key)
|
||||
}
|
||||
fun get(key: T): U {
|
||||
fun get(key: T): ref U {
|
||||
return values.get(keys.find(key))
|
||||
}
|
||||
fun remove(key: T) {
|
||||
@@ -58,7 +58,7 @@ obj map<T,U> (Object) {
|
||||
keys.remove(idx)
|
||||
values.remove(idx)
|
||||
}
|
||||
fun operator[](key: T): U {
|
||||
fun operator[](key: T): ref U {
|
||||
return get(key)
|
||||
}
|
||||
fun for_each(func: fun(T, U):void) {
|
||||
|
||||
@@ -52,14 +52,11 @@ obj string (Object) {
|
||||
data.destruct()
|
||||
}
|
||||
|
||||
fun operator[](index: int): char { return data[index]; }
|
||||
fun operator[](index: int): ref char { return data[index]; }
|
||||
fun slice(first: int, second: int): string {
|
||||
var new.construct(data.slice(first,second)): string
|
||||
return new
|
||||
}
|
||||
fun operator[]=(index: int, toSet: char) {
|
||||
data[index] = toSet
|
||||
}
|
||||
fun set(index: int, toSet: char) {
|
||||
data.set(index, toSet)
|
||||
}
|
||||
|
||||
@@ -92,9 +92,9 @@ obj vector<T> (Object) {
|
||||
return new
|
||||
}
|
||||
|
||||
fun at(index: int): T { return get(index); }
|
||||
fun operator[](index: int): T { return get(index); }
|
||||
fun get(index: int): T {
|
||||
fun at(index: int): ref T { return get(index); }
|
||||
fun operator[](index: int): ref T { return get(index); }
|
||||
fun get(index: int): ref T {
|
||||
if (index < 0 || index >= size) {
|
||||
println("Vector access out of bounds! Retuning 0th element as sanest option");
|
||||
print("Vector tried to access element: ");
|
||||
@@ -124,9 +124,6 @@ obj vector<T> (Object) {
|
||||
return find(item) != -1
|
||||
}
|
||||
|
||||
fun operator[]=(index: int, dataIn: T) {
|
||||
set(index, dataIn)
|
||||
}
|
||||
fun set(index: int, dataIn: T): void {
|
||||
if (index < 0 || index >= size)
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user