コード例 #1
0
ファイル: CodeGenContext.cs プロジェクト: erikeidt/Draconum
        public void GenerateVariableDeclaration(VariableTreeNode node)
        {
            var opcode = ".decl";

            OutLine(String.Format("    {0}{2}{1}", opcode, node.Value, _argumentPosition.Substring(opcode.Length)));
        }
コード例 #2
0
        protected void GenerateLHSValue(CodeGenContext context, AbstractSyntaxTree target, VariableTreeNode variable)
        {
            if (target == null)
            {
                // An address was generated onto the stack.
                //	We need to use this address twice, as in a[i] += 4;
                //		we need to read a[i] once, and write a[i] once,
                //		from the same pointer computation
                context.GenerateInstruction("DUP");

                // and now we'll convert one of them into the value at that location
                context.GenerateInstruction("Indirection");
            }
            else if (variable != null)
            {
                context.GenerateInstruction("PUSH", variable.Value.ToString());
            }
            else
            {
                throw new AssertionFailedException("unexpected result for LHS");
            }
        }