Skip to content

Commit

Permalink
made tests with modifying lambdas on stack
Browse files Browse the repository at this point in the history
  • Loading branch information
Jakz committed Oct 25, 2018
1 parent 462226d commit f093776
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 3 deletions.
13 changes: 13 additions & 0 deletions src/defines.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,19 @@

#pragma once

/**************************
* CONFIG
**************************/

#define USE_PACKED_VALUES false






/**************************/

#include <stdlib.h>
#include <algorithm>

Expand Down
5 changes: 5 additions & 0 deletions src/instruction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1121,6 +1121,11 @@ void Instruction::execute(VM *vm) const
vv.push_back(v2);
vm->push(v1);
}
else if (v1.type == TYPE_LAMBDA)
{
Code* code = v1.lambda()->code();
vm->push(new Lambda(code->append(Instruction(v2))));
}
}
break;
}
Expand Down
2 changes: 1 addition & 1 deletion src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ int main (int argc, const char * argv[])
else if (input == "info")
{
cout << " arch: " << (sizeof(void*) == 4 ? "x86" : "x86-64") << endl;
cout << " size of value : " << sizeof(Value) << endl;
cout << " size of value : " << sizeof(Value) << (sizeof(Value) == sizeof(value_data) + sizeof(Type) ? " (packed)" : "") << endl;
cout << " size of instruction : " << sizeof(Instruction) << endl;
cout << " size of opcode : " << sizeof(Opcode) << endl;
}
Expand Down
4 changes: 4 additions & 0 deletions src/value.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,11 @@ union value_data
bool operator==(const value_data& o) const { return i == o.i; }
};

#if defined(USE_PACKED_VALUES) && USE_PACKED_VALUES
class __attribute__((packed)) Value final
#else
class Value final
#endif
{
public:
value_data data;
Expand Down
2 changes: 0 additions & 2 deletions src/vm.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,6 @@ class VM

void push(const Value& value)
{
std::string str = value.svalue();
std::cout << "pushing " << str << std::endl << std::flush;
valueStack->push_back(value);
}

Expand Down

0 comments on commit f093776

Please sign in to comment.