Fixed Kalypso's scope lookup to handle ::, ported another test (+ got another one from having proper scope operator)
This commit is contained in:
@@ -579,7 +579,18 @@ fun identifier_lookup(name: string, scope: *ast_node): *ast_node {
|
||||
fun scope_lookup(name: string, scope: *ast_node): vector<*ast_node> {
|
||||
println("*****Doing a name lookup for*****")
|
||||
println(name)
|
||||
return scope_lookup_helper(name, scope, set<*ast_node>())
|
||||
var results = vector(scope)
|
||||
name.split("::").for_each(fun(i: string) {
|
||||
println(string("based on split, looking up: ") + i)
|
||||
var next_results = vector<*ast_node>()
|
||||
results.for_each(fun(s: *ast_node) {
|
||||
print("looking in scope: ")
|
||||
println(s)
|
||||
next_results += scope_lookup_helper(i, s, set<*ast_node>())
|
||||
})
|
||||
results = next_results
|
||||
})
|
||||
return results
|
||||
}
|
||||
fun scope_lookup_helper(name: string, scope: *ast_node, visited: set<*ast_node>): vector<*ast_node> {
|
||||
// need to do properly scopded lookups
|
||||
|
||||
@@ -149,11 +149,28 @@ obj string (Object, Serializable) {
|
||||
return out;
|
||||
}
|
||||
|
||||
fun lines(): vector::vector<string> {
|
||||
fun split(delim: *char): vector::vector<string> return split(string(delim))
|
||||
fun split(delim: string): vector::vector<string> {
|
||||
var out.construct(): vector::vector<string>
|
||||
var current = string("")
|
||||
for (var i = 0; i < data.size; i++;) {
|
||||
if (data[i] == '\n') {
|
||||
if (i < data.size-delim.length() && slice(i, i+delim.length()) == delim) {
|
||||
out.add(current)
|
||||
current = string("")
|
||||
i += delim.length()-1
|
||||
} else {
|
||||
current += data[i]
|
||||
}
|
||||
}
|
||||
out.add(current)
|
||||
return out
|
||||
}
|
||||
fun lines(): vector::vector<string> return split('\n')
|
||||
fun split(delim: char): vector::vector<string> {
|
||||
var out.construct(): vector::vector<string>
|
||||
var current = string("")
|
||||
for (var i = 0; i < data.size; i++;) {
|
||||
if (data[i] == delim) {
|
||||
out.add(current)
|
||||
current = string("")
|
||||
} else {
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import io;
|
||||
import simple_print;
|
||||
|
||||
fun nothing(): void {}
|
||||
|
||||
fun main(): int {
|
||||
nothing();
|
||||
io::println("It was nothing");
|
||||
simple_print::println("It was nothing");
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user