Exemplo n.º 1
0
 internal override void Accept(NodeVar var)
 {
     builder.currentLineNumber = var.StartLine;
     var.vars.ForEach(def =>
     {
         if (def.Value == null)
             builder.OpNull();
         else def.Value.Visit(this);
         builder.OpKStore(def.Key);
         if (!var.isResultRequired)
             builder.OpPop();
     });
 }
Exemplo n.º 2
0
 internal virtual void Accept(NodeVar var)
 {
     builder.currentLineNumber = var.StartLine;
     var.vars.ForEach(def =>
     {
         if (def.Value != null)
             def.Value.Visit(this);
         else builder.OpNull();
         uint local;
         builder.AddLocal(def.Key, out local);
         builder.OpLStore(local);
         if (!var.isResultRequired)
             builder.OpPop();
     });
 }
Exemplo n.º 3
0
 void ASTVisitor.Accept(NodeVar value)
 {
     Accept(value);
 }
Exemplo n.º 4
0
        private Node ParseVar()
        {
            // The first token we'll have is 'var', so skip it.
            var var = new NodeVar(Location);
            Advance();

            // Now, let's get us some variables!
            while (true)
            {
                if (!TokensRemain)
                {
                    log.Error(tokens[-1].location, "End of file reached, expected a variable declaration.");
                    break;
                }

                // Variables are all identifiers, so do that.
                string name;
                ExpectIdentifier(out name, "");

                Node value = null;
                // Vars don't have to be assigned to initially, they default to null.
                // Initialization?
                if (Check(ASSIGN))
                {
                    Advance();
                    value = Expression();
                }

                // Add it to our var list
                var.vars.Add(new KeyValuePair<string, Node>(name, value));

                // If there's a comma, we expect another definition:
                if (Check(COMMA))
                    Advance();
                else break;
            }

            return var;
        }