;\r
\r
vtfixup_attr : /* EMPTY */\r
- | vtfixup_attr int32\r
| vtfixup_attr int64\r
| vtfixup_attr K_FROMUNMANAGED\r
| vtfixup_attr K_CALLMOSTDERIVED\r
\r
data_head : D_DATA tls id ASSIGN\r
{\r
- \r
- $$ = new DataDef ((string) $3, (bool)\r
- $2);\r
- \r
+ $$ = new DataDef ((string) $3, (bool) $2); \r
} \r
| D_DATA tls\r
{\r
- \r
$$ = new DataDef (String.Empty, (bool) $2);\r
- \r
}\r
;\r
\r
| param_attr type K_MARSHAL OPEN_PARENS native_type CLOSE_PARENS id\r
;\r
\r
+type_list : /* EMPTY */ { $$ = new ArrayList (); }\r
+ | type\r
+ {\r
+ ArrayList type_list = new ArrayList ();\r
+ type_list.Add ($1);\r
+ $$ = type_list;\r
+ }\r
+ | type_list COMMA type\r
+ {\r
+ ArrayList type_list = (ArrayList) $1;\r
+ type_list.Add ($3);\r
+ }\r
+ ;\r
+\r
method_decls : /* EMPTY */\r
| method_decls method_decl\r
;\r
\r
method_decl : D_EMITBYTE int32\r
| D_MAXSTACK int32\r
- | D_LOCALS OPEN_PARENS sig_args CLOSE_PARENS\r
- | D_LOCALS K_INIT OPEN_PARENS sig_args CLOSE_PARENS\r
+ | D_LOCALS OPEN_PARENS local_list CLOSE_PARENS\r
+ {\r
+ codegen.CurrentMethodDef.AddLocals (\r
+ (ArrayList) $3);\r
+ }\r
+ | D_LOCALS K_INIT OPEN_PARENS local_list CLOSE_PARENS\r
+ {\r
+ codegen.CurrentMethodDef.AddLocals (\r
+ (ArrayList) $4);\r
+ codegen.CurrentMethodDef.InitLocals ();\r
+ }\r
| D_ENTRYPOINT\r
+ {\r
+ codegen.CurrentMethodDef.EntryPoint ();\r
+ }\r
| D_ZEROINIT\r
| D_EXPORT OPEN_BRACKET int32 CLOSE_BRACKET\r
| D_EXPORT OPEN_BRACKET int32 CLOSE_BRACKET K_AS id\r
| scope_block\r
| D_PARAM OPEN_BRACKET int32 CLOSE_BRACKET init_opt\r
| id COLON\r
+ {\r
+ codegen.CurrentMethodDef.AddLabel ((string) $1);\r
+ }\r
| seh_block\r
| instr\r
| sec_decl\r
| data_decl\r
;\r
\r
+local_list : /* EMPTY */\r
+ | local\r
+ {\r
+ ArrayList local_list = new ArrayList ();\r
+ local_list.Add ($1);\r
+ $$ = local_list;\r
+ }\r
+ | local_list COMMA local\r
+ {\r
+ ArrayList local_list = (ArrayList) $1;\r
+ local_list.Add ($3);\r
+ }\r
+ ;\r
+\r
+local : type\r
+ {\r
+ $$ = new Local (-1, (ITypeRef) $1);\r
+ }\r
+ | type id\r
+ {\r
+ $$ = new Local (-1, (string) $2, (ITypeRef) $1);\r
+ }\r
+ | OPEN_BRACKET int32 CLOSE_BRACKET type\r
+ {\r
+ $$ = new Local ((int) $2, (ITypeRef) $4);\r
+ }\r
+ | OPEN_BRACKET int32 CLOSE_BRACKET type id\r
+ {\r
+ $$ = new Local ((int) $2, (string) $5, (ITypeRef) $4);\r
+ }\r
+ ;\r
+\r
type_spec : class_ref\r
| OPEN_BRACKET comp_name CLOSE_BRACKET\r
| OPEN_BRACKET D_MODULE comp_name CLOSE_BRACKET\r
new SimpInstr ((Op) $1));\r
}\r
| INSTR_VAR int32\r
+ {\r
+ \r
+ }\r
| INSTR_I int32\r
{\r
codegen.CurrentMethodDef.AddInstr (new\r
| INSTR_I id /* Allow variable names */\r
| INSTR_I8 int64\r
{\r
- Console.WriteLine ($1);\r
+ codegen.CurrentMethodDef.AddInstr (new\r
+ IntInstr ((IntOp) $1, (int) $2));\r
}\r
| INSTR_R float64\r
+ {\r
+ switch ((MiscInstr) $1) {\r
+ case MiscInstr.ldc_r4:\r
+ case MiscInstr.ldc_r8:\r
+ codegen.CurrentMethodDef.AddInstr (new LdcInstr ((MiscInstr) $1, (double) $2));\r
+ break;\r
+ }\r
+ }\r
| INSTR_R int64\r
+ {\r
+ switch ((MiscInstr) $1) {\r
+ case MiscInstr.ldc_r8:\r
+ codegen.CurrentMethodDef.AddInstr (new LdcInstr ((MiscInstr) $1, (double) $2));\r
+ break;\r
+ }\r
+ }\r
| INSTR_R OPEN_PARENS bytes CLOSE_PARENS\r
| INSTR_BRTARGET int32\r
+ {\r
+ // Need to add this to PEAPI \r
+ }\r
| INSTR_BRTARGET id\r
+ {\r
+ codegen.CurrentMethodDef.AddInstr (new BranchInstr ((BranchOp) $1,\r
+ codegen.CurrentMethodDef, (string) $2));\r
+ }\r
| INSTR_METHOD method_ref\r
+ {\r
+ codegen.CurrentMethodDef.AddInstr (new MethodInstr ((MethodOp) $1,\r
+ (IMethodRef) $2));\r
+ }\r
| INSTR_FIELD type type_spec DOUBLE_COLON id\r
| INSTR_FIELD type id\r
| INSTR_TYPE type_spec\r
+ {\r
+ codegen.CurrentMethodDef.AddInstr (new TypeInstr ((TypeOp) $1,\r
+ (ITypeRef) $2));\r
+ }\r
| INSTR_STRING comp_qstring\r
{\r
- if ((string) $1 == "ldstr")\r
+ if ((MiscInstr) $1 == MiscInstr.ldstr)\r
codegen.CurrentMethodDef.AddInstr (new LdstrInstr ((string) $2));\r
}\r
| INSTR_STRING K_BYTEARRAY ASSIGN OPEN_PARENS bytes CLOSE_PARENS\r
| INSTR_SIG call_conv type OPEN_PARENS sig_args CLOSE_PARENS\r
| INSTR_TOK owner_type\r
| INSTR_SWITCH OPEN_PARENS labels CLOSE_PARENS\r
+ {\r
+ codegen.CurrentMethodDef.AddInstr (new SwitchInstr ((ArrayList) $3,\r
+ codegen.CurrentMethodDef));\r
+ }\r
;\r
\r
method_ref : call_conv type type_spec DOUBLE_COLON method_name \r
- OPEN_PARENS sig_args CLOSE_PARENS\r
+ OPEN_PARENS type_list CLOSE_PARENS\r
+ {\r
+ IClassRef owner = (IClassRef) $3;\r
+ ArrayList arg_list = (ArrayList) $7;\r
+ \r
+ $$ = owner.GetMethodRef ((ITypeRef) $2, (string) $5,\r
+ (ITypeRef[]) arg_list.ToArray (typeof (ITypeRef)));\r
+ }\r
| call_conv type method_name \r
- OPEN_PARENS sig_args CLOSE_PARENS\r
+ OPEN_PARENS type_list CLOSE_PARENS\r
+ {\r
+ ArrayList arg_list = (ArrayList) $5;\r
+\r
+ $$ = new GlobalMethodRef ((ITypeRef) $2, (string) $3,\r
+ (ITypeRef[]) arg_list.ToArray (typeof (ITypeRef)));\r
+ }\r
;\r
\r
labels : /* EMPTY */\r
| id\r
+ {\r
+ ArrayList label_list = new ArrayList ();\r
+ label_list.Add ($1);\r
+ $$ = label_list;\r
+ }\r
| int32\r
+ {\r
+ ArrayList label_list = new ArrayList ();\r
+ label_list.Add ($1);\r
+ $$ = label_list;\r
+ }\r
| labels COMMA id\r
+ {\r
+ ArrayList label_list = (ArrayList) $1;\r
+ label_list.Add ($3);\r
+ }\r
| labels COMMA int32\r
+ {\r
+ ArrayList label_list = (ArrayList) $1;\r
+ label_list.Add ($3);\r
+ }\r
;\r
\r
owner_type : type_spec\r
| customattr_decl\r
;\r
\r
-dotted_name : id\r
- | dotted_name DOT id { $$ = String.Format ("{0}.{1}", $1, $3); }\r
- ;\r
-\r
comp_qstring : QSTRING\r
| comp_qstring PLUS QSTRING { $$ = String.Format ("{0}{1}", $1, $3); }\r
;\r
;\r
\r
comp_name : id\r
- | dotted_name\r
- ;\r
-\r
-dotted_name : id\r
- | dotted_name DOT id\r
+ | comp_name DOT id\r
+ {\r
+ $$ = (string) $1 + '.' + (string) $3;\r
+ }\r
;\r
\r
\r