You are reading a single comment by @Gordon and its replies. Click here to read the full conversation.
  • And then...

    Byte Name STRING STR_EXT NAME_STR NAME_INT INT DOUBLE OBJ/FUNC/ARRAY ARRAYBUFFER FLAT_STR NATIVE_FUNC
    0 - 3 varData data data data data data data nativePtr size size nativePtr
    4 - 5 next - data next next - data format - argTypes
    6 - 7 prev - data prev prev - data format - -
    8 - 9 refs refs data refs refs refs refs refs refs refs
    10-11 first - data child child - - first stringPtr -
    12-13 last nextPtr nextPtr nextPtr - - r? last - nextPtr
    14-15 Flags Flags Flags Flags Flags Flags Flags Flags Flags Flags

    I saw it already last week, but I can not tell the difference among NAME, INT, NAME_INT, NAME_INT_INT? also STRING and STR_EXT.

    You'd have to look further into the code - look at the comments here: https://github.com/espruino/Espruino/blo­b/master/src/jsutils.h#L254

    And in the table, what is the difference between “varData” and “data”, “nextPtr” and “next”?

    The 2nd column 'Name' is just the name of the field - it doesn't really mean anything other than being descriptive (and possibly the name of the variable)

    And what does the “child” means, it is firstChild?

    Some variable types have just a single child. See jsvHasSingleChild

    digitalWrite([A5,A6],0x11), I see the function about this is : https://github.com/espruino/Espruino/blo­b/4e9f34831ff9f200cc5e261c30a2af9f145b98­0c/src/jswrap_io.c#L233

    In the function, jsvLock(pinName) uses jsvGetAddressOf(pinName), and jsvGetAddressOf(pinName) just return &jsVars[ref-1]. Does it mean all variable are stored in jsVar[JSVAR_CACHE_SIZE], including local variable and global variable, like Serial1?

    Yes. jswrapper may 'make' the global variable if it doesn't already exist though.

    If it is, what is the function of the jsvSkipName(pinNamePtr). I see the definition of the jsvSkipName(), It is : https://github.com/espruino/Espruino/blo­b/4e9f34831ff9f200cc5e261c30a2af9f145b98­0c/src/jsvar.c#L1542

    I don’t understand that “if a is a name ” . What does “a name” mean?

    see 'lvalue' on wikipedia - a Name in Espruino is one of those - a variable that is a pointer to another. For instance in a = 1, 1 is not a name (it cannot be written) but a is. However, after assignment a will point to the value 1.

    What is the effect of the function indeed ?

    It skips the name. In the case above, 'jsvSkipName(a)' would skip over 'a' and return 1.

    And what is the relationship of JsExecIfo->root and jsVar[JSVAR_CACHE_SIZE]

    JsExecIfo->root is basically the value of the 'global' variable. jsVar[JSVAR_CACHE_SIZE] holds all variables, including 'global'.

About

Avatar for Gordon @Gordon started