示例#1
0
        private HassiumMethod compileLambda(LambdaNode node)
        {
            var temp = method;
            method = new HassiumMethod();
            method.Name = "lambda";
            method.Parent = temp.Parent;
            table.PushScope();

            foreach (AstNode param in node.Parameters.Children)
            {
                string name = ((IdentifierNode)param).Identifier;
                if (!table.ContainsSymbol(name))
                    table.AddSymbol(name);
                method.Parameters.Add(new FuncParameter(name), table.GetSymbol(name));
            }

            node.Body.VisitChildren(this);
            table.PopScope();

            var ret = method;
            method = temp;
            return ret;
        }
 public void Accept(LambdaNode node)
 {
 }
示例#3
0
 public void Accept(LambdaNode node)
 {
     var lambda = compileLambda(node);
     int hash = lambda.GetHashCode();
     if (!module.ObjectPool.ContainsKey(hash))
         module.ObjectPool.Add(hash, lambda);
     method.Emit(node.SourceLocation, InstructionType.PushObject, hash);
     method.Emit(node.SourceLocation, InstructionType.BuildClosure);
 }