Comments (1)
This is so cool, good job. about the step run, I'll add some debug utility in future, but I can't sure when.if you required this function right now,you can simple change source code of lemon, here is a quick demo patch.this may need some test, but enough for your test.
diff --git a/src/machine.c b/src/machine.c
index c6b8d54..4b7726e 100644
--- a/src/machine.c
+++ b/src/machine.c
@@ -1278,6 +1278,13 @@ lemon_machine_execute_loop(struct lemon *lemon)
CHECK_PAUSE(lemon->l_nil);
}
while (!machine->halt && machine->pc < machine->maxpc) {
+
+ if (machine->step >= 0) {
+ if (machine->step-- == 0) {
+ machine->step = 10;
+ return lemon->l_nil;
+ }
+ }
opcode = machine->code[machine->pc++];
switch (opcode) {
diff --git a/src/machine.h b/src/machine.h
index 9f1c8e6..61ed5c7 100644
--- a/src/machine.h
+++ b/src/machine.h
@@ -11,6 +11,7 @@ struct machine {
int fp; /* frame pointer */
int sp; /* stack pointer */
+ int step;
int halt;
int maxpc;
diff --git a/src/main.c b/src/main.c
index 23ea8f4..8b961e0 100644
--- a/src/main.c
+++ b/src/main.c
@@ -1,5 +1,6 @@
#include "lemon.h"
#include "shell.h"
+#include "machine.h"
#include "larray.h"
#include "lstring.h"
#include "lib/builtin.h"
@@ -70,7 +71,15 @@ main(int argc, char *argv[])
}
lemon_machine_reset(lemon);
- lemon_machine_execute(lemon);
+ struct machine *machine = lemon->l_machine;
+ machine->step = 10; // -1 for non-stop run
+ for (;;) {
+ printf("pc: %d\n", machine->pc);
+ lemon_machine_execute_loop(lemon);
+ if (machine->pc >= machine->maxpc) {
+ break;
+ }
+ }
}
lemon_destroy(lemon);
from lemon.
Related Issues (20)
- Almost a JS HOT 3
- A naive correction for ltype.c casting HOT 2
- Building on Windows? HOT 1
- Documentation needed! HOT 2
- How to build on Android using clang? HOT 1
- history support HOT 1
- possible bug in os.open('file','r') and os.open('file','w') HOT 3
- Can lemon run on a linux? HOT 1
- file io examples HOT 1
- network io support ? HOT 1
- Where is codegen and gcc implemented?
- delete this HOT 6
- Using the return value from snprintf without proper checks can cause overflow.
- Unbounded write by strcpy
- Uncontrolled process operation HOT 1
- Unbounded write operation
- Inconsistent null checks
- Hello, this is an amazing project, why did it stop developing?
- Possible bug inside lexer.c? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from lemon.