Ejemplo n.º 1
0
        Stmt *new_stmt(StmtKind kind, SrcPos pos)
        {
            var s = (Stmt *)ast_alloc(sizeof(Stmt));

            s->pos  = pos;
            s->kind = kind;
            return(s);
        }
Ejemplo n.º 2
0
        Stmt new_stmt(StmtKind kind, SrcPos pos)
        {
            var s = new Stmt();

            s.pos  = pos;
            s.kind = kind;
            return(s);
        }
Ejemplo n.º 3
0
 public StmtState(string regBegin, string regEnd, string memBegin, string memEnd)
 {
     this.regBegin = regBegin;
     this.regEnd   = regEnd;
     this.memBegin = memBegin;
     this.memEnd   = memEnd;
     stmtKind      = StmtKind.Other;
     indenter      = null;
 }
Ejemplo n.º 4
0
 /// <summary>
 /// create a new statment node
 /// </summary>
 /// <param name="kind"></param>
 /// <param name="name"></param>
 /// <param name="Linenum"></param>
 /// <param name="scope"></param>
 public TreeNode(StmtKind kind, string name, int Linenum, string scope)
     : this()
 {
     this.NodeKind = NodeKind.stmtK;
     this.Kind     = kind;
     this.Type     = TokenType.NONE;
     this.Name     = name;
     this.LineNum  = Linenum;
     this.Scope    = scope;
 }
 public TreeNode(StmtKind stmtkind) // creates a TreeNode of Stmd kind
 {
     childrens = new TreeNode[3];
     for (int i = 0; i < 3; i++)
     {
         childrens[i] = null;
     }
     nodekind      = NodeKind.StmtK;
     this.stmtkind = stmtkind;
 }
Ejemplo n.º 6
0
 /// <summary>
 /// create a new statment node
 /// </summary>
 /// <param name="kind"></param>
 /// <param name="name"></param>
 /// <param name="Linenum"></param>
 /// <param name="scope"></param>
 public TreeNode(StmtKind kind, string name, int Linenum, string scope)
     : this()
 {
     this.NodeKind = NodeKind.stmtK;
     this.Kind = kind;
     this.Type = TokenType.NONE;
     this.Name = name;
     this.LineNum = Linenum;
     this.Scope = scope;
 }
Ejemplo n.º 7
0
            void SetKind(FileWriter writer, StmtKind kind)
            {
                if (kind == stmtKind)
                {
                    return;
                }

                indenter?.Dispose();
                indenter = null;
                switch (stmtKind)
                {
                case StmtKind.Other:
                    break;

                case StmtKind.Register:
                    writer.WriteLine(regEnd);
                    break;

                case StmtKind.Memory:
                    writer.WriteLine(memEnd);
                    break;

                default:
                    throw new InvalidOperationException();
                }

                switch (kind)
                {
                case StmtKind.Other:
                    break;

                case StmtKind.Register:
                    writer.WriteLine(regBegin);
                    indenter = writer.Indent();
                    break;

                case StmtKind.Memory:
                    writer.WriteLine(memBegin);
                    indenter = writer.Indent();
                    break;

                default:
                    throw new InvalidOperationException();
                }
                stmtKind = kind;
            }
Ejemplo n.º 8
0
        TreeNode newStmtNode(StmtKind kind)
        {
            TreeNode t = new TreeNode();
            int      i;

            if (t == null)
            {
                Console.Write("Out of memory error at line %d\n");
            }
            else
            {
                for (i = 0; i < MAXCHILDREN; i++)
                {
                    t.child.Add(null);
                }
                t.sibling   = null;
                t.nodekind  = NodeKind.StmtK;
                t.kind.stmt = kind;
            }
            return(t);
        }
Ejemplo n.º 9
0
 internal static void statements(this TextWriter trapFile, Statement stmt, StmtKind kind)
 {
     trapFile.WriteTuple("statements", stmt, (int)kind);
 }
Ejemplo n.º 10
0
 internal static Tuple statements(Statement stmt, StmtKind kind) => new Tuple("statements", stmt, kind);