List<Expression> indices = expr.get_indices ();
int rank = indices.size;
- var container_type = expr.container.value_type.data_type;
-
var ccontainer = (CCodeExpression) expr.container.ccodenode;
var cindex = (CCodeExpression) indices[0].ccodenode;
if (expr.container.symbol_reference is ArrayLengthField) {
} else {
Report.error (expr.source_reference, "only integer literals supported as index");
}
- } else if (container_type == string_type.data_type) {
- // should be moved to a different module
-
- // access to unichar in a string
- var coffset = new CCodeBinaryExpression (CCodeBinaryOperator.PLUS, ccontainer, cindex);
-
- var ccall = new CCodeFunctionCall (new CCodeIdentifier ("g_utf8_get_char"));
- ccall.add_argument (coffset);
-
- expr.ccodenode = ccall;
} else {
// access to element in an array
for (int i = 1; i < rank; i++) {
}
} else if (pointer_type != null && !pointer_type.base_type.is_reference_type_or_type_parameter ()) {
value_type = pointer_type.base_type.copy ();
- } else if (analyzer.context.profile == Profile.GOBJECT && container_type == analyzer.string_type.data_type) {
- if (get_indices ().size != 1) {
- error = true;
- Report.error (source_reference, "Element access with more than one dimension is not supported for strings");
- return false;
- }
-
- value_type = analyzer.unichar_type;
} else if (analyzer.context.profile == Profile.DOVA && container_type == analyzer.tuple_type.data_type) {
if (get_indices ().size != 1) {
error = true;
[CCode (cname = "g_strnfill")]
public static string nfill (size_t length, char fill_char);
+ public char get (long index) {
+ return ((char*) this)[index];
+ }
+
[CCode (cname = "g_utf8_next_char")]
public unowned string next_char ();
[CCode (cname = "g_utf8_get_char")]