示例#1
0
 public void Parse_LocalDeclarationStatement(LocalModifier m)
 {
     this.local_variables.Clear();
     base.DECLARE_SWITCH = true;
     base.DECLARATION_CHECK_SWITCH = true;
     ArrayList list = new ArrayList();
     ArrayList list2 = new ArrayList();
     this.Call_SCANNER();
     do
     {
         int num = 0x10;
         do
         {
             int num2 = this.Parse_Ident();
             this.Gen(base.code.OP_DECLARE_LOCAL_VARIABLE, num2, base.CurrSubId, 0);
             this.local_variables.Add(num2);
             if (m == LocalModifier.Static)
             {
                 base.SetStaticLocalVar(num2);
             }
             if (base.IsCurrText('('))
             {
                 IntegerList bounds = new IntegerList(true);
                 string str = this.Parse_ArrayNameModifier(bounds);
                 list.Add(bounds);
                 list2.Add(str);
             }
             else
             {
                 list.Add(null);
                 list2.Add(null);
             }
         }
         while (base.CondMatch(','));
         base.DECLARE_SWITCH = false;
         if (base.IsCurrText("As"))
         {
             this.Match("As");
             bool flag = base.curr_token.id == base.DATETIME_CLASS_id;
             if (base.IsCurrText("New") || flag)
             {
                 if (base.IsCurrText("New"))
                 {
                     this.Match("New");
                     flag = base.curr_token.id == base.DATETIME_CLASS_id;
                 }
                 num = this.Parse_Type();
                 if (this.local_variables.Count == 1)
                 {
                     if (list2[0] != null)
                     {
                         base.RaiseError(true, "VB00003. Arrays cannot be declared with 'New'");
                     }
                     int res = this.local_variables[0];
                     this.Gen(base.code.OP_CREATE_OBJECT, num, 0, res);
                     if (base.IsCurrText('('))
                     {
                         this.Match('(');
                         this.Gen(base.code.OP_CALL, num, this.Parse_ArgumentList(')', num, res), 0);
                         this.Match(')');
                     }
                     else
                     {
                         this.Gen(base.code.OP_BEGIN_CALL, num, 0, 0);
                         if (flag)
                         {
                             this.Gen(base.code.OP_PUSH, base.NewConst(0), 0, num);
                         }
                         this.Gen(base.code.OP_PUSH, res, 0, 0);
                         this.Gen(base.code.OP_CALL, num, 0, 0);
                     }
                 }
                 else
                 {
                     base.RaiseError(true, "VB00002. Explicit initialization is not permitted with multiple variables declared with a single type specifier.");
                 }
             }
             else
             {
                 num = this.Parse_TypeEx();
             }
         }
         else if (this.OPTION_STRICT)
         {
             base.RaiseError(false, "VB00006. Option Strict On requires all variable declarations to have an 'As' clause.");
         }
         for (int i = 0; i < this.local_variables.Count; i++)
         {
             int num5 = this.local_variables[i];
             if (list2[i] != null)
             {
                 string str2 = (string) list2[i];
                 int id = num;
                 int num7 = base.NewVar();
                 base.SetName(num7, base.GetName(id) + str2);
                 this.Gen(base.code.OP_EVAL_TYPE, id, 0, num7);
                 this.Gen(base.code.OP_ASSIGN_TYPE, num5, num7, 0);
                 IntegerList list4 = (IntegerList) list[i];
                 this.Gen(base.code.OP_CREATE_OBJECT, num7, 0, num5);
                 int count = list4.Count;
                 if (count > 0)
                 {
                     this.Gen(base.code.OP_BEGIN_CALL, num7, 0, 0);
                     for (int j = 0; j < count; j++)
                     {
                         this.Gen(base.code.OP_INC, list4[j], 0, list4[j]);
                         this.Gen(base.code.OP_PUSH, list4[j], 0, num7);
                     }
                     this.Gen(base.code.OP_PUSH, num5, 0, 0);
                     this.Gen(base.code.OP_CALL, num7, count, 0);
                 }
                 num = num7;
             }
             else
             {
                 this.Gen(base.code.OP_ASSIGN_TYPE, num5, num, 0);
             }
         }
         if (base.IsCurrText('='))
         {
             base.DECLARE_SWITCH = false;
             this.Match('=');
             if (this.local_variables.Count == 1)
             {
                 int num10 = this.local_variables[0];
                 if (base.IsCurrText('{'))
                 {
                     this.Gen(base.code.OP_ASSIGN, num10, this.Parse_ArrayInitializer(num), num10);
                 }
                 else
                 {
                     this.Gen(base.code.OP_ASSIGN, num10, this.Parse_Expression(), num10);
                 }
                 this.Gen(base.code.OP_INIT_STATIC_VAR, num10, 0, 0);
             }
             else
             {
                 base.RaiseError(true, "VB00002. Explicit initialization is not permitted with multiple variables declared with a single type specifier.");
             }
             base.DECLARE_SWITCH = true;
         }
         else
         {
             for (int k = 0; k < this.local_variables.Count; k++)
             {
                 int num12 = this.local_variables[k];
                 this.Gen(base.code.OP_CHECK_STRUCT_CONSTRUCTOR, num, 0, num12);
             }
         }
         base.DECLARE_SWITCH = true;
     }
     while (base.CondMatch(','));
     base.DECLARE_SWITCH = false;
     base.DECLARATION_CHECK_SWITCH = false;
     this.MatchStatementTerminator();
 }
示例#2
0
 public void Parse_LocalDeclarationStatement(LocalModifier m)
 {
     this.local_variables.Clear();
     base.DECLARE_SWITCH = true;
     base.DECLARATION_CHECK_SWITCH = true;
     this.Call_SCANNER();
     do
     {
         int num = 0x10;
         do
         {
             int num2 = this.Parse_Ident();
             this.Gen(base.code.OP_DECLARE_LOCAL_VARIABLE, num2, base.CurrSubId, 0);
             this.local_variables.Add(num2);
         }
         while (base.CondMatch(','));
         base.DECLARE_SWITCH = false;
         if (m == LocalModifier.Var)
         {
             this.Match(":");
             num = this.Parse_Type();
         }
         else if (base.IsCurrText(":"))
         {
             this.Match(":");
             num = this.Parse_Type();
         }
         for (int i = 0; i < this.local_variables.Count; i++)
         {
             int num4 = this.local_variables[i];
             this.Gen(base.code.OP_ASSIGN_TYPE, num4, num, 0);
         }
         if (base.IsCurrText('='))
         {
             base.DECLARE_SWITCH = false;
             this.Match('=');
             if (this.local_variables.Count == 1)
             {
                 int num5 = this.local_variables[0];
                 this.Gen(base.code.OP_ASSIGN, num5, this.Parse_Expression(), num5);
             }
             else
             {
                 base.RaiseError(true, "VB00002. Explicit initialization is not permitted with multiple variables declared with a single type specifier.");
             }
             base.DECLARE_SWITCH = true;
         }
         else
         {
             for (int j = 0; j < this.local_variables.Count; j++)
             {
                 int res = this.local_variables[j];
                 this.Gen(base.code.OP_CHECK_STRUCT_CONSTRUCTOR, num, 0, res);
             }
         }
         base.DECLARE_SWITCH = true;
     }
     while (base.CondMatch(','));
     base.DECLARE_SWITCH = false;
     base.DECLARATION_CHECK_SWITCH = false;
     this.Match(";");
 }