コード例 #1
0
ファイル: Compiler.cs プロジェクト: GruntTheDivine/Hassium
        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;
        }
コード例 #2
0
 public void Accept(LambdaNode node)
 {
 }
コード例 #3
0
ファイル: Compiler.cs プロジェクト: GruntTheDivine/Hassium
 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);
 }