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 ILParser (CodeGen codegen) {
\r
30 this.codegen = codegen;
\r
33 public CodeGen CodeGen {
\r
43 /* ID - alpha-numeric identifier */
\r
46 /* QSTRING - quoted string */
\r
49 /* SQSTRING - single quoted string */
\r
52 /* INT32 - 32 bit integer */
\r
55 /* INT64 - 64 bit integer */
\r
58 /* FLOAT64 - floating point number */
\r
65 %token OPEN_BRACE "{"
\r
66 %token CLOSE_BRACE "}"
\r
67 %token OPEN_BRACKET "["
\r
68 %token CLOSE_BRACKET "]"
\r
69 %token OPEN_PARENS "("
\r
70 %token CLOSE_PARENS ")"
\r
73 %token DOUBLE_COLON "::"
\r
74 %token SEMICOLON ";"
\r
77 %token AMPERSAND "&"
\r
81 %token ELLIPSIS "..."
\r
90 /* INSTR_* instruction types */
\r
96 %token INSTR_BRTARGET
\r
100 %token INSTR_STRING
\r
104 %token INSTR_SWITCH
\r
113 /* Mechanically generated - DO NOT EDIT! */
\r
122 %token D_CAPABILITY
\r
132 %token D_ENTRYPOINT
\r
141 %token D_IMPLICITCOM
\r
147 %token D_MANIFESTRES
\r
154 %token D_ORIGINATOR
\r
160 %token D_PERMISSION
\r
161 %token D_PERMISSIONSET
\r
165 %token D_PUBLICKEYTOKEN
\r
182 %token K_IMPLICITCOM
\r
183 %token K_IMPLICITRES
\r
184 %token K_NOAPPDOMAIN
\r
208 %token K_RTSPECIALNAME
\r
209 %token K_SPECIALNAME
\r
211 %token K_FAMANDASSEM
\r
212 %token K_FAMORASSEM
\r
213 %token K_PRIVATESCOPE
\r
215 %token K_NOTSERIALIZED
\r
217 %token K_NOT_IN_GC_HEAP
\r
222 %token K_SEQUENTIAL
\r
227 %token K_SERIALIZABLE
\r
231 %token K_IMPLEMENTS
\r
236 %token K_UNMANAGEDEXP
\r
237 %token K_PINVOKEIMPL
\r
247 %token K_FORWARDREF
\r
249 %token K_INTERNALCALL
\r
250 %token K_SYNCHRONIZED
\r
251 %token K_NOINLINING
\r
292 %token K_USERDEFINED
\r
298 %token K_STREAMED_OBJECT
\r
299 %token K_STORED_OBJECT
\r
300 %token K_BLOB_OBJECT
\r
311 %token K_FROMUNMANAGED
\r
312 %token K_CALLMOSTDERIVED
\r
328 %token K_PERMITONLY
\r
330 %token K_INHERITCHECK
\r
334 %token K_PREJITGRANT
\r
335 %token K_PREJITDENY
\r
336 %token K_NONCASDEMAND
\r
337 %token K_NONCASLINKDEMAND
\r
338 %token K_NONCASINHERITANCE
\r
340 %token K_NOMETADATA
\r
342 %token K_FULLORIGIN
\r
346 %token K_ENABLEJITTRACKING
\r
347 %token K_DISABLEJITOPTIMIZER
\r
348 %token K_PRESERVESIG
\r
349 %token K_BEFOREFIELDINIT
\r
353 %token K_COMPILERCONTROLLED
\r
361 /* end generated */
\r
374 decls : /* EMPTY */
\r
379 | nameSpaceHead OPEN_BRACE decls CLOSE_BRACE
\r
387 | assemblyHead OPEN_BRACE assemblyDecls CLOSE_BRACE
\r
388 | assemblyRefHead OPEN_BRACE assemblyRefDecls CLOSE_BRACE
\r
389 | comtypeHead OPEN_BRACE comtypeDecls CLOSE_BRACE
\r
390 | manifestResHead OPEN_BRACE manifestResDecls CLOSE_BRACE
\r
394 | D_SUBSYSTEM int32
\r
395 | D_CORFLAGS int32
\r
396 | D_FILE K_ALIGNMENT int32
\r
400 compQstring : QSTRING
\r
401 | compQstring PLUS QSTRING {$$ = ($1 as string) + ($3 as string);}
\r
404 languageDecl : D_LANGUAGE SQSTRING
\r
405 | D_LANGUAGE SQSTRING COMMA SQSTRING
\r
406 | D_LANGUAGE SQSTRING COMMA SQSTRING COMMA SQSTRING
\r
409 customAttrDecl : D_CUSTOM customType
\r
410 | D_CUSTOM customType ASSIGN compQstring
\r
411 | customHead bytes CLOSE_PARENS
\r
412 | D_CUSTOM OPEN_PARENS customType CLOSE_PARENS customType
\r
413 | D_CUSTOM OPEN_PARENS customType CLOSE_PARENS customType ASSIGN compQstring
\r
414 | customHeadWithOwner bytes CLOSE_PARENS
\r
417 moduleHead : D_MODULE
\r
419 | D_MODULE K_EXTERN name1
\r
422 vtfixupDecl : D_VTFIXUP OPEN_BRACKET int32 CLOSE_BRACKET vtfixupAttr K_AT id
\r
425 vtfixupAttr : /* EMPTY */
\r
426 | vtfixupAttr K_INT32
\r
427 | vtfixupAttr K_INT64
\r
428 | vtfixupAttr K_FROMUNMANAGED
\r
429 | vtfixupAttr K_CALLMOSTDERIVED
\r
432 vtableDecl : vtableHead bytes CLOSE_PARENS
\r
435 vtableHead : D_VTABLE ASSIGN OPEN_PARENS
\r
438 nameSpaceHead : D_NAMESPACE name1
\r
441 classHead : D_CLASS classAttr id extendsClause implClause
\r
443 currentTypeAttrs = 0;
\r
444 currentClass = new Class ($3 as string);
\r
445 currentClass.Attrs = currentTypeAttrs;
\r
447 // TODO: extends/implemets
\r
451 classAttr : /* EMPTY */
\r
452 | classAttr K_PUBLIC {currentTypeAttrs |= TypeAttributes.Public;}
\r
453 | classAttr K_PRIVATE {currentTypeAttrs &= ~TypeAttributes.Public;}
\r
454 | classAttr K_VALUE { /* FIXME */ }
\r
455 | classAttr K_ENUM { /* FIXME */ }
\r
456 | classAttr K_INTERFACE {currentTypeAttrs |= TypeAttributes.Interface;}
\r
457 | classAttr K_SEALED {currentTypeAttrs |= TypeAttributes.Sealed;}
\r
458 | classAttr K_ABSTRACT {currentTypeAttrs |= TypeAttributes.Abstract;}
\r
459 | classAttr K_AUTO {currentTypeAttrs |= TypeAttributes.AutoLayout;}
\r
460 | classAttr K_SEQUENTIAL {currentTypeAttrs |= TypeAttributes.SequentialLayout;}
\r
461 | classAttr K_EXPLICIT {currentTypeAttrs |= TypeAttributes.ExplicitLayout;}
\r
462 | classAttr K_ANSI {currentTypeAttrs |= TypeAttributes.AnsiClass;}
\r
463 | classAttr K_UNICODE {currentTypeAttrs |= TypeAttributes.UnicodeClass;}
\r
464 | classAttr K_AUTOCHAR {currentTypeAttrs |= TypeAttributes.AutoClass;}
\r
465 | classAttr K_IMPORT {currentTypeAttrs |= TypeAttributes.Import;}
\r
466 | classAttr K_SERIALIZABLE {currentTypeAttrs |= TypeAttributes.Serializable;}
\r
467 | classAttr K_NESTED K_PUBLIC {currentTypeAttrs |= TypeAttributes.NestedPublic;}
\r
468 | classAttr K_NESTED K_PRIVATE {currentTypeAttrs |= TypeAttributes.NestedPrivate;}
\r
469 | classAttr K_NESTED K_FAMILY {currentTypeAttrs |= TypeAttributes.NestedFamily;}
\r
470 | classAttr K_NESTED K_ASSEMBLY {currentTypeAttrs |= TypeAttributes.NestedAssembly;}
\r
471 | classAttr K_NESTED K_FAMANDASSEM {currentTypeAttrs |= TypeAttributes.NestedFamANDAssem;}
\r
472 | classAttr K_NESTED K_FAMORASSEM {currentTypeAttrs |= TypeAttributes.NestedFamORAssem;}
\r
473 | classAttr K_BEFOREFIELDINIT {currentTypeAttrs |= TypeAttributes.BeforeFieldInit;}
\r
474 | classAttr K_SPECIALNAME {currentTypeAttrs |= TypeAttributes.SpecialName;}
\r
475 | classAttr K_RTSPECIALNAME {currentTypeAttrs |= TypeAttributes.RTSpecialName;}
\r
478 extendsClause : /* EMPTY */
\r
479 | K_EXTENDS className
\r
482 implClause : /* EMPTY */
\r
483 | K_IMPLEMENTS classNames
\r
486 classNames : classNames COMMA className
\r
490 classDecls : /* EMPTY */
\r
491 | classDecls classDecl
\r
495 classAll : classHead OPEN_BRACE classDecls CLOSE_BRACE
\r
497 codegen.AddClass (currentClass);
\r
498 currentClass = null;
\r
503 classDecl : methodAll
\r
505 | eventHead OPEN_BRACE eventDecls CLOSE_BRACE
\r
506 | propHead OPEN_BRACE propDecls CLOSE_BRACE
\r
514 | exportHead OPEN_BRACE comtypeDecls CLOSE_BRACE
\r
515 | D_OVERRIDE typeSpec DOUBLE_COLON methodName K_WITH callConv type typeSpec DOUBLE_COLON methodName OPEN_PARENS sigArgs0 CLOSE_PARENS
\r
519 fieldDecl : D_FIELD repeatOpt fieldAttr type id atOpt initOpt
\r
523 atOpt : /* EMPTY */
\r
527 initOpt : /* EMPTY */
\r
528 | ASSIGN fieldInit
\r
531 repeatOpt : /* EMPTY */
\r
532 | OPEN_BRACKET int32 CLOSE_BRACKET
\r
535 customHead : D_CUSTOM customType ASSIGN OPEN_PARENS
\r
538 customHeadWithOwner : D_CUSTOM OPEN_PARENS customType CLOSE_PARENS customType ASSIGN OPEN_PARENS
\r
541 customType : typeSpec
\r
542 | callConv type typeSpec DOUBLE_COLON methodName OPEN_PARENS sigArgs0 CLOSE_PARENS
\r
543 | callConv type methodName OPEN_PARENS sigArgs0 CLOSE_PARENS
\r
546 eventHead : D_EVENT eventAttr typeSpec id
\r
547 | D_EVENT eventAttr id
\r
551 eventAttr : /* EMPTY */
\r
552 | eventAttr K_RTSPECIALNAME /**/
\r
553 | eventAttr K_SPECIALNAME
\r
556 eventDecls : /* EMPTY */
\r
557 | eventDecls eventDecl
\r
560 eventDecl : D_ADDON callConv type typeSpec DOUBLE_COLON methodName OPEN_PARENS sigArgs0 CLOSE_PARENS
\r
561 | D_ADDON callConv type methodName OPEN_PARENS sigArgs0 CLOSE_PARENS
\r
562 | D_REMOVEON callConv type typeSpec DOUBLE_COLON methodName OPEN_PARENS sigArgs0 CLOSE_PARENS
\r
563 | D_REMOVEON callConv type methodName OPEN_PARENS sigArgs0 CLOSE_PARENS
\r
564 | D_FIRE callConv type typeSpec DOUBLE_COLON methodName OPEN_PARENS sigArgs0 CLOSE_PARENS
\r
565 | D_FIRE callConv type methodName OPEN_PARENS sigArgs0 CLOSE_PARENS
\r
566 | D_OTHER callConv type typeSpec DOUBLE_COLON methodName OPEN_PARENS sigArgs0 CLOSE_PARENS
\r
567 | D_OTHER callConv type methodName OPEN_PARENS sigArgs0 CLOSE_PARENS
\r
573 propHead : D_PROPERTY propAttr callConv type id OPEN_PARENS sigArgs0 CLOSE_PARENS initOpt
\r
576 propAttr : /* EMPTY */
\r
577 | propAttr K_RTSPECIALNAME /**/
\r
578 | propAttr K_SPECIALNAME
\r
581 propDecls : /* EMPTY */
\r
582 | propDecls propDecl
\r
586 propDecl : D_SET callConv type typeSpec DOUBLE_COLON methodName OPEN_PARENS sigArgs0 CLOSE_PARENS
\r
587 | D_SET callConv type methodName OPEN_PARENS sigArgs0 CLOSE_PARENS
\r
588 | D_GET callConv type typeSpec DOUBLE_COLON methodName OPEN_PARENS sigArgs0 CLOSE_PARENS
\r
589 | D_GET callConv type methodName OPEN_PARENS sigArgs0 CLOSE_PARENS
\r
590 | D_OTHER callConv type typeSpec DOUBLE_COLON methodName OPEN_PARENS sigArgs0 CLOSE_PARENS
\r
591 | D_OTHER callConv type methodName OPEN_PARENS sigArgs0 CLOSE_PARENS
\r
598 methodHeadPart1 : D_METHOD
\r
600 method = new Method ();
\r
601 currentCallConv = 0; /*?*/
\r
605 methodHead : methodHeadPart1 methAttr callConv paramAttr type methodName OPEN_PARENS sigArgs0 CLOSE_PARENS implAttr OPEN_BRACE
\r
607 method.SetMethodName ($6 as MethodName);
\r
608 method.CallConv = currentCallConv;
\r
609 method.RetType = $5 as string;
\r
611 | methodHeadPart1 methAttr callConv paramAttr type K_MARSHAL OPEN_PARENS nativeType CLOSE_PARENS methodName OPEN_PARENS sigArgs0 CLOSE_PARENS implAttr OPEN_BRACE
\r
615 methodAll : methodHead methodDecls CLOSE_BRACE
\r
617 // Console.WriteLine (method);
\r
618 currentClass.AddMethod (method);
\r
623 methAttr : /* EMPTY */
\r
624 | methAttr K_STATIC {method.Attrs |= MethodAttributes.Static;}
\r
625 | methAttr K_PUBLIC {method.Attrs |= MethodAttributes.Public;}
\r
626 | methAttr K_PRIVATE {method.Attrs &= ~MethodAttributes.Public;}
\r
627 | methAttr K_FAMILY {method.Attrs |= MethodAttributes.Family;}
\r
628 | methAttr K_FINAL {method.Attrs |= MethodAttributes.Final;}
\r
629 | methAttr K_SPECIALNAME {method.Attrs |= MethodAttributes.SpecialName;}
\r
630 | methAttr K_VIRTUAL {method.Attrs |= MethodAttributes.Virtual;}
\r
631 | methAttr K_ABSTRACT {method.Attrs |= MethodAttributes.Abstract;}
\r
632 | methAttr K_ASSEMBLY {method.Attrs |= MethodAttributes.Assembly;}
\r
633 | methAttr K_FAMANDASSEM {method.Attrs |= MethodAttributes.FamANDAssem;}
\r
634 | methAttr K_FAMORASSEM {method.Attrs |= MethodAttributes.FamORAssem;}
\r
635 | methAttr K_COMPILERCONTROLLED {/* FIXME */}
\r
636 | methAttr K_HIDEBYSIG {method.Attrs |= MethodAttributes.HideBySig;}
\r
637 | methAttr K_NEWSLOT {method.Attrs |= MethodAttributes.NewSlot;}
\r
638 | methAttr K_RTSPECIALNAME /**/ {/* FIXME */}
\r
639 | methAttr K_UNMANAGEDEXP {method.Attrs |= MethodAttributes.UnmanagedExport;}
\r
640 | methAttr K_REQSECOBJ {method.Attrs |= MethodAttributes.RequireSecObject;}
\r
641 | methAttr K_PINVOKEIMPL OPEN_PARENS compQstring K_AS compQstring pinvAttr CLOSE_PARENS {/* FIXME */}
\r
642 | methAttr K_PINVOKEIMPL OPEN_PARENS compQstring pinvAttr CLOSE_PARENS {/* FIXME */}
\r
643 | methAttr K_PINVOKEIMPL OPEN_PARENS pinvAttr CLOSE_PARENS {/* FIXME */}
\r
646 pinvAttr : /* EMPTY */
\r
647 | pinvAttr K_NOMANGLE
\r
649 | pinvAttr K_UNICODE
\r
650 | pinvAttr K_AUTOCHAR
\r
651 | pinvAttr K_LASTERR
\r
652 | pinvAttr K_WINAPI
\r
653 | pinvAttr K_CDECL
\r
654 | pinvAttr K_STDCALL
\r
655 | pinvAttr K_THISCALL
\r
656 | pinvAttr K_FASTCALL
\r
659 methodName : D_CTOR {$$ = new MethodName ("ctor", true);}
\r
660 | D_CCTOR {$$ = new MethodName ("cctor", true);}
\r
661 | name1 {$$ = new MethodName ($1 as string);}
\r
664 paramAttr : /* EMPTY */
\r
665 | paramAttr OPEN_BRACKET K_IN CLOSE_BRACKET
\r
666 | paramAttr OPEN_BRACKET K_OUT CLOSE_BRACKET
\r
667 | paramAttr OPEN_BRACKET K_OPT CLOSE_BRACKET
\r
668 | paramAttr OPEN_BRACKET int32 CLOSE_BRACKET
\r
671 fieldAttr : /* EMPTY */
\r
672 | fieldAttr K_STATIC
\r
673 | fieldAttr K_PUBLIC
\r
674 | fieldAttr K_PRIVATE
\r
675 | fieldAttr K_FAMILY
\r
676 | fieldAttr K_INITONLY
\r
677 | fieldAttr K_RTSPECIALNAME /**/
\r
678 | fieldAttr K_SPECIALNAME
\r
679 /* commented out because PInvoke for fields is not supported by EE
\r
680 | fieldAttr K_PINVOKEIMPL OPEN_PARENS compQstring K_AS compQstring pinvAttr CLOSE_PARENS
\r
681 | fieldAttr K_PINVOKEIMPL OPEN_PARENS compQstring pinvAttr CLOSE_PARENS
\r
682 | fieldAttr K_PINVOKEIMPL OPEN_PARENS pinvAttr CLOSE_PARENS
\r
684 | fieldAttr K_MARSHAL OPEN_PARENS nativeType CLOSE_PARENS
\r
685 | fieldAttr K_ASSEMBLY
\r
686 | fieldAttr K_FAMANDASSEM
\r
687 | fieldAttr K_FAMORASSEM
\r
688 | fieldAttr K_COMPILERCONTROLLED
\r
689 | fieldAttr K_LITERAL
\r
690 | fieldAttr K_NOTSERIALIZED
\r
693 implAttr : /* empty */
\r
694 | implAttr K_NATIVE
\r
695 | implAttr ELLIPSIS
\r
696 | implAttr K_IL /* LAMESPEC: absent in docs */
\r
697 | implAttr K_CIL /* LAMESPEC: same as above */
\r
698 | implAttr K_OPTIL
\r
699 | implAttr K_MANAGED
\r
700 | implAttr K_UNMANAGED
\r
701 | implAttr K_FORWARDREF
\r
702 | implAttr K_PRESERVESIG
\r
703 | implAttr K_RUNTIME
\r
704 | implAttr K_INTERNALCALL
\r
705 | implAttr K_SYNCHRONIZED
\r
706 | implAttr K_NOINLINING
\r
709 localsHead : D_LOCALS
\r
713 methodDecl : D_EMITBYTE int32
\r
715 | D_MAXSTACK int32
\r
716 | localsHead OPEN_PARENS sigArgs0 CLOSE_PARENS
\r
717 | localsHead K_INIT OPEN_PARENS sigArgs0 CLOSE_PARENS
\r
718 | D_ENTRYPOINT {method.IsEntryPoint = true;}
\r
722 method.AddInstruction (currentInstr);
\r
729 | D_EXPORT OPEN_BRACKET int32 CLOSE_BRACKET
\r
730 | D_EXPORT OPEN_BRACKET int32 CLOSE_BRACKET K_AS id
\r
731 | D_VTENTRY int32 COLON int32
\r
732 | D_OVERRIDE typeSpec DOUBLE_COLON methodName
\r
734 | D_PARAM OPEN_BRACKET int32 CLOSE_BRACKET initOpt
\r
737 scopeBlock : scopeOpen methodDecls CLOSE_BRACE
\r
740 scopeOpen : OPEN_BRACE
\r
743 sehBlock : tryBlock sehClauses
\r
746 sehClauses : sehClause sehClauses
\r
750 tryBlock : tryHead scopeBlock
\r
751 | tryHead id K_TO id
\r
752 | tryHead int32 K_TO int32
\r
759 sehClause : catchClause handlerBlock
\r
760 | filterClause handlerBlock
\r
761 | finallyClause handlerBlock
\r
762 | faultClause handlerBlock
\r
766 filterClause : filterHead scopeBlock
\r
768 | filterHead int32
\r
771 filterHead : K_FILTER
\r
774 catchClause : K_CATCH className
\r
777 finallyClause : K_FINALLY
\r
780 faultClause : K_FAULT
\r
783 handlerBlock : scopeBlock
\r
784 | K_HANDLER id K_TO id
\r
785 | K_HANDLER int32 K_TO int32
\r
789 methodDecls : /* EMPTY */
\r
790 | methodDecls methodDecl
\r
793 dataDecl : ddHead ddBody
\r
796 ddHead : D_DATA tls id ASSIGN
\r
804 ddBody : OPEN_BRACE ddItemList CLOSE_BRACE
\r
808 ddItemList : ddItem COMMA ddItemList
\r
812 ddItemCount : /* EMPTY */
\r
813 | OPEN_BRACKET int32 CLOSE_BRACKET
\r
816 ddItem : K_CHAR STAR OPEN_PARENS compQstring CLOSE_PARENS
\r
817 | AMPERSAND OPEN_PARENS id CLOSE_PARENS
\r
818 | bytearrayhead bytes CLOSE_PARENS
\r
819 | K_FLOAT32 OPEN_PARENS float64 CLOSE_PARENS ddItemCount
\r
820 | K_FLOAT64 OPEN_PARENS float64 CLOSE_PARENS ddItemCount
\r
821 | K_INT64 OPEN_PARENS int64 CLOSE_PARENS ddItemCount
\r
822 | K_INT32 OPEN_PARENS int32 CLOSE_PARENS ddItemCount
\r
823 | K_INT16 OPEN_PARENS int32 CLOSE_PARENS ddItemCount
\r
824 | K_INT8 OPEN_PARENS int32 CLOSE_PARENS ddItemCount
\r
825 | K_FLOAT32 ddItemCount
\r
826 | K_FLOAT64 ddItemCount
\r
827 | K_INT64 ddItemCount
\r
828 | K_INT32 ddItemCount
\r
829 | K_INT16 ddItemCount
\r
830 | K_INT8 ddItemCount
\r
833 fieldInit : K_FLOAT32 OPEN_PARENS float64 CLOSE_PARENS
\r
834 | K_FLOAT64 OPEN_PARENS float64 CLOSE_PARENS
\r
835 | K_FLOAT32 OPEN_PARENS int64 CLOSE_PARENS
\r
836 | K_FLOAT64 OPEN_PARENS int64 CLOSE_PARENS
\r
837 | K_INT64 OPEN_PARENS int64 CLOSE_PARENS
\r
838 | K_INT32 OPEN_PARENS int64 CLOSE_PARENS
\r
839 | K_INT16 OPEN_PARENS int64 CLOSE_PARENS
\r
840 | K_CHAR OPEN_PARENS int64 CLOSE_PARENS
\r
841 | K_INT8 OPEN_PARENS int64 CLOSE_PARENS
\r
842 | K_BOOL OPEN_PARENS truefalse CLOSE_PARENS
\r
844 | bytearrayhead bytes CLOSE_PARENS
\r
848 bytearrayhead : K_BYTEARRAY OPEN_PARENS
\r
856 bytes : /* EMPTY */
\r
860 hexbytes : hexbyte
\r
861 | hexbytes hexbyte
\r
864 instr_r_head : INSTR_R OPEN_PARENS
\r
867 methodSpec : K_METHOD
\r
870 instr : INSTR_NONE {currentInstr = new InstrNone ((OpCode) $1);}
\r
871 | INSTR_VAR int32 {currentInstr = new InstrVar ((OpCode) $1, $2);}
\r
872 | INSTR_VAR id {currentInstr = new InstrVar ((OpCode) $1, $2);}
\r
873 | INSTR_I int32 {currentInstr = new InstrI ((OpCode) $1, (Int32) $2);}
\r
874 | INSTR_I8 int64 {currentInstr = new InstrI8 ((OpCode) $1, (Int64) $2);}
\r
875 | INSTR_R float64 {currentInstr = new InstrR ((OpCode) $1, (Double) $2);}
\r
876 | INSTR_R int64 {currentInstr = new InstrR ((OpCode) $1, (Int64) $2);}
\r
877 | instr_r_head bytes CLOSE_PARENS
\r
878 | INSTR_BRTARGET int32
\r
879 | INSTR_BRTARGET id
\r
880 | INSTR_METHOD callConv type assembly_name name1 DOUBLE_COLON ID OPEN_PARENS signature_args CLOSE_PARENS
\r
882 currentInstr = new InstrCall ((OpCode) $1, (string)$3, (string)$4,
\r
883 (string)$5, (string)$7, (string)$9);
\r
887 | INSTR_METHOD callConv type methodName OPEN_PARENS sigArgs0 CLOSE_PARENS
\r
891 | INSTR_FIELD type typeSpec DOUBLE_COLON id
\r
892 | INSTR_FIELD type id
\r
893 | INSTR_TYPE typeSpec
\r
894 | INSTR_STRING compQstring
\r
896 currentInstr = new InstrString ((OpCode) $1, $2 as string);
\r
898 | INSTR_STRING bytearrayhead bytes CLOSE_PARENS
\r
899 | INSTR_SIG callConv type OPEN_PARENS sigArgs0 CLOSE_PARENS
\r
902 | INSTR_TOK methodSpec callConv type typeSpec DOUBLE_COLON methodName OPEN_PARENS sigArgs0 CLOSE_PARENS
\r
903 | INSTR_TOK methodSpec callConv type methodName OPEN_PARENS sigArgs0 CLOSE_PARENS
\r
904 | INSTR_TOK K_FIELD type typeSpec DOUBLE_COLON id
\r
905 | INSTR_TOK K_FIELD type id
\r
906 | INSTR_TOK typeSpec
\r
907 | INSTR_SWITCH OPEN_PARENS labels CLOSE_PARENS
\r
908 | INSTR_PHI int16s
\r
911 signature_args : /* EMPTY */
\r
913 | type COMMA signature_args
\r
917 sigArgs0 : /* EMPTY */
\r
922 | sigArgs1 COMMA sigArg
\r
927 | paramAttr type id
\r
928 | paramAttr type K_MARSHAL OPEN_PARENS nativeType CLOSE_PARENS
\r
929 | paramAttr type K_MARSHAL OPEN_PARENS nativeType CLOSE_PARENS id
\r
933 dottedName : id DOT id {$$ = ($1 as string) + "." + ($3 as string);}
\r
943 | id DASH id {$$ = String.Format ("{0}-{1}", $1, $3);}
\r
944 | id DASH assembly_ref {$$ = String.Format ("{0}-{1}", $1, $3);}
\r
947 assembly_name : OPEN_BRACKET assembly_ref CLOSE_BRACKET {$$ = ($2 as string);}
\r
950 className : OPEN_BRACKET name1 CLOSE_BRACKET slashedName
\r
951 | OPEN_BRACKET D_MODULE name1 CLOSE_BRACKET slashedName
\r
955 slashedName : name1
\r
956 | slashedName SLASH name1 {$$ = ($1 as string) + "/" + ($3 as string);}
\r
959 typeSpec : className
\r
960 | OPEN_BRACKET name1 CLOSE_BRACKET
\r
961 | OPEN_BRACKET D_MODULE name1 CLOSE_BRACKET
\r
965 callConv : K_INSTANCE callConv {currentCallConv |= CallingConventions.HasThis;}
\r
966 | K_EXPLICIT callConv {currentCallConv |= CallingConventions.ExplicitThis;}
\r
970 callKind : /* EMPTY */
\r
971 | K_DEFAULT {currentCallConv |= CallingConventions.Standard;}
\r
972 | K_VARARG {currentCallConv |= CallingConventions.VarArgs;}
\r
973 | K_UNMANAGED K_CDECL
\r
974 | K_UNMANAGED K_STDCALL
\r
975 | K_UNMANAGED K_THISCALL
\r
976 | K_UNMANAGED K_FASTCALL
\r
979 nativeType : /* EMPTY */
\r
980 | K_CUSTOM OPEN_PARENS compQstring COMMA compQstring COMMA compQstring COMMA compQstring CLOSE_PARENS
\r
981 | K_CUSTOM OPEN_PARENS compQstring COMMA compQstring CLOSE_PARENS
\r
982 | K_FIXED K_SYSSTRING OPEN_BRACKET int32 CLOSE_BRACKET
\r
983 | K_FIXED K_ARRAY OPEN_BRACKET int32 CLOSE_BRACKET
\r
996 | K_UNSIGNED K_INT8
\r
997 | K_UNSIGNED K_INT16
\r
998 | K_UNSIGNED K_INT32
\r
999 | K_UNSIGNED K_INT64
\r
1000 | nativeType STAR
\r
1001 | nativeType OPEN_BRACKET CLOSE_BRACKET
\r
1002 | nativeType OPEN_BRACKET int32 CLOSE_BRACKET
\r
1003 | nativeType OPEN_BRACKET int32 PLUS int32 CLOSE_BRACKET
\r
1004 | nativeType OPEN_BRACKET PLUS int32 CLOSE_BRACKET
\r
1016 | K_SAFEARRAY variantType
\r
1018 | K_UNSIGNED K_INT
\r
1019 | K_NESTED K_STRUCT
\r
1023 | K_VARIANT K_BOOL
\r
1029 variantType : /* EMPTY */
\r
1041 | K_UNSIGNED K_INT8
\r
1042 | K_UNSIGNED K_INT16
\r
1043 | K_UNSIGNED K_INT32
\r
1044 | K_UNSIGNED K_INT64
\r
1046 | variantType OPEN_BRACKET CLOSE_BRACKET
\r
1047 | variantType K_VECTOR
\r
1048 | variantType AMPERSAND
\r
1058 | K_UNSIGNED K_INT
\r
1068 | K_STREAMED_OBJECT
\r
1069 | K_STORED_OBJECT
\r
1075 type : K_CLASS className
\r
1078 | K_VALUE K_CLASS className
\r
1079 | K_VALUETYPE className
\r
1080 | type OPEN_BRACKET CLOSE_BRACKET
\r
1081 | type OPEN_BRACKET bounds1 CLOSE_BRACKET
\r
1082 /* uncomment when and if this type is supported by the Runtime
\r
1083 | type K_VALUE OPEN_BRACKET int32 CLOSE_BRACKET
\r
1088 | type K_MODREQ OPEN_PARENS className CLOSE_PARENS
\r
1089 | type K_MODOPT OPEN_PARENS className CLOSE_PARENS
\r
1091 | methodSpec callConv type STAR OPEN_PARENS sigArgs0 CLOSE_PARENS
\r
1102 | K_UNSIGNED K_INT8 {$$ = "uint8";}
\r
1103 | K_UNSIGNED K_INT16 {$$ = "uint16";}
\r
1104 | K_UNSIGNED K_INT32 {$$ = "uint32";}
\r
1105 | K_UNSIGNED K_INT64 {$$ = "uint64";}
\r
1107 | K_NATIVE K_UNSIGNED K_INT
\r
1108 | K_NATIVE K_FLOAT
\r
1112 | bounds1 COMMA bound
\r
1115 bound : /* EMPTY */
\r
1118 | int32 ELLIPSIS int32
\r
1122 labels : /* empty */
\r
1123 | id COMMA labels
\r
1124 | int32 COMMA labels
\r
1134 int16s : /* EMPTY */
\r
1138 int32 : INT32 /* NOTE: it's INT64 in docs */
\r
1144 float64 : FLOAT64
\r
1145 | K_FLOAT32 OPEN_PARENS int32 CLOSE_PARENS
\r
1146 | K_FLOAT64 OPEN_PARENS int64 CLOSE_PARENS
\r
1149 secDecl : D_PERMISSION secAction typeSpec OPEN_PARENS nameValPairs CLOSE_PARENS
\r
1150 | D_PERMISSION secAction typeSpec
\r
1151 | psetHead bytes CLOSE_PARENS
\r
1154 psetHead : D_PERMISSIONSET secAction ASSIGN OPEN_PARENS
\r
1157 nameValPairs : nameValPair
\r
1158 | nameValPair COMMA nameValPairs
\r
1161 nameValPair : compQstring ASSIGN caValue
\r
1164 truefalse : K_TRUE
\r
1168 caValue : truefalse
\r
1170 | K_INT32 OPEN_PARENS int32 CLOSE_PARENS
\r
1172 | className OPEN_PARENS K_INT8 COLON int32 CLOSE_PARENS
\r
1173 | className OPEN_PARENS K_INT16 COLON int32 CLOSE_PARENS
\r
1174 | className OPEN_PARENS K_INT32 COLON int32 CLOSE_PARENS
\r
1175 | className OPEN_PARENS int32 CLOSE_PARENS
\r
1178 secAction : K_REQUEST
\r
1191 | K_NONCASLINKDEMAND
\r
1192 | K_NONCASINHERITANCE
\r
1195 extSourceSpec : D_LINE int32 SQSTRING
\r
1197 | D_XLINE int32 QSTRING
\r
1200 fileDecl : D_FILE fileAttr name1 fileEntry hashHead bytes CLOSE_PARENS fileEntry
\r
1201 | D_FILE fileAttr name1 fileEntry
\r
1204 fileAttr : /* EMPTY */
\r
1205 | fileAttr K_NOMETADATA
\r
1208 fileEntry : /* EMPTY */
\r
1212 hashHead : D_HASH ASSIGN OPEN_PARENS
\r
1215 assemblyHead : D_ASSEMBLY asmAttr name1
\r
1217 // TODO: set assembly attrs
\r
1218 codegen.SetName ($3 as string);
\r
1222 asmAttr : /* EMPTY */
\r
1223 | asmAttr K_NOAPPDOMAIN
\r
1224 | asmAttr K_NOPROCESS
\r
1225 | asmAttr K_NOMACHINE
\r
1228 assemblyDecls : /* EMPTY */
\r
1229 | assemblyDecls assemblyDecl
\r
1232 assemblyDecl : D_HASH K_ALGORITHM int32
\r
1237 asmOrRefDecl : publicKeyHead bytes CLOSE_PARENS
\r
1238 | D_VER int32 COLON int32 COLON int32 COLON int32
\r
1239 | D_LOCALE compQstring
\r
1240 | localeHead bytes CLOSE_PARENS
\r
1241 | D_PROCESSOR int32
\r
1242 | D_OS int32 D_VER int32 COLON int32
\r
1246 publicKeyHead : D_PUBLICKEY ASSIGN OPEN_PARENS
\r
1249 publicKeyTokenHead : D_PUBLICKEYTOKEN ASSIGN OPEN_PARENS
\r
1252 localeHead : D_LOCALE ASSIGN OPEN_PARENS
\r
1255 assemblyRefHead : D_ASSEMBLY K_EXTERN name1
\r
1258 assemblyRefDecls : /* EMPTY */
\r
1259 | assemblyRefDecls assemblyRefDecl
\r
1262 assemblyRefDecl : hashHead bytes CLOSE_PARENS
\r
1264 | publicKeyTokenHead bytes CLOSE_PARENS
\r
1267 comtypeHead : D_CLASS K_EXTERN comtAttr name1
\r
1270 exportHead : D_EXPORT comtAttr name1
\r
1273 comtAttr : /* EMPTY */
\r
1274 | comtAttr K_PRIVATE
\r
1275 | comtAttr K_PUBLIC
\r
1276 | comtAttr K_NESTED K_PUBLIC
\r
1277 | comtAttr K_NESTED K_PRIVATE
\r
1278 | comtAttr K_NESTED K_FAMILY
\r
1279 | comtAttr K_NESTED K_ASSEMBLY
\r
1280 | comtAttr K_NESTED K_FAMANDASSEM
\r
1281 | comtAttr K_NESTED K_FAMORASSEM
\r
1284 comtypeDecls : /* EMPTY */
\r
1285 | comtypeDecls comtypeDecl
\r
1288 comtypeDecl : D_FILE name1
\r
1289 | D_CLASS K_EXTERN name1
\r
1294 manifestResHead : D_MRESOURCE manresAttr name1
\r
1297 manresAttr : /* EMPTY */
\r
1298 | manresAttr K_PUBLIC
\r
1299 | manresAttr K_PRIVATE
\r
1302 manifestResDecls : /* EMPTY */
\r
1303 | manifestResDecls manifestResDecl
\r
1306 manifestResDecl : D_FILE name1 K_AT int32
\r
1307 | D_ASSEMBLY K_EXTERN name1
\r
1314 } // namespace Mono.ILASM
\r