@@ -379,7 +379,13 @@ module internal LexerStateEncoding =
379379
380380let bitOfBool b = if bthen 1 else 0
381381let boolOfBit n = ( n= 1 L)
382-
382+
383+ let inline colorStateOfLexState ( state : FSharpTokenizerLexState ) =
384+ enum < FSharpTokenizerColorState> ( int32(( state&&& lexstateMask) >>> lexstateStart))
385+
386+ let inline lexStateOfColorState ( state : FSharpTokenizerColorState ) =
387+ ( int64 state<<< lexstateStart) &&& lexstateMask
388+
383389let encodeLexCont ( colorState : FSharpTokenizerColorState ) ncomments ( b : pos ) ifdefStack light =
384390let mutable ifdefStackCount = 0
385391let mutable ifdefStackBits = 0
@@ -390,8 +396,7 @@ module internal LexerStateEncoding =
390396 ifdefStackBits<- ( ifdefStackBits||| ( 1 <<< ifdefStackCount))
391397 ifdefStackCount<- ifdefStackCount+ 1
392398
393- let lexstate = int64 colorState
394- (( lexstate<<< lexstateStart) &&& lexstateMask)
399+ lexStateOfColorState colorState
395400||| (( ncomments<<< ncommentsStart) &&& ncommentsMask)
396401||| (( resize32 b.Encoding<<< startPosStart) &&& startPosMask)
397402||| (( resize32( bitOfBool light) <<< hardwhitePosStart) &&& hardwhitePosMask)
@@ -408,7 +413,7 @@ module internal LexerStateEncoding =
408413let mask = 1 <<< bit
409414let ifDef = ( if ifdefStack&&& mask= 0 then IfDefIfelse IfDefElse)
410415 ifDefs<- ( ifDef, range0):: ifDefs
411- enum < FSharpTokenizerColorState > ( int32 (( state&&& lexstateMask ) >>> lexstateStart )) ,
416+ colorStateOfLexState state,
412417( int32) (( state&&& ncommentsMask) >>> ncommentsStart),
413418 pos.Decode( int32(( state&&& startPosMask) >>> startPosStart)),
414419 ifDefs,
@@ -740,16 +745,11 @@ type FSharpLineTokenizer(lexbuf: UnicodeLexing.Lexbuf,
740745
741746 tokenDataOption, lexintFinal
742747
743- static member ColorStateOfLexState ( lexState : FSharpTokenizerLexState ) =
744- let tag , _ncomments , _position , _ifdefStack , _lightSyntaxStatusInital = LexerStateEncoding.decodeLexCont lexState
745- tag
748+ static member ColorStateOfLexState ( lexState : FSharpTokenizerLexState ) =
749+ LexerStateEncoding.colorStateOfLexState lexState
746750
747- static member LexStateOfColorState ( colorState : FSharpTokenizerColorState ) =
748- let ncomments = 0 L
749- let position = pos0
750- let ifdefStack = []
751- let light = true
752- LexerStateEncoding.encodeLexCont colorState ncomments position ifdefStack light
751+ static member LexStateOfColorState ( colorState : FSharpTokenizerColorState ) =
752+ LexerStateEncoding.lexStateOfColorState colorState
753753
754754[<Sealed>]
755755type FSharpSourceTokenizer ( defineConstants : string list , filename :Option < string >) =