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); }
// 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); }
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); }
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); }