示例#1
0
 /// <summary>
 /// Save to a local variable
 /// </summary>
 /// <param name="id">Variable</param>
 public void EmitSaveVariable(ScopeVariable var)
 {
     GetMethodProcessor().Emit(OpCodes.Stloc, var.Var);
 }
示例#2
0
文件: Scope.cs 项目: menozz/mirelle
        /// <summary>
        /// Declare a local variable in the current subscope
        /// </summary>
        /// <param name="name">Variable name</param>
        /// <param name="typeName">Variable type as string</param>
        /// <param name="type">Variable type as TypeReference</param>
        /// <returns></returns>
        public ScopeVariable Introduce(string typeName, TypeReference type, string name = null)
        {
            if (name == null || name == "")
            name = CreateNewName();

              if (Exists(name))
            throw new CompilerException(String.Format(Resources.errVariableRedefinition, name));

              var actualVariable = new VariableDefinition(name, type);
              var local = new ScopeVariable(name, typeName, actualVariable);
              Method.Body.Variables.Add(actualVariable);
              Data.Peek().Add(name, local);

              return local;
        }
示例#3
0
 /// <summary>
 /// Load a variable address
 /// </summary>
 /// <param name="id">Variable</param>
 public void EmitLoadVariableAddress(ScopeVariable var)
 {
     GetMethodProcessor().Emit(OpCodes.Ldloca, var.Var);
 }