[Mono-list] mcs compilation of xsp.exe is a little strange...

Francisco Figueiredo Jr. fxjrlists@yahoo.com.br
Sun, 28 Jul 2002 04:05:55 -0300 (ART)

Hi all,

I just started to play with xsp. Got the cvs code and
tried some aspx coding.

I tried this simple .aspx page :)


But when I run it with xsp.exe I got an ArgumentNull
exception in the Tag constructor.

After some digging, I could see that Tag was being
constructed in the ASPParser.get_tag() method inside
the case switch case Token.IDENTIFIER.

After some more digging, and almost getting crazy
because my Console.WriteLine() calls wasn't appearing
I had no choice but to check what was inside the il :)

Looking at it I could see that some code wasn't there!
More exactly the line that says:
id = tokenizer.value;
wasn't getting compiled. So, the Tag contructor was
getting a null value for its first argument. 
I could see that the code is compiled differently
depending if I let the line that constructs the Tag
object or not

As the code is a little big, I will put just the
discussion part:

Main switch statement in ASPParser.get_tag():

  IL_0035:  ldloc.0    // holds value of token
  IL_0036:  stloc.s    V_10 
  IL_0038:  ldloc.s    V_10  //switch (token)
  IL_003a:  ldc.i4.s   33
  IL_003c:  beq        IL_00f0 // case '%'
  IL_0041:  ldloc.s    V_10
  IL_0043:  ldc.i4.s   37
  IL_0045:  beq        IL_0064 // case '/'
  IL_004a:  ldloc.s    V_10
  IL_004c:  ldc.i4.s   47
  IL_004e:  beq        IL_00a0 // case '!'
  IL_0053:  ldloc.s    V_10
  IL_0055:  ldc.i4     0x3e8
  IL_005a:  beq        IL_0142 // case
  IL_005f:  br         IL_015a // default

and in the IL_0142...

if I let the line: 
Tag tag = new Tag(...);
I got the following...:

  IL_0142:  ldloc.1
  IL_0143:  ldarg.0
  IL_0144:  callvirt   instance class
  IL_0149:  ldarg.0
  IL_014a:  ldc.i4.s   47
  IL_014c:  callvirt   instance bool
  IL_0151:  newobj     instance void
  class Mono.ASP.TagAttributes,
  IL_0156:  stloc.s    V_9

and if I comment out the new Tag line:

  IL_0142:  ldstr      "token.Ident"
  IL_0147:  call       void
  IL_014c:  ldarg.0
  IL_014d:  ldfld      class Mono.ASP.AspTokenizer
  IL_0152:  callvirt   instance string
  IL_0157:  stloc.1
  IL_0158:  ldstr      "id: "
  IL_015d:  ldloc.1
  IL_015e:  call       string
  IL_0163:  call       void

I even can get my comments that wasn't there before!

As we can see from the second version, *there is* code
to store the return of tokenizer.value in the id local
variable (code IL_014c - IL_0157) as well the code to
call my Console.WriteLine and the constructor. In the
first version, there is the ldloc.1 as in the second
version, what means that, IMHO, mcs was forgetting to
put some code. 

Can someone confirm this??
I couldn't find anything about this possibly bug in
the bugzilla. 

I'm using mono runtime and mcs from the monobaselabs
rpm mono-0.12_baselabs-20020726.i386.rpm in a Linux
Mandrake 81 intel.

Thanks in advance and sorry for this length message :)

P.S.: Ah, I could get it working if I change the line:
Tag tag = new Tag(id, get_attributes (), eat ('/'));


Tag tag = new Tag(tokenizer.value, get_attributes (),
eat ('/'));

Francisco Figueiredo Jr.

Yahoo! PageBuilder
O super editor para criação de sites: é grátis, fácil e rápido.