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

Add SFall arrays and patry_member_list opcodes #269

Merged
merged 89 commits into from
May 30, 2023

Conversation

roginvs
Copy link
Contributor

@roginvs roginvs commented Apr 24, 2023

This PR adds support for SFall arrays. Opcodes:

  • CreateArray
  • SetArray
  • GetArray
  • FreeArray
  • LenArray
  • ResizeArray
  • TempArray
  • FixArray
  • StringSplit
  • ScanArray
  • Substr
  • TypeOf
  • GetArrayKey
  • StackArray
  • PartyMemberList

Tested using this script https://gist.github.com/phobos2077/6bf357c49caaf515371a13f9a2d74a41 (except loading and saving which are not implemented in this PR)

Need review regarding C++ related stuff

Related to #29

@roginvs roginvs changed the title [Draft] Add SFall arrays and patry_member_list opcode Add SFall arrays and patry_member_list opcode May 15, 2023
@roginvs roginvs changed the title Add SFall arrays and patry_member_list opcode Add SFall arrays and patry_member_list opcodes May 15, 2023
@alexbatalov
Copy link
Owner

Hey, I've updated some of your code. Please review and if you're ok with this, let's move on.

Copy link
Contributor Author

@roginvs roginvs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, ok, looks good for me!

PS: I prefer to throw if something unexpected happens, for example unexpected enum value inside switch statement. It is better to identify error earlier that later. On the other hand a smart compiler should warn if switch statement did not check all enum values, is not it?

ProgramValue GetArrayKey(ArrayId arrayId, int index, Program* program)
{
auto arr = get_array_by_id(arrayId);
if (arr == nullptr) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As far as I know build-in pointer-to-bool conversion works exactly this way. Just a matter of style

}
}

std::vector<KeyValuePair> pairs;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LOL no map for assoc arrays. I think it is fine if we know that arrays are usually small (for example less than 100 or 1000 items). Anyway I do not see any problem here

@alexbatalov alexbatalov merged commit fe0d767 into alexbatalov:main May 30, 2023
9 checks passed
@alexbatalov
Copy link
Owner

Adds many functions towards #200

@phobos2077
Copy link
Contributor

I don't think the original Olympus uses any of advanced sfall features (you probably tested on of those "fixed" versions)? Anyway, great to see we are one step closer to sfall compatibility. Next step: global scripts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants