WhiZard wrote...
FunkySwerve wrote...
It smacks of conspiracy theorizing. '>
Theorizing, yes. Conspiracy, well I'll just repeat '>.
I am not saying all bit shifts just the bit shifts performed on characters. For example ALT + 0255 character might left shift to a ALT + 0254 character.
Still not really understanding what you're saying in the slightest. Earlier you said:
Given the lyceum examples are all for one byte, it could be that what is being reported for >> and >>> could be for "char" and not "int".
I don't see anything about bit shifts on characters there, or anywhere else in this thread. You've totally lost me. If bit shifts were somehow casting their results into an 8-bit datatype at any stage, you couldn't do what I did in the function on the previous page - data loss would produce wildly distorted results. I really have no idea what you're suggesting anymore. Is anyone else able to understand what WhiZard is suggesting?
Funky
I am saying there might be two different shifts for each bit shift symbol (>>, >>>, <<) one that will work for characters and one that will work for integers. The result for integers may have been an afterthought, with the intended behavior provided for the use on characters. Hope that helps. And, yes, I am in far off speculation stage.
To clear things up a little bit -
There are several fundamental data types supported by the script environment at the lowest levels (runtime and compiler). They are:
- A signed 32-bit integer ('int' in the script compiler).
- A 32-bit IEEE float ('float' in the script compiler).
- A character string ('string' in the script compiler). String typed values can only be initialized to a default value, string literal, concatenated (operator +), copied, or compared for equality with other string typed values.
- A void type for declaring functions with no return value only ('void' in the script compiler).
- A 32-bit object id ('object') in the script compiler, for which two manifest constants (OBJECT_INVALID and OBJECT_SELF) exist in the runtime and the compiler, plus whatever other arbitrary values the script host program defines. Object typed values can only be initialized to a default value (or two manifest constant values), copied, and compared for equality with other values of type object.
- The 'vector' type, which is internally treated as a structure aggregating three floats. The runtime is only minimally aware of 'vector' in the sense that there is an instruction type to operate on groups of three floats on the stack. The compiler treats the 'vector' type as a predefined struct with three float members (x, y, z), and some additional initializer syntax support and operator support (generally the same operators afforded to 'float' types).
- Various 'engine structure' types, such as 'talent', 'effect', and so forth. These are opaque handles to data structures defined by the script host program and can only be initialized to a default value, copied, and compared for equality with engine structure types of the same family.
- The 'action' type, which is not really a data type per se, but an indicator to the compiler that it must emit a special instruction causing the runtime to fork off a copy of the script program's state for deferred execution (i.e. the creation of a 'script situation'). The 'action' pseudo-type cannot be used outside of the declaration of an engine function which may only be performed in nwscript.nss.
Structures can be aggregates of all of the above except 'void' and 'action'; structures are always passed by value and are logically just shorthand for copying multiple variables at once. The standard compiler does not correctly support nested structures. The runtime is only minimally aware of structures in that there is an instruction to copy multiple values on the stack, and an instruction to compare multiple values on the stack.
There is no 8-bit integral type implemented natively.
The standard compiler does not support any C preprocessor constructs and has no notion of pragmas or similar directives.
The Advanced Script Compiler (in extensions mode or when used with virusman's toolset plugin) supports a limited preprocessor language that is a subset of the C preprocessor language, including a pragma directive and very basic ifdef support. Additionally, in extensions mode, nested structures are supported correctly.
On top of the support outlined above, a script host program (such as NWN1 or NWN2, or other NWScript-derived games) can provide additional services in the form of engine functions - for example, engine functions to return the length of a string type, to create a substring derived from an existing string type, to print a string to a log file, etc. The compiler and runtime environment are structured to be agnostic of the nature of these additional 'engine function' services, other than providing a generic mechanism to allow extended functionality to be implemented by the script host program and then called upon by script.
I do feel compelled to point out that for all of the features that one would have liked NWScript to have, the design was well architected on the whole. Remember that at the time, there was no CLR or .NET easily accessible for embedding - compared to previous games with cumbersome and highly implementation specific scripting systems (or source-text based interpreters), NWScript was a significant leap forward - the actual script compiler and execution environment are well isolated from the implementation details of the game in a way that makes it easily portable to other games, and a number of powerful constructs are exposed to script in relatively simple and elegant ways (such as deferring execution with 'action' functions).
While the implementation has left things to be desired at times, the number of different games that have used NWScript in a way that have essentially left the core compiler and runtime environment completely untouched are a solid testament to the design forethought put in to the scripting system.
Modifié par SkywingvL, 20 novembre 2011 - 06:58 .