2 // Mono::ILASM::ILParser
\r
4 // (C) Sergey Chaban (serge@wildwestsoftware.com)
\r
7 using System.Reflection;
\r
8 using System.Reflection.Emit;
\r
10 namespace Mono.ILASM {
\r
12 public class ILParser {
\r
14 private Method method;
\r
16 private InstrBase currentInstr;
\r
18 private CallingConventions currentCallConv;
\r
20 private TypeAttributes currentTypeAttrs;
\r
22 private Class currentClass;
\r
24 private CodeGen codegen;
\r
26 private string defaultAsmName = "output";
\r
29 public CodeGen CodeGen {
\r
39 /* ID - alpha-numeric identifier */
\r
42 /* QSTRING - quoted string */
\r
45 /* SQSTRING - single quoted string */
\r
48 /* INT32 - 32 bit integer */
\r
51 /* INT64 - 64 bit integer */
\r
54 /* FLOAT64 - floating point number */
\r
61 %token OPEN_BRACE "{"
\r
62 %token CLOSE_BRACE "}"
\r
63 %token OPEN_BRACKET "["
\r
64 %token CLOSE_BRACKET "]"
\r
65 %token OPEN_PARENS "("
\r
66 %token CLOSE_PARENS ")"
\r
69 %token DOUBLE_COLON "::"
\r
70 %token SEMICOLON ";"
\r
73 %token AMPERSAND "&"
\r
77 %token ELLIPSIS "..."
\r
86 /* INSTR_* instruction types */
\r
92 %token INSTR_BRTARGET
\r
100 %token INSTR_SWITCH
\r
110 /* Mechanically generated - DO NOT EDIT! */
\r
119 %token D_CAPABILITY
\r
129 %token D_ENTRYPOINT
\r
138 %token D_IMPLICITCOM
\r
144 %token D_MANIFESTRES
\r
151 %token D_ORIGINATOR
\r
157 %token D_PERMISSION
\r
158 %token D_PERMISSIONSET
\r
162 %token D_PUBLICKEYTOKEN
\r
179 %token K_IMPLICITCOM
\r
180 %token K_IMPLICITRES
\r
181 %token K_NOAPPDOMAIN
\r
205 %token K_RTSPECIALNAME
\r
206 %token K_SPECIALNAME
\r
208 %token K_FAMANDASSEM
\r
209 %token K_FAMORASSEM
\r
210 %token K_PRIVATESCOPE
\r
212 %token K_NOTSERIALIZED
\r
214 %token K_NOT_IN_GC_HEAP
\r
219 %token K_SEQUENTIAL
\r
224 %token K_SERIALIZABLE
\r
228 %token K_IMPLEMENTS
\r
233 %token K_UNMANAGEDEXP
\r
234 %token K_PINVOKEIMPL
\r
244 %token K_FORWARDREF
\r
246 %token K_INTERNALCALL
\r
247 %token K_SYNCHRONIZED
\r
248 %token K_NOINLINING
\r
289 %token K_USERDEFINED
\r
295 %token K_STREAMED_OBJECT
\r
296 %token K_STORED_OBJECT
\r
297 %token K_BLOB_OBJECT
\r
308 %token K_FROMUNMANAGED
\r
309 %token K_CALLMOSTDERIVED
\r
325 %token K_PERMITONLY
\r
327 %token K_INHERITCHECK
\r
331 %token K_PREJITGRANT
\r
332 %token K_PREJITDENY
\r
333 %token K_NONCASDEMAND
\r
334 %token K_NONCASLINKDEMAND
\r
335 %token K_NONCASINHERITANCE
\r
337 %token K_NOMETADATA
\r
339 %token K_FULLORIGIN
\r
343 %token K_ENABLEJITTRACKING
\r
344 %token K_DISABLEJITOPTIMIZER
\r
345 %token K_PRESERVESIG
\r
346 %token K_BEFOREFIELDINIT
\r
350 %token K_COMPILERCONTROLLED
\r
358 /* end generated */
\r
371 decls : /* EMPTY */
\r
376 | nameSpaceHead OPEN_BRACE decls CLOSE_BRACE
\r
384 | assemblyHead OPEN_BRACE assemblyDecls CLOSE_BRACE
\r
385 | assemblyRefHead OPEN_BRACE assemblyRefDecls CLOSE_BRACE
\r
386 | comtypeHead OPEN_BRACE comtypeDecls CLOSE_BRACE
\r
387 | manifestResHead OPEN_BRACE manifestResDecls CLOSE_BRACE
\r
391 | D_SUBSYSTEM int32
\r
392 | D_CORFLAGS int32
\r
393 | D_FILE K_ALIGNMENT int32
\r
397 compQstring : QSTRING
\r
398 | compQstring PLUS QSTRING {$$ = ($1 as string) + ($3 as string);}
\r
401 languageDecl : D_LANGUAGE SQSTRING
\r
402 | D_LANGUAGE SQSTRING COMMA SQSTRING
\r
403 | D_LANGUAGE SQSTRING COMMA SQSTRING COMMA SQSTRING
\r
406 customAttrDecl : D_CUSTOM customType
\r
407 | D_CUSTOM customType ASSIGN compQstring
\r
408 | customHead bytes CLOSE_PARENS
\r
409 | D_CUSTOM OPEN_PARENS customType CLOSE_PARENS customType
\r
410 | D_CUSTOM OPEN_PARENS customType CLOSE_PARENS customType ASSIGN compQstring
\r
411 | customHeadWithOwner bytes CLOSE_PARENS
\r
414 moduleHead : D_MODULE
\r
416 | D_MODULE K_EXTERN name1
\r
419 vtfixupDecl : D_VTFIXUP OPEN_BRACKET int32 CLOSE_BRACKET vtfixupAttr K_AT id
\r
422 vtfixupAttr : /* EMPTY */
\r
423 | vtfixupAttr K_INT32
\r
424 | vtfixupAttr K_INT64
\r
425 | vtfixupAttr K_FROMUNMANAGED
\r
426 | vtfixupAttr K_CALLMOSTDERIVED
\r
429 vtableDecl : vtableHead bytes CLOSE_PARENS
\r
432 vtableHead : D_VTABLE ASSIGN OPEN_PARENS
\r
435 nameSpaceHead : D_NAMESPACE name1
\r
438 classHead : D_CLASS classAttr id extendsClause implClause
\r
440 currentTypeAttrs = 0;
\r
441 currentClass = new Class ($3 as string);
\r
442 currentClass.Attrs = currentTypeAttrs;
\r
444 // TODO: extends/implemets
\r
448 classAttr : /* EMPTY */
\r
449 | classAttr K_PUBLIC {currentTypeAttrs |= TypeAttributes.Public;}
\r
450 | classAttr K_PRIVATE {currentTypeAttrs &= ~TypeAttributes.Public;}
\r
451 | classAttr K_VALUE { /* FIXME */ }
\r
452 | classAttr K_ENUM { /* FIXME */ }
\r
453 | classAttr K_INTERFACE {currentTypeAttrs |= TypeAttributes.Interface;}
\r
454 | classAttr K_SEALED {currentTypeAttrs |= TypeAttributes.Sealed;}
\r
455 | classAttr K_ABSTRACT {currentTypeAttrs |= TypeAttributes.Abstract;}
\r
456 | classAttr K_AUTO {currentTypeAttrs |= TypeAttributes.AutoLayout;}
\r
457 | classAttr K_SEQUENTIAL {currentTypeAttrs |= TypeAttributes.SequentialLayout;}
\r
458 | classAttr K_EXPLICIT {currentTypeAttrs |= TypeAttributes.ExplicitLayout;}
\r
459 | classAttr K_ANSI {currentTypeAttrs |= TypeAttributes.AnsiClass;}
\r
460 | classAttr K_UNICODE {currentTypeAttrs |= TypeAttributes.UnicodeClass;}
\r
461 | classAttr K_AUTOCHAR {currentTypeAttrs |= TypeAttributes.AutoClass;}
\r
462 | classAttr K_IMPORT {currentTypeAttrs |= TypeAttributes.Import;}
\r
463 | classAttr K_SERIALIZABLE {currentTypeAttrs |= TypeAttributes.Serializable;}
\r
464 | classAttr K_NESTED K_PUBLIC {currentTypeAttrs |= TypeAttributes.NestedPublic;}
\r
465 | classAttr K_NESTED K_PRIVATE {currentTypeAttrs |= TypeAttributes.NestedPrivate;}
\r
466 | classAttr K_NESTED K_FAMILY {currentTypeAttrs |= TypeAttributes.NestedFamily;}
\r
467 | classAttr K_NESTED K_ASSEMBLY {currentTypeAttrs |= TypeAttributes.NestedAssembly;}
\r
468 | classAttr K_NESTED K_FAMANDASSEM {currentTypeAttrs |= TypeAttributes.NestedFamANDAssem;}
\r
469 | classAttr K_NESTED K_FAMORASSEM {currentTypeAttrs |= TypeAttributes.NestedFamORAssem;}
\r
470 | classAttr K_BEFOREFIELDINIT {currentTypeAttrs |= TypeAttributes.BeforeFieldInit;}
\r
471 | classAttr K_SPECIALNAME {currentTypeAttrs |= TypeAttributes.SpecialName;}
\r
472 | classAttr K_RTSPECIALNAME {currentTypeAttrs |= TypeAttributes.RTSpecialName;}
\r
475 extendsClause : /* EMPTY */
\r
476 | K_EXTENDS className
\r
479 implClause : /* EMPTY */
\r
480 | K_IMPLEMENTS classNames
\r
483 classNames : classNames COMMA className
\r
487 classDecls : /* EMPTY */
\r
488 | classDecls classDecl
\r
492 classAll : classHead OPEN_BRACE classDecls CLOSE_BRACE
\r
494 codegen.AddClass (currentClass);
\r
495 currentClass = null;
\r
500 classDecl : methodAll
\r
502 | eventHead OPEN_BRACE eventDecls CLOSE_BRACE
\r
503 | propHead OPEN_BRACE propDecls CLOSE_BRACE
\r
511 | exportHead OPEN_BRACE comtypeDecls CLOSE_BRACE
\r
512 | D_OVERRIDE typeSpec DOUBLE_COLON methodName K_WITH callConv type typeSpec DOUBLE_COLON methodName OPEN_PARENS sigArgs0 CLOSE_PARENS
\r
516 fieldDecl : D_FIELD repeatOpt fieldAttr type id atOpt initOpt
\r
520 atOpt : /* EMPTY */
\r
524 initOpt : /* EMPTY */
\r
525 | ASSIGN fieldInit
\r
528 repeatOpt : /* EMPTY */
\r
529 | OPEN_BRACKET int32 CLOSE_BRACKET
\r
532 customHead : D_CUSTOM customType ASSIGN OPEN_PARENS
\r
535 customHeadWithOwner : D_CUSTOM OPEN_PARENS customType CLOSE_PARENS customType ASSIGN OPEN_PARENS
\r
538 customType : typeSpec
\r
539 | callConv type typeSpec DOUBLE_COLON methodName OPEN_PARENS sigArgs0 CLOSE_PARENS
\r
540 | callConv type methodName OPEN_PARENS sigArgs0 CLOSE_PARENS
\r
543 eventHead : D_EVENT eventAttr typeSpec id
\r
544 | D_EVENT eventAttr id
\r
548 eventAttr : /* EMPTY */
\r
549 | eventAttr K_RTSPECIALNAME /**/
\r
550 | eventAttr K_SPECIALNAME
\r
553 eventDecls : /* EMPTY */
\r
554 | eventDecls eventDecl
\r
557 eventDecl : D_ADDON callConv type typeSpec DOUBLE_COLON methodName OPEN_PARENS sigArgs0 CLOSE_PARENS
\r
558 | D_ADDON callConv type methodName OPEN_PARENS sigArgs0 CLOSE_PARENS
\r
559 | D_REMOVEON callConv type typeSpec DOUBLE_COLON methodName OPEN_PARENS sigArgs0 CLOSE_PARENS
\r
560 | D_REMOVEON callConv type methodName OPEN_PARENS sigArgs0 CLOSE_PARENS
\r
561 | D_FIRE callConv type typeSpec DOUBLE_COLON methodName OPEN_PARENS sigArgs0 CLOSE_PARENS
\r
562 | D_FIRE callConv type methodName OPEN_PARENS sigArgs0 CLOSE_PARENS
\r
563 | D_OTHER callConv type typeSpec DOUBLE_COLON methodName OPEN_PARENS sigArgs0 CLOSE_PARENS
\r
564 | D_OTHER callConv type methodName OPEN_PARENS sigArgs0 CLOSE_PARENS
\r
570 propHead : D_PROPERTY propAttr callConv type id OPEN_PARENS sigArgs0 CLOSE_PARENS initOpt
\r
573 propAttr : /* EMPTY */
\r
574 | propAttr K_RTSPECIALNAME /**/
\r
575 | propAttr K_SPECIALNAME
\r
578 propDecls : /* EMPTY */
\r
579 | propDecls propDecl
\r
583 propDecl : D_SET callConv type typeSpec DOUBLE_COLON methodName OPEN_PARENS sigArgs0 CLOSE_PARENS
\r
584 | D_SET callConv type methodName OPEN_PARENS sigArgs0 CLOSE_PARENS
\r
585 | D_GET callConv type typeSpec DOUBLE_COLON methodName OPEN_PARENS sigArgs0 CLOSE_PARENS
\r
586 | D_GET callConv type methodName OPEN_PARENS sigArgs0 CLOSE_PARENS
\r
587 | D_OTHER callConv type typeSpec DOUBLE_COLON methodName OPEN_PARENS sigArgs0 CLOSE_PARENS
\r
588 | D_OTHER callConv type methodName OPEN_PARENS sigArgs0 CLOSE_PARENS
\r
595 methodHeadPart1 : D_METHOD
\r
597 method = new Method ();
\r
598 currentCallConv = 0; /*?*/
\r
602 methodHead : methodHeadPart1 methAttr callConv paramAttr type methodName OPEN_PARENS sigArgs0 CLOSE_PARENS implAttr OPEN_BRACE
\r
604 method.SetMethodName ($6 as MethodName);
\r
605 method.CallConv = currentCallConv;
\r
606 method.RetType = $5 as string;
\r
608 | methodHeadPart1 methAttr callConv paramAttr type K_MARSHAL OPEN_PARENS nativeType CLOSE_PARENS methodName OPEN_PARENS sigArgs0 CLOSE_PARENS implAttr OPEN_BRACE
\r
612 methodAll : methodHead methodDecls CLOSE_BRACE
\r
614 // Console.WriteLine (method);
\r
615 currentClass.AddMethod (method);
\r
620 methAttr : /* EMPTY */
\r
621 | methAttr K_STATIC {method.Attrs |= MethodAttributes.Static;}
\r
622 | methAttr K_PUBLIC {method.Attrs |= MethodAttributes.Public;}
\r
623 | methAttr K_PRIVATE {method.Attrs &= ~MethodAttributes.Public;}
\r
624 | methAttr K_FAMILY {method.Attrs |= MethodAttributes.Family;}
\r
625 | methAttr K_FINAL {method.Attrs |= MethodAttributes.Final;}
\r
626 | methAttr K_SPECIALNAME {method.Attrs |= MethodAttributes.SpecialName;}
\r
627 | methAttr K_VIRTUAL {method.Attrs |= MethodAttributes.Virtual;}
\r
628 | methAttr K_ABSTRACT {method.Attrs |= MethodAttributes.Abstract;}
\r
629 | methAttr K_ASSEMBLY {method.Attrs |= MethodAttributes.Assembly;}
\r
630 | methAttr K_FAMANDASSEM {method.Attrs |= MethodAttributes.FamANDAssem;}
\r
631 | methAttr K_FAMORASSEM {method.Attrs |= MethodAttributes.FamORAssem;}
\r
632 | methAttr K_COMPILERCONTROLLED {/* FIXME */}
\r
633 | methAttr K_HIDEBYSIG {method.Attrs |= MethodAttributes.HideBySig;}
\r
634 | methAttr K_NEWSLOT {method.Attrs |= MethodAttributes.NewSlot;}
\r
635 | methAttr K_RTSPECIALNAME /**/ {/* FIXME */}
\r
636 | methAttr K_UNMANAGEDEXP {method.Attrs |= MethodAttributes.UnmanagedExport;}
\r
637 | methAttr K_REQSECOBJ {method.Attrs |= MethodAttributes.RequireSecObject;}
\r
638 | methAttr K_PINVOKEIMPL OPEN_PARENS compQstring K_AS compQstring pinvAttr CLOSE_PARENS {/* FIXME */}
\r
639 | methAttr K_PINVOKEIMPL OPEN_PARENS compQstring pinvAttr CLOSE_PARENS {/* FIXME */}
\r
640 | methAttr K_PINVOKEIMPL OPEN_PARENS pinvAttr CLOSE_PARENS {/* FIXME */}
\r
643 pinvAttr : /* EMPTY */
\r
644 | pinvAttr K_NOMANGLE
\r
646 | pinvAttr K_UNICODE
\r
647 | pinvAttr K_AUTOCHAR
\r
648 | pinvAttr K_LASTERR
\r
649 | pinvAttr K_WINAPI
\r
650 | pinvAttr K_CDECL
\r
651 | pinvAttr K_STDCALL
\r
652 | pinvAttr K_THISCALL
\r
653 | pinvAttr K_FASTCALL
\r
656 methodName : D_CTOR {$$ = new MethodName ("ctor", true);}
\r
657 | D_CCTOR {$$ = new MethodName ("cctor", true);}
\r
658 | name1 {$$ = new MethodName ($1 as string);}
\r
661 paramAttr : /* EMPTY */
\r
662 | paramAttr OPEN_BRACKET K_IN CLOSE_BRACKET
\r
663 | paramAttr OPEN_BRACKET K_OUT CLOSE_BRACKET
\r
664 | paramAttr OPEN_BRACKET K_OPT CLOSE_BRACKET
\r
665 | paramAttr OPEN_BRACKET int32 CLOSE_BRACKET
\r
668 fieldAttr : /* EMPTY */
\r
669 | fieldAttr K_STATIC
\r
670 | fieldAttr K_PUBLIC
\r
671 | fieldAttr K_PRIVATE
\r
672 | fieldAttr K_FAMILY
\r
673 | fieldAttr K_INITONLY
\r
674 | fieldAttr K_RTSPECIALNAME /**/
\r
675 | fieldAttr K_SPECIALNAME
\r
676 /* commented out because PInvoke for fields is not supported by EE
\r
677 | fieldAttr K_PINVOKEIMPL OPEN_PARENS compQstring K_AS compQstring pinvAttr CLOSE_PARENS
\r
678 | fieldAttr K_PINVOKEIMPL OPEN_PARENS compQstring pinvAttr CLOSE_PARENS
\r
679 | fieldAttr K_PINVOKEIMPL OPEN_PARENS pinvAttr CLOSE_PARENS
\r
681 | fieldAttr K_MARSHAL OPEN_PARENS nativeType CLOSE_PARENS
\r
682 | fieldAttr K_ASSEMBLY
\r
683 | fieldAttr K_FAMANDASSEM
\r
684 | fieldAttr K_FAMORASSEM
\r
685 | fieldAttr K_COMPILERCONTROLLED
\r
686 | fieldAttr K_LITERAL
\r
687 | fieldAttr K_NOTSERIALIZED
\r
690 implAttr : /* empty */
\r
691 | implAttr K_NATIVE
\r
692 | implAttr ELLIPSIS
\r
693 | implAttr K_IL /* LAMESPEC: absent in docs */
\r
694 | implAttr K_CIL /* LAMESPEC: same as above */
\r
695 | implAttr K_OPTIL
\r
696 | implAttr K_MANAGED
\r
697 | implAttr K_UNMANAGED
\r
698 | implAttr K_FORWARDREF
\r
699 | implAttr K_PRESERVESIG
\r
700 | implAttr K_RUNTIME
\r
701 | implAttr K_INTERNALCALL
\r
702 | implAttr K_SYNCHRONIZED
\r
703 | implAttr K_NOINLINING
\r
706 localsHead : D_LOCALS
\r
710 methodDecl : D_EMITBYTE int32
\r
712 | D_MAXSTACK int32
\r
713 | localsHead OPEN_PARENS sigArgs0 CLOSE_PARENS
\r
714 | localsHead K_INIT OPEN_PARENS sigArgs0 CLOSE_PARENS
\r
718 | instr {method.AddInstruction (currentInstr);}
\r
724 | D_EXPORT OPEN_BRACKET int32 CLOSE_BRACKET
\r
725 | D_EXPORT OPEN_BRACKET int32 CLOSE_BRACKET K_AS id
\r
726 | D_VTENTRY int32 COLON int32
\r
727 | D_OVERRIDE typeSpec DOUBLE_COLON methodName
\r
729 | D_PARAM OPEN_BRACKET int32 CLOSE_BRACKET initOpt
\r
732 scopeBlock : scopeOpen methodDecls CLOSE_BRACE
\r
735 scopeOpen : OPEN_BRACE
\r
738 sehBlock : tryBlock sehClauses
\r
741 sehClauses : sehClause sehClauses
\r
745 tryBlock : tryHead scopeBlock
\r
746 | tryHead id K_TO id
\r
747 | tryHead int32 K_TO int32
\r
754 sehClause : catchClause handlerBlock
\r
755 | filterClause handlerBlock
\r
756 | finallyClause handlerBlock
\r
757 | faultClause handlerBlock
\r
761 filterClause : filterHead scopeBlock
\r
763 | filterHead int32
\r
766 filterHead : K_FILTER
\r
769 catchClause : K_CATCH className
\r
772 finallyClause : K_FINALLY
\r
775 faultClause : K_FAULT
\r
778 handlerBlock : scopeBlock
\r
779 | K_HANDLER id K_TO id
\r
780 | K_HANDLER int32 K_TO int32
\r
784 methodDecls : /* EMPTY */
\r
785 | methodDecls methodDecl
\r
788 dataDecl : ddHead ddBody
\r
791 ddHead : D_DATA tls id ASSIGN
\r
799 ddBody : OPEN_BRACE ddItemList CLOSE_BRACE
\r
803 ddItemList : ddItem COMMA ddItemList
\r
807 ddItemCount : /* EMPTY */
\r
808 | OPEN_BRACKET int32 CLOSE_BRACKET
\r
811 ddItem : K_CHAR STAR OPEN_PARENS compQstring CLOSE_PARENS
\r
812 | AMPERSAND OPEN_PARENS id CLOSE_PARENS
\r
813 | bytearrayhead bytes CLOSE_PARENS
\r
814 | K_FLOAT32 OPEN_PARENS float64 CLOSE_PARENS ddItemCount
\r
815 | K_FLOAT64 OPEN_PARENS float64 CLOSE_PARENS ddItemCount
\r
816 | K_INT64 OPEN_PARENS int64 CLOSE_PARENS ddItemCount
\r
817 | K_INT32 OPEN_PARENS int32 CLOSE_PARENS ddItemCount
\r
818 | K_INT16 OPEN_PARENS int32 CLOSE_PARENS ddItemCount
\r
819 | K_INT8 OPEN_PARENS int32 CLOSE_PARENS ddItemCount
\r
820 | K_FLOAT32 ddItemCount
\r
821 | K_FLOAT64 ddItemCount
\r
822 | K_INT64 ddItemCount
\r
823 | K_INT32 ddItemCount
\r
824 | K_INT16 ddItemCount
\r
825 | K_INT8 ddItemCount
\r
828 fieldInit : K_FLOAT32 OPEN_PARENS float64 CLOSE_PARENS
\r
829 | K_FLOAT64 OPEN_PARENS float64 CLOSE_PARENS
\r
830 | K_FLOAT32 OPEN_PARENS int64 CLOSE_PARENS
\r
831 | K_FLOAT64 OPEN_PARENS int64 CLOSE_PARENS
\r
832 | K_INT64 OPEN_PARENS int64 CLOSE_PARENS
\r
833 | K_INT32 OPEN_PARENS int64 CLOSE_PARENS
\r
834 | K_INT16 OPEN_PARENS int64 CLOSE_PARENS
\r
835 | K_CHAR OPEN_PARENS int64 CLOSE_PARENS
\r
836 | K_INT8 OPEN_PARENS int64 CLOSE_PARENS
\r
837 | K_BOOL OPEN_PARENS truefalse CLOSE_PARENS
\r
839 | bytearrayhead bytes CLOSE_PARENS
\r
843 bytearrayhead : K_BYTEARRAY OPEN_PARENS
\r
851 bytes : /* EMPTY */
\r
855 hexbytes : hexbyte
\r
856 | hexbytes hexbyte
\r
859 instr_r_head : INSTR_R OPEN_PARENS
\r
862 methodSpec : K_METHOD
\r
865 instr : INSTR_NONE {currentInstr = new InstrNone ((OpCode) $1);}
\r
866 | INSTR_VAR int32 {currentInstr = new InstrVar ((OpCode) $1, $2);}
\r
867 | INSTR_VAR id {currentInstr = new InstrVar ((OpCode) $1, $2);}
\r
868 | INSTR_I int32 {currentInstr = new InstrI ((OpCode) $1, (Int32) $2);}
\r
869 | INSTR_I8 int64 {currentInstr = new InstrI8 ((OpCode) $1, (Int64) $2);}
\r
870 | INSTR_R float64 {currentInstr = new InstrR ((OpCode) $1, (Double) $2);}
\r
871 | INSTR_R int64 {currentInstr = new InstrR ((OpCode) $1, (Int64) $2);}
\r
872 | instr_r_head bytes CLOSE_PARENS
\r
873 | INSTR_BRTARGET int32
\r
874 | INSTR_BRTARGET id
\r
875 | INSTR_METHOD callConv type typeSpec DOUBLE_COLON methodName OPEN_PARENS sigArgs0 CLOSE_PARENS
\r
876 | INSTR_METHOD callConv type methodName OPEN_PARENS sigArgs0 CLOSE_PARENS
\r
877 | INSTR_FIELD type typeSpec DOUBLE_COLON id
\r
878 | INSTR_FIELD type id
\r
879 | INSTR_TYPE typeSpec
\r
880 | INSTR_STRING compQstring {currentInstr = new InstrString ((OpCode) $1, $2 as string);}
\r
881 | INSTR_STRING bytearrayhead bytes CLOSE_PARENS
\r
882 | INSTR_SIG callConv type OPEN_PARENS sigArgs0 CLOSE_PARENS
\r
885 | INSTR_TOK methodSpec callConv type typeSpec DOUBLE_COLON methodName OPEN_PARENS sigArgs0 CLOSE_PARENS
\r
886 | INSTR_TOK methodSpec callConv type methodName OPEN_PARENS sigArgs0 CLOSE_PARENS
\r
887 | INSTR_TOK K_FIELD type typeSpec DOUBLE_COLON id
\r
888 | INSTR_TOK K_FIELD type id
\r
889 | INSTR_TOK typeSpec
\r
890 | INSTR_SWITCH OPEN_PARENS labels CLOSE_PARENS
\r
891 | INSTR_PHI int16s
\r
894 sigArgs0 : /* EMPTY */
\r
899 | sigArgs1 COMMA sigArg
\r
904 | paramAttr type id
\r
905 | paramAttr type K_MARSHAL OPEN_PARENS nativeType CLOSE_PARENS
\r
906 | paramAttr type K_MARSHAL OPEN_PARENS nativeType CLOSE_PARENS id
\r
911 dottedName : id DOT id {$$ = ($1 as string) + "." + ($3 as string);}
\r
920 className : OPEN_BRACKET name1 CLOSE_BRACKET slashedName
\r
921 | OPEN_BRACKET D_MODULE name1 CLOSE_BRACKET slashedName
\r
925 slashedName : name1
\r
926 | slashedName SLASH name1 {$$ = ($1 as string) + "/" + ($3 as string);}
\r
929 typeSpec : className
\r
930 | OPEN_BRACKET name1 CLOSE_BRACKET
\r
931 | OPEN_BRACKET D_MODULE name1 CLOSE_BRACKET
\r
935 callConv : K_INSTANCE callConv {currentCallConv |= CallingConventions.HasThis;}
\r
936 | K_EXPLICIT callConv {currentCallConv |= CallingConventions.ExplicitThis;}
\r
940 callKind : /* EMPTY */
\r
941 | K_DEFAULT {currentCallConv |= CallingConventions.Standard;}
\r
942 | K_VARARG {currentCallConv |= CallingConventions.VarArgs;}
\r
943 | K_UNMANAGED K_CDECL
\r
944 | K_UNMANAGED K_STDCALL
\r
945 | K_UNMANAGED K_THISCALL
\r
946 | K_UNMANAGED K_FASTCALL
\r
949 nativeType : /* EMPTY */
\r
950 | K_CUSTOM OPEN_PARENS compQstring COMMA compQstring COMMA compQstring COMMA compQstring CLOSE_PARENS
\r
951 | K_CUSTOM OPEN_PARENS compQstring COMMA compQstring CLOSE_PARENS
\r
952 | K_FIXED K_SYSSTRING OPEN_BRACKET int32 CLOSE_BRACKET
\r
953 | K_FIXED K_ARRAY OPEN_BRACKET int32 CLOSE_BRACKET
\r
966 | K_UNSIGNED K_INT8
\r
967 | K_UNSIGNED K_INT16
\r
968 | K_UNSIGNED K_INT32
\r
969 | K_UNSIGNED K_INT64
\r
971 | nativeType OPEN_BRACKET CLOSE_BRACKET
\r
972 | nativeType OPEN_BRACKET int32 CLOSE_BRACKET
\r
973 | nativeType OPEN_BRACKET int32 PLUS int32 CLOSE_BRACKET
\r
974 | nativeType OPEN_BRACKET PLUS int32 CLOSE_BRACKET
\r
986 | K_SAFEARRAY variantType
\r
988 | K_UNSIGNED K_INT
\r
989 | K_NESTED K_STRUCT
\r
993 | K_VARIANT K_BOOL
\r
999 variantType : /* EMPTY */
\r
1011 | K_UNSIGNED K_INT8
\r
1012 | K_UNSIGNED K_INT16
\r
1013 | K_UNSIGNED K_INT32
\r
1014 | K_UNSIGNED K_INT64
\r
1016 | variantType OPEN_BRACKET CLOSE_BRACKET
\r
1017 | variantType K_VECTOR
\r
1018 | variantType AMPERSAND
\r
1028 | K_UNSIGNED K_INT
\r
1038 | K_STREAMED_OBJECT
\r
1039 | K_STORED_OBJECT
\r
1045 type : K_CLASS className
\r
1048 | K_VALUE K_CLASS className
\r
1049 | K_VALUETYPE className
\r
1050 | type OPEN_BRACKET CLOSE_BRACKET
\r
1051 | type OPEN_BRACKET bounds1 CLOSE_BRACKET
\r
1052 /* uncomment when and if this type is supported by the Runtime
\r
1053 | type K_VALUE OPEN_BRACKET int32 CLOSE_BRACKET
\r
1058 | type K_MODREQ OPEN_PARENS className CLOSE_PARENS
\r
1059 | type K_MODOPT OPEN_PARENS className CLOSE_PARENS
\r
1061 | methodSpec callConv type STAR OPEN_PARENS sigArgs0 CLOSE_PARENS
\r
1072 | K_UNSIGNED K_INT8 {$$ = "uint8";}
\r
1073 | K_UNSIGNED K_INT16 {$$ = "uint16";}
\r
1074 | K_UNSIGNED K_INT32 {$$ = "uint32";}
\r
1075 | K_UNSIGNED K_INT64 {$$ = "uint64";}
\r
1077 | K_NATIVE K_UNSIGNED K_INT
\r
1078 | K_NATIVE K_FLOAT
\r
1082 | bounds1 COMMA bound
\r
1085 bound : /* EMPTY */
\r
1088 | int32 ELLIPSIS int32
\r
1092 labels : /* empty */
\r
1093 | id COMMA labels
\r
1094 | int32 COMMA labels
\r
1104 int16s : /* EMPTY */
\r
1108 int32 : INT32 /* NOTE: it's INT64 in docs */
\r
1114 float64 : FLOAT64
\r
1115 | K_FLOAT32 OPEN_PARENS int32 CLOSE_PARENS
\r
1116 | K_FLOAT64 OPEN_PARENS int64 CLOSE_PARENS
\r
1119 secDecl : D_PERMISSION secAction typeSpec OPEN_PARENS nameValPairs CLOSE_PARENS
\r
1120 | D_PERMISSION secAction typeSpec
\r
1121 | psetHead bytes CLOSE_PARENS
\r
1124 psetHead : D_PERMISSIONSET secAction ASSIGN OPEN_PARENS
\r
1127 nameValPairs : nameValPair
\r
1128 | nameValPair COMMA nameValPairs
\r
1131 nameValPair : compQstring ASSIGN caValue
\r
1134 truefalse : K_TRUE
\r
1138 caValue : truefalse
\r
1140 | K_INT32 OPEN_PARENS int32 CLOSE_PARENS
\r
1142 | className OPEN_PARENS K_INT8 COLON int32 CLOSE_PARENS
\r
1143 | className OPEN_PARENS K_INT16 COLON int32 CLOSE_PARENS
\r
1144 | className OPEN_PARENS K_INT32 COLON int32 CLOSE_PARENS
\r
1145 | className OPEN_PARENS int32 CLOSE_PARENS
\r
1148 secAction : K_REQUEST
\r
1161 | K_NONCASLINKDEMAND
\r
1162 | K_NONCASINHERITANCE
\r
1165 extSourceSpec : D_LINE int32 SQSTRING
\r
1167 | D_XLINE int32 QSTRING
\r
1170 fileDecl : D_FILE fileAttr name1 fileEntry hashHead bytes CLOSE_PARENS fileEntry
\r
1171 | D_FILE fileAttr name1 fileEntry
\r
1174 fileAttr : /* EMPTY */
\r
1175 | fileAttr K_NOMETADATA
\r
1178 fileEntry : /* EMPTY */
\r
1182 hashHead : D_HASH ASSIGN OPEN_PARENS
\r
1185 assemblyHead : D_ASSEMBLY asmAttr name1
\r
1187 codegen = new CodeGen (defaultAsmName);
\r
1189 // TODO: set assembly attrs
\r
1190 codegen.SetName ($3 as string);
\r
1194 asmAttr : /* EMPTY */
\r
1195 | asmAttr K_NOAPPDOMAIN
\r
1196 | asmAttr K_NOPROCESS
\r
1197 | asmAttr K_NOMACHINE
\r
1200 assemblyDecls : /* EMPTY */
\r
1201 | assemblyDecls assemblyDecl
\r
1204 assemblyDecl : D_HASH K_ALGORITHM int32
\r
1209 asmOrRefDecl : publicKeyHead bytes CLOSE_PARENS
\r
1210 | D_VER int32 COLON int32 COLON int32 COLON int32
\r
1211 | D_LOCALE compQstring
\r
1212 | localeHead bytes CLOSE_PARENS
\r
1213 | D_PROCESSOR int32
\r
1214 | D_OS int32 D_VER int32 COLON int32
\r
1218 publicKeyHead : D_PUBLICKEY ASSIGN OPEN_PARENS
\r
1221 publicKeyTokenHead : D_PUBLICKEYTOKEN ASSIGN OPEN_PARENS
\r
1224 localeHead : D_LOCALE ASSIGN OPEN_PARENS
\r
1227 assemblyRefHead : D_ASSEMBLY K_EXTERN name1
\r
1230 assemblyRefDecls : /* EMPTY */
\r
1231 | assemblyRefDecls assemblyRefDecl
\r
1234 assemblyRefDecl : hashHead bytes CLOSE_PARENS
\r
1236 | publicKeyTokenHead bytes CLOSE_PARENS
\r
1239 comtypeHead : D_CLASS K_EXTERN comtAttr name1
\r
1242 exportHead : D_EXPORT comtAttr name1
\r
1245 comtAttr : /* EMPTY */
\r
1246 | comtAttr K_PRIVATE
\r
1247 | comtAttr K_PUBLIC
\r
1248 | comtAttr K_NESTED K_PUBLIC
\r
1249 | comtAttr K_NESTED K_PRIVATE
\r
1250 | comtAttr K_NESTED K_FAMILY
\r
1251 | comtAttr K_NESTED K_ASSEMBLY
\r
1252 | comtAttr K_NESTED K_FAMANDASSEM
\r
1253 | comtAttr K_NESTED K_FAMORASSEM
\r
1256 comtypeDecls : /* EMPTY */
\r
1257 | comtypeDecls comtypeDecl
\r
1260 comtypeDecl : D_FILE name1
\r
1261 | D_CLASS K_EXTERN name1
\r
1266 manifestResHead : D_MRESOURCE manresAttr name1
\r
1269 manresAttr : /* EMPTY */
\r
1270 | manresAttr K_PUBLIC
\r
1271 | manresAttr K_PRIVATE
\r
1274 manifestResDecls : /* EMPTY */
\r
1275 | manifestResDecls manifestResDecl
\r
1278 manifestResDecl : D_FILE name1 K_AT int32
\r
1279 | D_ASSEMBLY K_EXTERN name1
\r
1286 } // namespace Mono.ILASM
\r