ConversionResult?VisitInstance(INSTANCE instance) { ARRAY_TYPE arrayType = instance.type as ARRAY_TYPE; if (arrayType == null || !arrayType.isMath) { return(null); } Int32 index = RegisterArgument(instance); String access = String.Format("Access(argument{0})", index); String complete = index.ToString(); HashSet <Int32> arguments = new HashSet <Int32>(); arguments.Add(index); return(new ConversionResult(null, access, complete, arrayType.dimensions.Length, arrayType.base_type, null, arguments)); }
protected override void Visit_ARRAY_TYPE(ARRAY_TYPE node) { /* MOVE CODE HERE */ }
public static Method GetArrayInitializationMethod(String name, bool isPublic, TypeNode declaringType, ARRAY_TYPE type, SourceContext sourceContext) { //Array NewTypeName() //{ // Array Res; // Res = new Array[A.GetLength(0), A.GetLength(1)]; // for (int i1 = 0; i1 < A.GetLength(0); i1++) // Res[i1] = new Array[]; // return Res; //} TypeNode returnType = (TypeNode)type.convertAndGetType(); Method method = new Method(); method.Name = Identifier.For("New" + name); method.DeclaringType = declaringType; method.Flags = MethodFlags.Static; if (isPublic) { method.Flags |= MethodFlags.Public; } else { method.Flags |= MethodFlags.Private; } method.InitLocals = true; method.SourceContext = sourceContext; method.Body = new Block(); method.Body.Checked = false; //??? method.Body.HasLocals = true; method.Body.Statements = new StatementList(); method.ReturnType = returnType; method.Parameters = new ParameterList(); int count = 0; // Add parameters List <Expression> parameterAccess = new List <Expression>(); ARRAY_TYPE arrayType = type; while (arrayType != null) { for (int i = 0; i < arrayType.dimensions.Length; i++) { if (arrayType.dimensions[i] == null || arrayType.dimensions[i].calculate() == null) { Identifier paramName = Identifier.For("n" + count.ToString()); Parameter parameter = new Parameter(paramName, SystemTypes.Int32); method.Parameters.Add(parameter); parameterAccess.Add(paramName); count++; } } if (arrayType.base_type is ARRAY_TYPE) { arrayType = (ARRAY_TYPE)arrayType.base_type; } else { arrayType = null; } } Identifier resultName = Identifier.For("res"); LocalDeclarationsStatement loc_stmt = new LocalDeclarationsStatement(); loc_stmt.Constant = false; loc_stmt.Declarations = new LocalDeclarationList(1); loc_stmt.InitOnly = false; loc_stmt.SourceContext = sourceContext; loc_stmt.Type = returnType; LocalDeclaration local = new LocalDeclaration(); local.Name = resultName; local.SourceContext = sourceContext; loc_stmt.Declarations.Add(local); method.Body.Statements.Add(loc_stmt); method.Body.Statements.Add(createElementInitializerInternal(type, resultName, 0, parameterAccess, false, sourceContext)); Return ret = new Return(); ret.Expression = resultName; method.Body.Statements.Add(ret); return(method); }
protected virtual void Visit_ARRAY_TYPE(ARRAY_TYPE node) { }