kjs: variables with/without var [PATCH]

Maciej Stachowiak mjs at apple.com
Sat Jan 18 22:34:19 GMT 2003


On Saturday, January 18, 2003, at 11:38  AM, David Faure wrote:

>
> Ouch, it seems the var was put in the wrong global object....
> (the one of the calling interpreter, i.e. the frameset, instead of the
> one of the frame .... and since the frameset's globalobject isn't in 
> the
> scope chain, the alert() can't find the value of 'myvar').
>
> Hmm, I'm afraid I don't see how putValue() could know the right
> globalobject to use..... or is that 
> exec->context().imp()->variableObject() ?

variableObject is not the nearest global object, it's the pseudo-object 
for the function's local scope. I'm pretty sure that without `var' you 
should be setting a global variable. The kjs in Safari (based on 3.0.x) 
is putting things in the global object in this case, and the original 
posted example works fine with the "var" removed, which makes me doubt 
there is anything wrong with the globalObject() call.

  - Maciej

>
> Index: internal.cpp
> ===================================================================
> RCS file: /home/kde/kdelibs/kjs/internal.cpp,v
> retrieving revision 1.141
> diff -u -p -r1.141 internal.cpp
> - --- internal.cpp        16 Jan 2003 23:30:52 -0000      1.141
> +++ internal.cpp        18 Jan 2003 19:36:59 -0000
> @@ -256,7 +256,7 @@ void Reference2::putValue(ExecState *exe
>                    propertyName()).cstring().c_str(), w);
>  #endif
>    if (bs.type() == NullType)
> - -    exec->interpreter()->globalObject().put(exec, propertyName(), 
> w);
> +    exec->context().imp()->variableObject().put(exec, propertyName(), 
> w);
>    else
>      static_cast<ObjectImp*>(bs.imp())->put(exec, propertyName(), w);
>  }
>
> - --
> David Faure -- faure at kde.org, dfaure at klaralvdalens-datakonsult.se
> Klarälvdalens Datakonsult AB, Platform-independent software solutions
> Contributing to: http://www.konqueror.org/, http://www.koffice.org/
> KOffice-1.2.1 is available - 
> http://download.kde.org/stable/koffice-1.2.1/
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.0.7 (GNU/Linux)
>
> iD8DBQE+Ka1R72KcVAmwbhARAuHPAJ9RGLKlKcesw++pTbPea6zhi7StrwCgrkMj
> aSWNer/ool/0M58FBtUcM1U=
> =LeY6
> -----END PGP SIGNATURE-----
>





More information about the kfm-devel mailing list