コード例 #1
0
ファイル: VisitorHelper.cs プロジェクト: pwdlugosz/Horse
        public static void AllocateMemory(Workspace Home, MemoryStruct Heap, ExpressionVisitor Evaluator, HScriptParser.DeclareMatrixLiteralContext context)
        {

            string name = context.IDENTIFIER().GetText();
            CellAffinity type = GetAffinity(context.type());
            MatrixVisitor vis = new MatrixVisitor(Home, Heap, Evaluator);
            CellMatrix mat = vis.ToMatrix(context.matrix_expression()).Evaluate();
            Heap.Arrays.Reallocate(name, mat);

        }
コード例 #2
0
ファイル: VisitorHelper.cs プロジェクト: pwdlugosz/Horse
        // Heap allocations //
        public static void AllocateMemory(Workspace Home, MemoryStruct Heap, ExpressionVisitor Evaluator, HScriptParser.DeclareScalarContext context)
        {

            string name = context.IDENTIFIER().GetText();
            CellAffinity type = GetAffinity(context.type());
            Cell value = (context.ASSIGN() != null) ? Evaluator.ToNode(context.expression()).Evaluate() : new Cell(type);

            Heap.Scalars.Reallocate(name, value);

        }
コード例 #3
0
ファイル: VisitorHelper.cs プロジェクト: pwdlugosz/Horse
        public static void AllocateMemory(Workspace Home, MemoryStruct Heap, ExpressionVisitor Evaluator, HScriptParser.DeclareMatrix2DContext context)
        {

            string name = context.IDENTIFIER().GetText();
            CellAffinity type = GetAffinity(context.type());
            int rows = (int)Evaluator.ToNode(context.expression()[0]).Evaluate().valueINT;
            int cols = (int)Evaluator.ToNode(context.expression()[1]).Evaluate().valueINT;
            CellMatrix mat = new CellMatrix(rows, cols, type);
            Heap.Arrays.Reallocate(name, mat);

        }
コード例 #4
0
ファイル: CommandCompiler.cs プロジェクト: pwdlugosz/Horse
 internal static DeclareMatrixNode RenderDeclareNode(Workspace Home, ExpressionVisitor Evaluator, HScriptParser.DeclareMatrix2DContext context)
 {
     string name = context.IDENTIFIER().GetText();
     int row = (int)Evaluator.ToNode(context.expression()[0]).Evaluate().valueINT;
     int col = (int)Evaluator.ToNode(context.expression()[1]).Evaluate().valueINT;
     CellAffinity affinity = VisitorHelper.GetAffinity(context.type());
     MNodeLiteral m = new MNodeLiteral(null, new Gidran.CellMatrix(row, 1, affinity));
     return new DeclareMatrixNode(Home.GlobalHeap, name, m);
 }