public ByteCodeGenerator(CompileManager manager, Method method)
        {
            Manager = manager;
            Method = method;

            byteCodeStream = new byte[64];
            length = 0;

            variableList = new Variable[256];
            if (method.Modifiers.HasFlag(Modifier.Static))
            {
                variableCount = 0;
                MaxVariables = 0;
            }
            else
            {
                variableCount = 1;
                MaxVariables = 1;

                variableList[0] = new Variable(0, "this", method.DeclaringType);
            }
            variableListStack = new Stack<Tuple<short, Variable[]>>();

            state = new State();
        }
 public LocalItem(ByteCodeGenerator generator, Variable localVariable)
     : this(generator, localVariable.Type, localVariable.Index)
 {
 }
 public void UndefineVariable(Variable variable)
 {
     UndefineVariable(variable.Index);
 }
        public Variable DefineVariable(string name, Type type)
        {
            if (variableCount >= variableList.Length)
                throw new StackOverflowException("Cannot define any more local variables!");

            type = ClassLocator.Find(type, Manager.Imports);

            short index = FindFreeVariableIndex();

            if (pendingJumps != null) ResolvePendingJumps();

            variableList[index] = new Variable(index, name, type);
            variableCount++;

            MaxVariables = Math.Max(MaxVariables, variableCount);

            return variableList[index];
        }