コード例 #1
0
        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();
        }
コード例 #2
0
ファイル: LocalItem.cs プロジェクト: will14smith/JavaCompiler
 public LocalItem(ByteCodeGenerator generator, Variable localVariable)
     : this(generator, localVariable.Type, localVariable.Index)
 {
 }
コード例 #3
0
 public void UndefineVariable(Variable variable)
 {
     UndefineVariable(variable.Index);
 }
コード例 #4
0
        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];
        }