GithubHelp home page GithubHelp logo

Comments (19)

erkyrath avatar erkyrath commented on August 23, 2024 1

Yeesh:

Immediately following the property values table for a class (which is bound to be short, since it can only contain the short name and perhaps property 3) is a six-byte block of attributes which would be inherited from the class (*), and then a second property values table, specifying the properties which members of the class would inherit from it. (These values are accessed at run time to implement the superclass access operator :: when applied to a common property.)

(ITM 9.4)

This is six bytes of attributes even in V3.

from inform6.

erkyrath avatar erkyrath commented on August 23, 2024

I don't suppose you know what the 124 should be?

from inform6.

erkyrath avatar erkyrath commented on August 23, 2024

60, I think, but the formula needs to be tweaked anyhow. It relies on the fact that object addresses are always even in v4+, but in v3 they're not!

from inform6.

erkyrath avatar erkyrath commented on August 23, 2024

Pretty sure that line should be i = (i+60+cla*9)-->0; (This locates the property table block of the class object.)

However, the next line also needs to be changed:

i = CP__Tab(i + 2*(0->i) + 1, -1)+6;

...and at this point I am entirely unable to follow the logic. i + 2*(0->i) + 1 skips the property table header; CP__TAB(x, -1) then skips the property table body; what's six bytes after that? Someone else is going to have to take a look.

from inform6.

fredrikr avatar fredrikr commented on August 23, 2024

from inform6.

erkyrath avatar erkyrath commented on August 23, 2024

Okay, here's the upshot.

The correct code for veneer.c is:

             #IFV3;\
             i = (i+60+cla*9)-->0;\
             #IFNOT;\
             i = 0-->((i+124+cla*14)/2);\
             #ENDIF;\

However, this doesn't work unless you also replace CP__Tab(). The veneer's CP__Tab() assumes the v4+ property table layout.

A working implementation of CP__Tab() for v3... I'm pretty sure... is:

[ CP__Tab x id size;
	while (true) {
		size = x->0;
		if (size == 0) break;
		x++;
		if (id == (size & 31)) return x;
		x = x + (size/32)+1;
	}
	if (id<0) return x+1;
	rfalse;
];

from inform6.

erkyrath avatar erkyrath commented on August 23, 2024

So what to do? PunyInform already replaces a couple of veneer routines (CA__Pr(), Cl__Ms()). Seems like the options are:

  • Let Puny replace RA__Pr() and CP__Tab() as well.
  • Update RA__Pr() and CP__Tab() in veneer.c with #ifv3 sections.
  • Fix all four routines in veneer.c, so Puny doesn't have to.

I admit that I'm leaning towards the second option, even though it's inelegant.

(Also note that I haven't gone through the rest of RA__Pr() to see if there are other V4-isms in there.)

from inform6.

fredrikr avatar fredrikr commented on August 23, 2024

from inform6.

erkyrath avatar erkyrath commented on August 23, 2024

Okay, I'll wrap up a change for RA__Pr() and CP__Tab().

Puny's changes to CA__Pr and Cl__Ms are a bit of a hack, and cuts out features of Inform.

Yeah, that's the rub. (Specifically it drops the ability to pass multiple arguments on to a x.prop(...) call, because v3 can't count arguments in the same way later versions do. And it drops support for create/recreate/destroy/copy.)

What I think I want to do is add #ifv3; error; sections to those veneer routines. That way you'll get a sensible error message if you try to use them in v3, rather than a weird assembly error message. Puny won't be affected because it replaces them.

from inform6.

fredrikr avatar fredrikr commented on August 23, 2024

Ok, great.

I did have a thought while reading this code: Properties appear in descending order in the property list. Instead of checking if we've reached the value zero, could we check for any value lower than the property we're looking for? The .& operator is often used in both PunyInform and the standard library to test if an object provides a certain property, e.g. normally all present objects will be checked to see if they have a react_before routine every move. This could be a welcome optimization, unless the check turns out to actually slow things down.

Blocking attempts to create, destroy etc with a sensible error message: Perfect.

As for calling property routines in z3: Wouldn't it be worthwile to allow it for 0 or 1 argument, and document the limitation? Puny replaces this routine out of necessity. Replacing it means it doesn't benefit from bug fixes and enhancements in the compiler, unless we notice them.

from inform6.

fredrikr avatar fredrikr commented on August 23, 2024

I edited my last comment. I meant to say .& is often used to check if an object provides a certain property. CP__Tab could probably be made more efficient.

Hm, odd, looking at CP__Tab now, it doesn't look like it's meant to handle v3 games at all. But we haven't had any problems with it.

from inform6.

erkyrath avatar erkyrath commented on August 23, 2024

CP__Tab() is only called from RA__Pr(). It's not used in normal property lookup.

I am not going to worry about optimizing CP__Tab(). That's not part of this task and I don't really want to rely on Inform's ordering of properties.

from inform6.

fredrikr avatar fredrikr commented on August 23, 2024

from inform6.

erkyrath avatar erkyrath commented on August 23, 2024

Whoops, you're right. I was thinking of the individual property table, which is unsorted (and not part of the Z-spec).

from inform6.

fredrikr avatar fredrikr commented on August 23, 2024

I tested the changes to RA__Pr and CP__Tab, and they seem to work fine.

I just discovered that RL__Pr is broken for z3 as well. Should I create a new ticket for that?

from inform6.

erkyrath avatar erkyrath commented on August 23, 2024

Let's wrap it up into this one, since it's part of the same problem.

I thought indiv properties used the same layout on z3 and z5, though? It seems like this case would have already been tested.

from inform6.

fredrikr avatar fredrikr commented on August 23, 2024

RL__Pr is used for common properties in a superclass as well.

This kludge makes it work for common properties in superclass:

[ RL__Pr obj identifier x;
 if (identifier<64 && identifier>0) {
	!return obj.#identifier;
	@get_prop_addr obj identifier -> x;
	@get_prop_len x -> sp;
	@ret_popped;
 }
 x = obj..&identifier;
 if (x==0) rfalse;
 #IFV3;
 return 1 + ((x-1)->0) / 32;
 #IFNOT;
 if (identifier&$C000==$4000)
	 switch (((x-1)->0)&$C0)
	 {    0: return 1;  
		$40: return 2;  
		$80: return ((x-1)->0)&$3F; 
	 }
 return (x-1)->0;
 #ENDIF;	 
];

from inform6.

erkyrath avatar erkyrath commented on August 23, 2024

Are you talking about an expression like obj.#cla::prop ?

from inform6.

erkyrath avatar erkyrath commented on August 23, 2024

Actually, I changed my mind. I don't understand the exact issue here. Please file a separate ticket for RL__Pr(). We can let #217 go in as it is while I figure out what's going on with RL__Pr().

from inform6.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.