Swapped pointers to the other side for types to prevent ambiguity, i.e. *int instead of int*
This commit is contained in:
@@ -52,11 +52,11 @@ obj grammer (Object) {
|
||||
var rules: vector::vector<rule>
|
||||
var regexs: set::set<regex::regex>
|
||||
|
||||
fun construct(): grammer* {
|
||||
fun construct(): *grammer {
|
||||
rules.construct()
|
||||
regexs.construct()
|
||||
}
|
||||
fun copy_construct(old: grammer*) {
|
||||
fun copy_construct(old: *grammer) {
|
||||
rules.copy_construct(&old->rules)
|
||||
regexs.copy_construct(&old->regexs)
|
||||
}
|
||||
@@ -91,13 +91,13 @@ obj rule (Object) {
|
||||
var position: int
|
||||
var lookahead: set::set<symbol::symbol>
|
||||
|
||||
fun construct(): rule* {
|
||||
fun construct(): *rule {
|
||||
lhs.construct()
|
||||
rhs.construct()
|
||||
position = 0
|
||||
lookahead.construct()
|
||||
}
|
||||
fun copy_construct(other: rule*) {
|
||||
fun copy_construct(other: *rule) {
|
||||
lhs.copy_construct(&other->lhs)
|
||||
rhs.copy_construct(&other->rhs)
|
||||
position = other->position
|
||||
|
||||
@@ -14,7 +14,7 @@ fun println<T>(toPrint: T) : void {
|
||||
print("\n")
|
||||
}
|
||||
|
||||
fun print(toPrint: char*) : void {
|
||||
fun print(toPrint: *char) : void {
|
||||
__if_comp__ __C__ {
|
||||
simple_passthrough(toPrint = toPrint::) """
|
||||
printf("%s", toPrint);
|
||||
@@ -77,7 +77,7 @@ fun print(toPrint: double) : void{
|
||||
fun read_file(path: string::string): string::string {
|
||||
var char_path = path.toCharArray()
|
||||
defer delete(char_path)
|
||||
var data: char*
|
||||
var data: *char
|
||||
__if_comp__ __C__ {
|
||||
simple_passthrough(char_path = char_path:data = data:) """
|
||||
FILE *fp = fopen(char_path, "r");
|
||||
|
||||
@@ -8,7 +8,7 @@ obj lexer (Object) {
|
||||
var regs: vector::vector<regex::regex>
|
||||
var input: string::string
|
||||
var position: int
|
||||
fun construct(): lexer* {
|
||||
fun construct(): *lexer {
|
||||
regs.construct()
|
||||
input.construct()
|
||||
position = 0
|
||||
@@ -18,7 +18,7 @@ obj lexer (Object) {
|
||||
regs.destruct()
|
||||
input.destruct()
|
||||
}
|
||||
fun copy_construct(old: lexer*) {
|
||||
fun copy_construct(old: *lexer) {
|
||||
regs.copy_construct(&old->regs)
|
||||
input.copy_construct(&old->input)
|
||||
position = old->position
|
||||
@@ -30,7 +30,7 @@ obj lexer (Object) {
|
||||
fun add_regex(newOne: regex::regex) {
|
||||
regs.add(newOne)
|
||||
}
|
||||
fun add_regex(newOne: char*) {
|
||||
fun add_regex(newOne: *char) {
|
||||
regs.add(regex::regex(newOne))
|
||||
}
|
||||
fun set_input(in: string::string) {
|
||||
|
||||
@@ -19,7 +19,7 @@ obj map<T,U> (Object) {
|
||||
keys.construct()
|
||||
values.construct()
|
||||
}
|
||||
fun copy_construct(old: map<T,U>*) {
|
||||
fun copy_construct(old: *map<T,U>) {
|
||||
keys.copy_construct(&old->keys)
|
||||
values.copy_construct(&old->values)
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import vector:*;
|
||||
import io:*;
|
||||
|
||||
typedef matrix (Object) {
|
||||
obj matrix (Object) {
|
||||
var data: vector<double>;
|
||||
var rows: int;
|
||||
var cols: int;
|
||||
@@ -12,7 +12,7 @@ typedef matrix (Object) {
|
||||
|
||||
//Constructor with no arguments
|
||||
//No matrix is made
|
||||
fun construct(): matrix* {
|
||||
fun construct(): *matrix {
|
||||
rows = 0;
|
||||
cols = 0;
|
||||
data.construct();
|
||||
@@ -21,7 +21,7 @@ typedef matrix (Object) {
|
||||
|
||||
//Constructor with single argument
|
||||
//Creates an N x N matrix
|
||||
fun construct(size: int): matrix* {
|
||||
fun construct(size: int): *matrix {
|
||||
rows = size;
|
||||
cols = size;
|
||||
data.construct(rows*cols);
|
||||
@@ -30,7 +30,7 @@ typedef matrix (Object) {
|
||||
|
||||
//Constructor with two arguments
|
||||
//Creates an N x M matrix
|
||||
fun construct(r: int, c: int): matrix* {
|
||||
fun construct(r: int, c: int): *matrix {
|
||||
rows = r;
|
||||
cols = c;
|
||||
data.construct(rows*cols);
|
||||
@@ -144,23 +144,3 @@ typedef matrix (Object) {
|
||||
|
||||
};//end Matrix class
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -6,8 +6,8 @@ __if_comp__ __C__ simple_passthrough """
|
||||
|
||||
/* we have a template versions so we don't have to cast (because we don't have that yet) */
|
||||
|
||||
fun malloc<T>(size: int): T* {
|
||||
var memPtr: T*;
|
||||
fun malloc<T>(size: int): *T {
|
||||
var memPtr: *T;
|
||||
__if_comp__ __C__ {
|
||||
simple_passthrough( size = size, memPtr = memPtr : memPtr = memPtr :) """
|
||||
memPtr = malloc(size);
|
||||
@@ -16,7 +16,7 @@ fun malloc<T>(size: int): T* {
|
||||
return memPtr;
|
||||
}
|
||||
|
||||
fun free<T>(memPtr: T*): void {
|
||||
fun free<T>(memPtr: *T): void {
|
||||
__if_comp__ __C__ {
|
||||
simple_passthrough(memPtr = memPtr ::) """
|
||||
free(memPtr);
|
||||
@@ -25,7 +25,7 @@ fun free<T>(memPtr: T*): void {
|
||||
}
|
||||
|
||||
fun sizeof<T>(): int {
|
||||
var testObj: T*;
|
||||
var testObj: *T;
|
||||
var result: int;
|
||||
__if_comp__ __C__ {
|
||||
simple_passthrough(testObj = testObj : result = result:) """
|
||||
@@ -35,21 +35,21 @@ fun sizeof<T>(): int {
|
||||
return result;
|
||||
}
|
||||
|
||||
fun new<T>(count: int): T* {
|
||||
fun new<T>(count: int): *T {
|
||||
return malloc<T>( sizeof<T>() * count );
|
||||
}
|
||||
|
||||
fun new<T>(): T* {
|
||||
fun new<T>(): *T {
|
||||
return new<T>(1);
|
||||
}
|
||||
|
||||
/* We specilize on the trait Object to decide on whether or not the destructor should be called */
|
||||
fun delete<T>(toDelete: T*, itemCount: int): void {
|
||||
fun delete<T>(toDelete: *T, itemCount: int): void {
|
||||
delete<T>(toDelete);
|
||||
}
|
||||
|
||||
/* Calling this with itemCount = 0 allows you to delete destructable objects without calling their destructors. */
|
||||
fun delete<T(Object)>(toDelete: T*, itemCount: int): void {
|
||||
fun delete<T(Object)>(toDelete: *T, itemCount: int): void {
|
||||
// start at one because the actual delete will call the destructor of the first one as it
|
||||
// finishes the pointer
|
||||
for (var i: int = 0; i < itemCount; i++;)
|
||||
@@ -59,50 +59,50 @@ fun delete<T(Object)>(toDelete: T*, itemCount: int): void {
|
||||
}
|
||||
|
||||
/* We specilize on the trait Object to decide on whether or not the destructor should be called */
|
||||
fun delete<T>(toDelete: T*): void {
|
||||
fun delete<T>(toDelete: *T): void {
|
||||
free<T>(toDelete);
|
||||
}
|
||||
|
||||
fun delete<T(Object)>(toDelete: T*): void {
|
||||
fun delete<T(Object)>(toDelete: *T): void {
|
||||
toDelete->destruct();
|
||||
free<T>(toDelete);
|
||||
}
|
||||
|
||||
// a wrapper for construct if it has the Object trait
|
||||
fun maybe_construct<T>(it:T*):T* {
|
||||
fun maybe_construct<T>(it:*T):*T {
|
||||
return it
|
||||
}
|
||||
|
||||
fun maybe_construct<T(Object)>(it:T*):T* {
|
||||
fun maybe_construct<T(Object)>(it:*T):*T {
|
||||
return it->construct()
|
||||
}
|
||||
|
||||
|
||||
// a wrapper for copy constructing if it has the Object trait
|
||||
fun maybe_copy_construct<T>(to:T*, from:T*):void {
|
||||
fun maybe_copy_construct<T>(to:*T, from:*T):void {
|
||||
*to = *from
|
||||
}
|
||||
|
||||
fun maybe_copy_construct<T(Object)>(to:T*, from:T*):void {
|
||||
fun maybe_copy_construct<T(Object)>(to:*T, from:*T):void {
|
||||
to->copy_construct(from)
|
||||
}
|
||||
|
||||
// a wrapper for destruct if it has the Object trait
|
||||
fun maybe_destruct<T>(it:T*):void {}
|
||||
fun maybe_destruct<T>(it:*T):void {}
|
||||
|
||||
fun maybe_destruct<T(Object)>(it:T*):void {
|
||||
fun maybe_destruct<T(Object)>(it:*T):void {
|
||||
it->destruct()
|
||||
}
|
||||
|
||||
// a function that allows the safe deletion of recursive and complicated data structures
|
||||
fun safe_recursive_delete<T>(first: T*, addingFunc: fun(T*): set::set<T*>) {
|
||||
var toDelete = set::set<T*>()
|
||||
fun safe_recursive_delete<T>(first: *T, addingFunc: fun(*T): set::set<*T>) {
|
||||
var toDelete = set::set<*T>()
|
||||
var next = set::set(first)
|
||||
while (toDelete != next) {
|
||||
toDelete = next
|
||||
toDelete.for_each( fun(it: T*) next.add(addingFunc(it)); )
|
||||
toDelete.for_each( fun(it: *T) next.add(addingFunc(it)); )
|
||||
}
|
||||
toDelete.for_each( fun(it: T*) delete(it); )
|
||||
toDelete.for_each( fun(it: *T) delete(it); )
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ import set
|
||||
import util
|
||||
import conversions
|
||||
|
||||
fun regex(in: char*):regex {
|
||||
fun regex(in: *char):regex {
|
||||
return regex(string::string(in))
|
||||
}
|
||||
fun regex(in: string::string):regex {
|
||||
@@ -16,46 +16,46 @@ fun regex(in: string::string):regex {
|
||||
|
||||
obj regexState (Object) {
|
||||
var character: char
|
||||
var next_states: vector::vector<regexState*>
|
||||
fun construct(charIn:char): regexState* {
|
||||
var next_states: vector::vector<*regexState>
|
||||
fun construct(charIn:char): *regexState {
|
||||
character = charIn
|
||||
next_states.construct()
|
||||
return this
|
||||
}
|
||||
fun construct(): regexState* {
|
||||
fun construct(): *regexState {
|
||||
return construct(conversions::to_char(0))
|
||||
}
|
||||
fun copy_construct(old:regexState*): void {
|
||||
fun copy_construct(old:*regexState): void {
|
||||
character = old->character
|
||||
next_states.copy_construct(&old->next_states)
|
||||
}
|
||||
fun destruct():void {
|
||||
next_states.destruct()
|
||||
}
|
||||
fun match(input: char): vector::vector<regexState*> {
|
||||
return next_states.filter(fun(it:regexState*):bool { return it->character == input; })
|
||||
fun match(input: char): vector::vector<*regexState> {
|
||||
return next_states.filter(fun(it:*regexState):bool { return it->character == input; })
|
||||
}
|
||||
fun is_end():bool {
|
||||
return next_states.any_true(fun(state: regexState*):bool { return state->character == 1; })
|
||||
return next_states.any_true(fun(state: *regexState):bool { return state->character == 1; })
|
||||
}
|
||||
}
|
||||
|
||||
obj regex (Object) {
|
||||
var regexString: string::string
|
||||
var begin: regexState*
|
||||
var begin: *regexState
|
||||
|
||||
fun construct(regexStringIn: string::string): regex* {
|
||||
fun construct(regexStringIn: string::string): *regex {
|
||||
regexString.copy_construct(®exStringIn)
|
||||
|
||||
var beginningAndEnd = compile(regexStringIn)
|
||||
// init our begin, and the end state as the next state of each end
|
||||
begin = beginningAndEnd.first
|
||||
var end = mem::new<regexState>()->construct(conversions::to_char(1))
|
||||
beginningAndEnd.second.for_each(fun(it: regexState*): void { it->next_states.add(end); })
|
||||
beginningAndEnd.second.for_each(fun(it: *regexState): void { it->next_states.add(end); })
|
||||
return this
|
||||
}
|
||||
|
||||
fun copy_construct(old:regex*):void {
|
||||
fun copy_construct(old:*regex):void {
|
||||
//begin = old->begin
|
||||
//regexString.copy_construct(&old->regexString)
|
||||
construct(old->regexString)
|
||||
@@ -63,7 +63,7 @@ obj regex (Object) {
|
||||
|
||||
fun destruct():void {
|
||||
regexString.destruct()
|
||||
mem::safe_recursive_delete(begin, fun(it: regexState*): set::set<regexState*> { return set::from_vector(it->next_states); } )
|
||||
mem::safe_recursive_delete(begin, fun(it: *regexState): set::set<*regexState> { return set::from_vector(it->next_states); } )
|
||||
}
|
||||
|
||||
fun operator==(other: regex):bool {
|
||||
@@ -75,10 +75,10 @@ obj regex (Object) {
|
||||
construct(other.regexString)
|
||||
}
|
||||
|
||||
fun compile(regex_string: string::string): util::pair<regexState*, vector::vector<regexState*>> {
|
||||
fun compile(regex_string: string::string): util::pair<*regexState, vector::vector<*regexState>> {
|
||||
var first = mem::new<regexState>()->construct()
|
||||
var previous_begin = vector::vector<regexState*>()
|
||||
var previous_end = vector::vector<regexState*>()
|
||||
var previous_begin = vector::vector<*regexState>()
|
||||
var previous_end = vector::vector<*regexState>()
|
||||
var current_begin = vector::vector(first)
|
||||
var current_end = vector::vector(first)
|
||||
var alternating = false
|
||||
@@ -115,11 +115,11 @@ obj regex (Object) {
|
||||
i = perenEnd-1
|
||||
|
||||
if (alternating) {
|
||||
previous_end.for_each(fun(it: regexState*):void { it->next_states.add_all(innerBeginEnd.first->next_states); } )
|
||||
previous_end.for_each(fun(it: *regexState):void { it->next_states.add_all(innerBeginEnd.first->next_states); } )
|
||||
current_begin.add_all(innerBeginEnd.first->next_states)
|
||||
current_end.add_all(innerBeginEnd.second)
|
||||
} else {
|
||||
current_end.for_each(fun(it: regexState*):void { it->next_states.add_all(innerBeginEnd.first->next_states); } )
|
||||
current_end.for_each(fun(it: *regexState):void { it->next_states.add_all(innerBeginEnd.first->next_states); } )
|
||||
previous_begin = current_begin
|
||||
previous_end = current_end
|
||||
current_begin = innerBeginEnd.first->next_states
|
||||
@@ -133,11 +133,11 @@ obj regex (Object) {
|
||||
} else {
|
||||
var next = mem::new<regexState>()->construct(regex_string[i])
|
||||
if (alternating) {
|
||||
previous_end.for_each(fun(it: regexState*):void { it->next_states.add(next); })
|
||||
previous_end.for_each(fun(it: *regexState):void { it->next_states.add(next); })
|
||||
current_begin.add(next)
|
||||
current_end.add(next)
|
||||
} else {
|
||||
current_end.for_each(fun(it: regexState*):void { it->next_states.add(next); })
|
||||
current_end.for_each(fun(it: *regexState):void { it->next_states.add(next); })
|
||||
previous_begin = current_begin
|
||||
previous_end = current_end
|
||||
current_begin = vector::vector(next)
|
||||
@@ -151,19 +151,19 @@ obj regex (Object) {
|
||||
return beginAndEnd
|
||||
}
|
||||
|
||||
fun long_match(to_match: char*): int { return long_match(string::string(to_match)); }
|
||||
fun long_match(to_match: *char): int { return long_match(string::string(to_match)); }
|
||||
fun long_match(to_match: string::string): int {
|
||||
var next = vector::vector(begin)
|
||||
var longest = -1
|
||||
for (var i = 0; i < to_match.length(); i++;) {
|
||||
if (next.size == 0)
|
||||
return longest
|
||||
if (next.any_true(fun(state: regexState*):bool { return state->is_end(); }))
|
||||
if (next.any_true(fun(state: *regexState):bool { return state->is_end(); }))
|
||||
longest = i
|
||||
//next = next.flatten_map<regexState*>(fun(state: regexState*): vector::vector<regexState*> { return state->match(to_match[i]); })
|
||||
next = next.flatten_map(fun(state: regexState*): vector::vector<regexState*> { return state->match(to_match[i]); })
|
||||
//next = next.flatten_map<*regexState>(fun(state: *regexState): vector::vector<*regexState> { return state->match(to_match[i]); })
|
||||
next = next.flatten_map(fun(state: *regexState): vector::vector<*regexState> { return state->match(to_match[i]); })
|
||||
}
|
||||
if (next.any_true(fun(state: regexState*):bool { return state->is_end(); }))
|
||||
if (next.any_true(fun(state: *regexState):bool { return state->is_end(); }))
|
||||
return to_match.length()
|
||||
return longest
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ obj set<T> (Object) {
|
||||
fun construct() {
|
||||
data.construct()
|
||||
}
|
||||
fun copy_construct(old: set<T>*) {
|
||||
fun copy_construct(old: *set<T>) {
|
||||
data.copy_construct(&old->data)
|
||||
}
|
||||
fun operator=(rhs: set<T>) {
|
||||
|
||||
@@ -2,18 +2,18 @@ import vector
|
||||
import util
|
||||
import mem
|
||||
|
||||
fun string(in:char*):string {
|
||||
fun string(in:*char):string {
|
||||
var out:string = in
|
||||
return out
|
||||
}
|
||||
|
||||
obj string (Object) {
|
||||
var data: vector::vector<char>;
|
||||
fun construct(): string* {
|
||||
fun construct(): *string {
|
||||
data.construct();
|
||||
return this;
|
||||
}
|
||||
fun construct(str: char*): string* {
|
||||
fun construct(str: *char): *string {
|
||||
data.construct();
|
||||
while(*str) {
|
||||
data.addEnd(*str);
|
||||
@@ -22,23 +22,23 @@ obj string (Object) {
|
||||
// no null terminator
|
||||
return this;
|
||||
}
|
||||
fun construct(vec: vector::vector<char>): string* {
|
||||
fun construct(vec: vector::vector<char>): *string {
|
||||
data.copy_construct(&vec);
|
||||
return this;
|
||||
}
|
||||
fun construct(str: string): string* {
|
||||
fun construct(str: string): *string {
|
||||
return construct(str.data);
|
||||
}
|
||||
|
||||
fun copy_construct(old: string*): void {
|
||||
fun copy_construct(old: *string): void {
|
||||
data.copy_construct(&old->data)
|
||||
}
|
||||
|
||||
fun copy_construct(old: char**): void {
|
||||
fun copy_construct(old: **char): void {
|
||||
construct(*old)
|
||||
}
|
||||
|
||||
fun operator=(str: char*): void {
|
||||
fun operator=(str: *char): void {
|
||||
destruct();
|
||||
construct(str)
|
||||
}
|
||||
@@ -69,7 +69,7 @@ obj string (Object) {
|
||||
return length() == other.length() && !util::range(length()).any_true(fun(i: int):bool { return data[i] != other[i]; } )
|
||||
}
|
||||
|
||||
fun operator+(str: char*): string {
|
||||
fun operator+(str: *char): string {
|
||||
var newStr.construct(str):string
|
||||
var ret.construct(data + newStr.data):string
|
||||
return ret
|
||||
@@ -85,7 +85,7 @@ obj string (Object) {
|
||||
data += character
|
||||
}
|
||||
|
||||
fun operator+=(str: char*): void {
|
||||
fun operator+=(str: *char): void {
|
||||
var newStr.construct(str):string
|
||||
data += newStr.data
|
||||
}
|
||||
@@ -95,8 +95,8 @@ obj string (Object) {
|
||||
data += newStr.data
|
||||
}
|
||||
|
||||
fun toCharArray(): char* {
|
||||
var out: char* = mem::new<char>(data.size+1);
|
||||
fun toCharArray(): *char {
|
||||
var out: *char = mem::new<char>(data.size+1);
|
||||
for (var i: int = 0; i < data.size; i++;)
|
||||
out[i] = data.get(i);
|
||||
// null terminator
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import string
|
||||
|
||||
fun symbol(nameIn: char*, terminalIn: bool): symbol {
|
||||
fun symbol(nameIn: *char, terminalIn: bool): symbol {
|
||||
var toRet.construct(string::string(nameIn), terminalIn, string::string("no_value")): symbol
|
||||
return toRet
|
||||
}
|
||||
@@ -10,7 +10,7 @@ fun symbol(nameIn: string::string, terminalIn: bool): symbol {
|
||||
return toRet
|
||||
}
|
||||
|
||||
fun symbol(nameIn: char*, terminalIn: bool, dataIn: char*): symbol {
|
||||
fun symbol(nameIn: *char, terminalIn: bool, dataIn: *char): symbol {
|
||||
var toRet.construct(string::string(nameIn), terminalIn, string::string(dataIn)): symbol
|
||||
return toRet
|
||||
}
|
||||
@@ -25,12 +25,12 @@ obj symbol (Object) {
|
||||
var name: string::string
|
||||
var terminal: bool
|
||||
|
||||
fun construct(): symbol* {
|
||||
fun construct(): *symbol {
|
||||
data.construct()
|
||||
name.construct()
|
||||
return this
|
||||
}
|
||||
fun construct(nameIn: string::string, terminalIn: bool, dataIn: string::string): symbol* {
|
||||
fun construct(nameIn: string::string, terminalIn: bool, dataIn: string::string): *symbol {
|
||||
name.construct(nameIn)
|
||||
terminal = terminalIn
|
||||
data.construct(dataIn)
|
||||
@@ -40,7 +40,7 @@ obj symbol (Object) {
|
||||
data.destruct()
|
||||
name.destruct()
|
||||
}
|
||||
fun copy_construct(old: symbol*) {
|
||||
fun copy_construct(old: *symbol) {
|
||||
data.copy_construct(&old->data)
|
||||
name.copy_construct(&old->name)
|
||||
terminal = old->terminal
|
||||
@@ -53,7 +53,7 @@ obj symbol (Object) {
|
||||
return data == other.data && name == other.name && terminal == other.terminal;
|
||||
}
|
||||
fun to_string(): string::string {
|
||||
var terminalString: char*
|
||||
var terminalString: *char
|
||||
if (terminal)
|
||||
terminalString = "true"
|
||||
else
|
||||
|
||||
@@ -21,19 +21,19 @@ obj pair<T,U> (Object) {
|
||||
var first: T
|
||||
var second: U
|
||||
|
||||
fun construct(firstIn: T, secondIn: U): pair<T,U>* {
|
||||
fun construct(firstIn: T, secondIn: U): *pair<T,U> {
|
||||
mem::maybe_copy_construct(&first, &firstIn)
|
||||
mem::maybe_copy_construct(&second, &secondIn)
|
||||
return this
|
||||
}
|
||||
|
||||
fun construct(): pair<T,U>* {
|
||||
fun construct(): *pair<T,U> {
|
||||
mem::maybe_construct(&first)
|
||||
mem::maybe_construct(&second)
|
||||
return this
|
||||
}
|
||||
|
||||
fun copy_construct(old: pair<T,U>*):void {
|
||||
fun copy_construct(old: *pair<T,U>):void {
|
||||
mem::maybe_copy_construct(&first, &old->first)
|
||||
mem::maybe_copy_construct(&second, &old->second)
|
||||
}
|
||||
@@ -62,7 +62,7 @@ obj range {
|
||||
var begin: int
|
||||
var end: int
|
||||
var step: int
|
||||
fun construct(beginIn: int, endIn: int, stepIn: int) : range* {
|
||||
fun construct(beginIn: int, endIn: int, stepIn: int) : *range {
|
||||
begin = beginIn
|
||||
end = endIn
|
||||
step = stepIn
|
||||
|
||||
@@ -14,18 +14,18 @@ fun vector<T>(in:T):vector<T> {
|
||||
}
|
||||
|
||||
obj vector<T> (Object) {
|
||||
var data: T*;
|
||||
var data: *T;
|
||||
var size: int;
|
||||
var available: int;
|
||||
|
||||
fun construct(): vector<T>* {
|
||||
fun construct(): *vector<T> {
|
||||
size = 0;
|
||||
available = 8;
|
||||
data = new<T>(8);
|
||||
return this;
|
||||
}
|
||||
|
||||
fun construct(newSize: int): vector<T>*{
|
||||
fun construct(newSize: int): *vector<T>{
|
||||
size = newSize;
|
||||
available = newSize;
|
||||
|
||||
@@ -33,7 +33,7 @@ obj vector<T> (Object) {
|
||||
return this;
|
||||
}
|
||||
|
||||
fun copy_construct(old: vector<T>*): void {
|
||||
fun copy_construct(old: *vector<T>): void {
|
||||
construct()
|
||||
for (var i = 0; i < old->size; i++;)
|
||||
addEnd(old->get(i))
|
||||
@@ -77,7 +77,7 @@ obj vector<T> (Object) {
|
||||
}
|
||||
|
||||
fun resize(newSize: int): bool {
|
||||
var newData: T* = new<T>(newSize);
|
||||
var newData: *T = new<T>(newSize);
|
||||
if (!newData)
|
||||
return false;
|
||||
for (var i: int = 0; i < lesser<int>(size, newSize); i++;)
|
||||
@@ -114,7 +114,7 @@ obj vector<T> (Object) {
|
||||
return data[index];
|
||||
}
|
||||
|
||||
fun getBackingMemory(): T* { return data; }
|
||||
fun getBackingMemory(): *T { return data; }
|
||||
|
||||
// This is a template for the interesting reason that structs
|
||||
// can not be compared for equality in C, and maybe we haven't defined equality
|
||||
|
||||
@@ -101,4 +101,3 @@ fun vector<T>(first:T, second:T, third:T, fourth:T, fifth:T, sixth:T, seventh:T,
|
||||
return out
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user