protected static bool Apply( ref Tflag flags, Opcode code ) { if( code.Kind() == Opkind.Access ) { if( code == Opcode.Internal ) { flags |= Tflag.Internal; } else { flags = ((Tflag)(unchecked((byte)code) & 3)) | (flags & (~((Tflag)3))); } return true; } if( code.Kind() == Opkind.Scope ) { if( ((code == Opcode.Readonly) && (flags.Scope() == Tflag.Static)) || ((code == Opcode.Static) && (flags.Scope() == Tflag.Readonly)) ) { flags = Tflag.Rostatic | (flags & (~Tflag.Scope)); } else { flags = ((Tflag)((unchecked((byte)code) & 7) << 4)) | (flags & (~Tflag.Scope)); } return true; } if( code == Opcode.Partial ) { flags |= Tflag.Partial; return true; } if( code == Opcode.Unsafe ) { flags |= Tflag.Unsafe; return true; } return false; }//Apply
}//Classes protected virtual bool Members( string className, Opcode classType, Tflag classFlags, Flag flags ) { if( !Eol ) { throw new ParseError( this, "Unexpected input in class declaration" ); } if( NextLine().Indent < Pindent ) { return false; } if( classFlags.Scope() == Tflag.Static ) { flags |= Flag.Static; } var one = (flags & Flag.Single) != 0; flags &= ~Flag.Single; var was = false; var ppind = Pindent; var lflags = Tflag.None; int saveAt; do { saveAt = At; Pindent = Indent; var tflags = Tflag.None; var isvar = false; while( Apply( ref tflags, Opcode ) ) { if( (Opcode == Opcode.Readonly) || (Opcode == Opcode.Const) ) { isvar = true; } Next( isvar ); } if( !isvar ) { if( Curr == ':' ) { if( tflags == Tflag.None ) { throw new ParseError( this, "Unexpected ':' in class body" ); } Next(); lflags = tflags; continue; } if( (((unchecked((byte)Opcode) == unchecked((byte)Opcode.Class)) || (Opcode == Opcode.Face)) || (Opcode == Opcode.Struct)) || (Opcode == Opcode.Enum) ) { Pindent = ppind; if( At != saveAt ) { End = saveAt; Next(); } if( !Classes( flags, lflags ) ) { throw new ParseError( this, "Expected class declaration" ); } was = true; continue; } } if( tflags == Tflag.None ) { tflags = lflags; } else { if( tflags.Access() == Tflag.None ) { tflags = (tflags & (~Tflag.Access)) | lflags.Access(); } if( tflags.Scope() == Tflag.None ) { tflags = (tflags & (~Tflag.Scope)) | lflags.Scope(); } } int mark; var name = Word; if( (isvar || (Opcode == Opcode.Var)) || (Opcode == Opcode.Event) ) { var evt = (!isvar) && (Opcode == Opcode.Event); if( !isvar ) { Next( true ); while( Apply( ref tflags, Opcode ) ) { Next( true ); } } name = Word; if( name == null ) { throw new ParseError( this, "Expected field name" ); } mark = Cgen.FieldStart( name ); Next(); while( Apply( ref tflags, Opcode ) ) { Next(); } OptType( flags ); OptExpr( flags ); while( Apply( ref tflags, Opcode ) ) { Next(); } Cgen.FieldEnd( mark, name, evt ? Opcode.Event : Opcode.Field, tflags ); if( !Eof ) { if( !Eol ) { throw new ParseError( this, "Unexpected input in class body" ); } NextLine(); } } else { if( Curr == '.' ) { if( Next().Word == null ) { throw new ParseError( this, "Unexpected 'ctor' or 'new' after '.'" ); } name = "." + Word; } if( name == null ) { throw new ParseError( this, "Unexpected input in class body" ); } mark = Cgen.FuncStart( name ); Next(); while( Apply( ref tflags, Opcode ) ) { Next(); } OptType( flags ); mark = Cgen.FuncTypeEnd( mark, name ); while( Apply( ref tflags, Opcode ) ) { Next(); } var argc = 0; var paren = Curr == '('; if( paren || (Curr == ',') ) { Next( true ); } while( (paren || (!Eol)) && (!Eof) ) { if( Word == null ) { throw new ParseError( this, "Expected argument name" ); } if( (!paren) && Apply( ref tflags, Opcode ) ) { Next(); while( Apply( ref tflags, Opcode ) ) { Next(); } break; } var argn = Word; var argm = Cgen.FuncArg( mark, name, argc, argn ); Next(); OptType( flags ); argm = Cgen.FuncArgDef( mark, argm, name, argc, argn ); OptExpr( flags ); Cgen.FuncArgEnd( mark, argm, name, argc++, argn ); if( paren && (Curr == ')') ) { Next(); break; } if( Curr == ',' ) { Next( true ); } } while( Apply( ref tflags, Opcode ) ) { Next(); } mark = Cgen.FuncBody( mark, name, argc, tflags ); Block( flags | Flag.Nosize ); Cgen.FuncEnd( mark, name ); } } while( ((!Eof) && (Indent > ppind)) && (!one) ); Pindent = ppind; return was; }//Members