1011 - string-equal now working
This commit is contained in:
parent
07d35c4af3
commit
a8007cc483
|
@ -87,6 +87,8 @@ void setup_types() {
|
|||
Type[address].name = "address";
|
||||
int boolean = Type_number["boolean"] = Next_type_number++;
|
||||
Type[boolean].name = "boolean";
|
||||
int character = Type_number["character"] = Next_type_number++;
|
||||
Type[character].name = "character";
|
||||
int array = Type_number["array"] = Next_type_number++;
|
||||
Type[array].name = "array";
|
||||
// End Mu Types Initialization.
|
||||
|
|
|
@ -41,8 +41,9 @@ void run(routine rr) {
|
|||
size_t& pc = running_at(rr);
|
||||
// Running one instruction.
|
||||
if (instructions[pc].is_label) { ++pc; continue; }
|
||||
//? cout << "AAA " << Trace_stream << " ^" << Trace_stream->dump_layer << "$\n"; //? 1
|
||||
trace("run") << "instruction " << recipe_name(rr) << '/' << pc;
|
||||
//? cout << instructions[pc].operation << '\n'; //? 1
|
||||
//? cout << "operation " << instructions[pc].operation << '\n'; //? 3
|
||||
switch (instructions[pc].operation) {
|
||||
// Primitive Recipe Implementations.
|
||||
case COPY: {
|
||||
|
@ -88,6 +89,9 @@ if (argc > 1) {
|
|||
fin.close();
|
||||
}
|
||||
|
||||
Trace_stream = new trace_stream;
|
||||
//? Trace_stream->dump_layer = "all"; //? 1
|
||||
transform_all();
|
||||
recipe_number r = Recipe_number[string("main")];
|
||||
if (r) run(r);
|
||||
dump_memory();
|
||||
|
|
|
@ -47,7 +47,7 @@ void transform_names(const recipe_number r) {
|
|||
}
|
||||
for (size_t out = 0; out < inst.products.size(); ++out) {
|
||||
if (is_raw(inst.products[out])) continue;
|
||||
//? cout << "product " << out << '/' << inst.products.size() << " " << inst.products[out].name << '\n'; //? 3
|
||||
//? cout << "product " << out << '/' << inst.products.size() << " " << inst.products[out].name << '\n'; //? 4
|
||||
//? cout << inst.products[out].types[0] << '\n'; //? 1
|
||||
if (inst.products[out].name == "default-space")
|
||||
inst.products[out].initialized = true;
|
||||
|
|
36
cpp/core.mu
Normal file
36
cpp/core.mu
Normal file
|
@ -0,0 +1,36 @@
|
|||
recipe string-equal [
|
||||
default-space:address:space <- new location:type, 30:literal
|
||||
a:address:array:character <- next-ingredient
|
||||
a-len:integer <- length a:address:array:character/deref
|
||||
b:address:array:character <- next-ingredient
|
||||
b-len:integer <- length b:address:array:character/deref
|
||||
# compare lengths
|
||||
{
|
||||
length-equal?:boolean <- equal a-len:integer, b-len:integer
|
||||
break-if length-equal?:boolean
|
||||
reply 0:literal
|
||||
}
|
||||
# compare each corresponding character
|
||||
i:integer <- copy 0:literal
|
||||
{
|
||||
done?:boolean <- greater-or-equal i:integer, a-len:integer
|
||||
break-if done?:boolean
|
||||
a2:character <- index a:address:array:character/deref, i:integer
|
||||
b2:character <- index b:address:array:character/deref, i:integer
|
||||
{
|
||||
chars-match?:boolean <- equal a2:character, b2:character
|
||||
break-if chars-match?:boolean
|
||||
reply 0:literal
|
||||
}
|
||||
i:integer <- add i:integer, 1:literal
|
||||
loop
|
||||
}
|
||||
reply 1:literal
|
||||
]
|
||||
|
||||
recipe main [
|
||||
default-space:address:space <- new location:type, 30:literal
|
||||
x:address:array:character <- new [abc]
|
||||
y:address:array:character <- new [abd]
|
||||
3:boolean/raw <- string-equal x:address:array:character, y:address:array:character
|
||||
]
|
Loading…
Reference in New Issue
Block a user