public override Val Evaluate(IContext context) { for (int i = 0; i < _param.Count; i++) { Val p = _param[i].Evaluate(context); oparam[i] = p.Value; } if (_dimensions == null || _dimensions.Length == 0) { object o = Activator.CreateInstance(_type, oparam); return(new Val(o)); } else { int[] x = _first_dimensions; if (_first_indices != null) { for (int i = 0; i < _first_indices.Length; i++) { Val v = _first_indices[i].Evaluate(context); try { x[i] = v.Cast <int>(); } catch { throw new EvalException(this, Resource.Strings.Error_EvalException_InvalidArrayIndex); } } } Type t = _type; for (int i = _dimensions.Length - 1; i > 0; i--) { int d = _dimensions[i]; if (d == 1) { t = t.MakeArrayType(); // vector array } else { t = t.MakeArrayType(d); // multidimensional array } } Array a = Array.CreateInstance(t, x); if (_first_element != null) { Val v = _first_element.Evaluate(context); try { Array va = v.Cast <Array>(); for (int i = 0; i < va.Length; i++) { int[] index = ArrayLiteral.GetIndex(x, i); a.SetValue(va.GetValue(index), index); } } catch { throw new EvalException(this, Resource.Strings.Error_EvalException_InvalidArrayIndex); } } return(new Val(a)); } }