Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

multiple copies of objects #4

Open
dlech opened this issue May 9, 2019 · 0 comments
Open

multiple copies of objects #4

dlech opened this issue May 9, 2019 · 0 comments

Comments

@dlech
Copy link
Member

dlech commented May 9, 2019

The EV3 VM can only run one copy of each bytecode object (vmthread/block/subcall) because of the way the local variables are allocated. However, you can emit multiple object headers that point to the same instructions to duplicate an object.

Currently, there is a compiler "optimization" that detects duplicate objects. However, it would be nice to be able to write an object once in the assembly code instead of multiple times.

We will need to come up with a syntax for this. For example, we could use the common array notation:

// declare a subroutine with two instances
subcall MySub[2] {
    // do suff
}

vmthread Thread1 {
    // call the first instance
    CALL(MySub[0])
}

vmthread Thread2 {
    // call the second instance
    CALL(MySub[1])
}

vmthread Thread2 {
    // compiler error: missing index
    CALL(MySub)
}

vmthread Thread2 {
    // compiler error: index out of range
    CALL(MySub[3])
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant