Comments (12)
C0 C0 FF EE # magic number
00 17 # version 11, arch = 1 (64 bits)
00 00 # int pool count
# int pool
00 18 # string pool total size
# string pool
20 69 73 20 74 68 65 20 66 61 63 74 6F 72 69 61 6C 20 6F 66 20 31 35 00 # " is the factorial of 15"
00 02 # function count
# function_pool
#<main>
00 # number of arguments = 0
00 # number of local variables = 0
00 13 # code length = 19 bytes
10 0F # bipush 15 # 15
B8 00 01 # invokestatic 1 # factorial(15)
B7 00 00 # invokenative 0 # printint(factorial(15))
57 # pop # (ignore result)
14 00 00 # aldc 0 # s[0] = " is the factorial of 15"
B7 00 01 # invokenative 1 # println(" is the factorial of 15")
57 # pop # (ignore result)
10 00 # bipush 0 # 0
B0 # return #
#<factorial>
01 # number of arguments = 1
01 # number of local variables = 1
00 1B # code length = 27 bytes
15 00 # vload 0 # n
10 00 # bipush 0 # 0
9F 00 06 # if_cmpeq +6 # if (n == 0) goto <00:cond_true>
A7 00 08 # goto +8 # goto <01:cond_false>
# <00:cond_true>
10 01 # bipush 1 # 1
A7 00 0E # goto +14 # goto <02:cond_end>
# <01:cond_false>
15 00 # vload 0 # n
15 00 # vload 0 # n
10 01 # bipush 1 # 1
64 # isub # (n - 1)
B8 00 01 # invokestatic 1 # factorial((n - 1))
68 # imul # (n * factorial((n - 1)))
# <02:cond_end>
B0 # return #
00 02 # native count
# native pool
00 01 00 09 # printint
00 01 00 0A # println
from c0vm-ts.
Received! I'll dig into it tonight.
from c0vm-ts.
This seems like a browser-dependent problem. I've tried to run this byte code on Firefox and Chrome and the error didn't pop out.
from c0vm-ts.
Yes, Chrome seems to work. I guess warn off testers from using Safari for now haha.
Also, very cool project, will give more feedback now that I can use it.
from c0vm-ts.
That's weird... I've tried this in Safari on my MacBook, but failed to reproduce this problem.
Could you open the console after this error occurs and take a screen shot? The call stack will be dumped in console in debug mode.
from c0vm-ts.
btw, glad to hear that you enjoy this project
from c0vm-ts.
Hm, for some reason, it's empty for me. (I'm assuming you mean Console in Web Inspector).
And just to double check, the website URL I'm using is https://markchenyutian.github.io/C0VM-ts/build/
Edit: And I also enabled Compiler Option -d
for debug
from c0vm-ts.
Yes, I mean the console in inspector and the URL is correct. Sadly, this indicates that the error was caught silently.
However, after inspecting the source code & minimized JS, I suspect the error comes from
export function isNullPtr(ptr: C0Pointer): boolean {
return ptr.getBigUint64(0) === BigInt(0);
}
in src/utility/pointer_utility.ts
.
I've add a try ... catch ...
on it to log the e
when error occurs and update the website now, could you re-run the program and see if anything got logged in the console? (note: the version number on left corner should now be v0.2.6-alpha
)
from c0vm-ts.
Great. Here's my console output. I've created a video since it gets nested. Feel free to pause whenever to get the info you want.
Screen Recording 2022-08-22 at 10.11.08 PM.mov.zip
from c0vm-ts.
Thanks for the screen recording.
Turns out this is a problem with Safari's support to bigint
(a.k.a. long
in C
).
A similar complain is found in This issue. I'll fix this problem by changing getBigUint64(0)
to getUint32(0) === 0 && getUint32(4) === 0
.
from c0vm-ts.
Could you try again to run the program? Just to make sure the fix being applied do work.
from c0vm-ts.
Yep, looks good now!
from c0vm-ts.
Related Issues (20)
- Nested structs are not well supported HOT 2
- Remove StructuredClone dependency
- [Feature] Support object file (.o0 file)
- [Feature] Friendly Error Message HOT 3
- Rename tab not intuitive (UI improvement) HOT 1
- Drag and drop not working HOT 7
- [Feature] Shortcut key for Run/Step
- [Bug Report] Breakpoints are missing when switching between C0 and BC0 mode of the editor HOT 1
- [Feature] Import C0 source code Folder (C0 Project)
- [Feature] Replace breakpoint 🔴 emoji into CSS-styled HTML Element
- Unexpected type error when dereferencing Null pointer HOT 1
- [Bug Report] Editor Tab Name not updated properly HOT 5
- [Bug Report] Incorrect Variable Name
- Display Operand Stack [Feature] HOT 2
- Type Inference with recursive function [Bug Report]
- [Bug Report] Not Compatible with WeChat Browser HOT 3
- [Bug Report] Step Does Not Validate Modified C0 File HOT 1
- [Bug Report] parse_ints function not working as expected in native libraray parse HOT 3
- Struct fields don't appear until assignment HOT 6
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 c0vm-ts.