mirror of
https://github.com/adelphes/android-dev-ext.git
synced 2025-12-22 17:39:19 +00:00
tidy array constructors and fix some warnings
This commit is contained in:
@@ -1004,7 +1004,7 @@ function isArrayAssignable(variable_type, value) {
|
||||
if (value.elements.length === 0) {
|
||||
return true;
|
||||
}
|
||||
const required_element_type = variable_type.arrdims > 1 ? new ArrayType(variable_type.base, variable_type.arrdims - 1) : variable_type.base;
|
||||
const required_element_type = variable_type.elementType;
|
||||
for (let i=0; i < value.elements.length; i++) {
|
||||
const element = value.elements[i];
|
||||
let is_assignable;
|
||||
@@ -1751,7 +1751,7 @@ function arrayElementOrConstructor(tokens, open_array, matches, index) {
|
||||
.filter(v => v.type instanceof ArrayType)
|
||||
.map(v => new ArrayElement(v, index));
|
||||
|
||||
const types = matches.types.map(t => t instanceof ArrayType ? new ArrayType(t.base, t.arrdims+1) : new ArrayType(t, 1));
|
||||
const types = matches.types.map(t => new ArrayType(t, 1));
|
||||
|
||||
if (!variables[0] && !types[0]) {
|
||||
addproblem(tokens, ParseProblem.Error(open_array, `Invalid array expression: '${matches.source}' is not an array type`));
|
||||
@@ -1928,13 +1928,7 @@ function qualifiers(matches, tokens, locals, method, imports, typemap) {
|
||||
* @param {ResolvedIdent} matches
|
||||
*/
|
||||
function arrayTypeExpression(matches) {
|
||||
const types = matches.types.map(t => {
|
||||
if (t instanceof ArrayType) {
|
||||
return new ArrayType(t.base, t.arrdims + 1);
|
||||
}
|
||||
return new ArrayType(t, 1);
|
||||
});
|
||||
|
||||
const types = matches.types.map(t => new ArrayType(t, 1));
|
||||
return new ResolvedIdent(`${matches.source}[]`, [], [], types);
|
||||
}
|
||||
|
||||
|
||||
@@ -49,7 +49,7 @@ class AnyMethod extends Method {
|
||||
* @param {string} name
|
||||
*/
|
||||
constructor(name) {
|
||||
super(name, [], '');
|
||||
super(null, name, [], '');
|
||||
}
|
||||
|
||||
get returnType() {
|
||||
@@ -70,13 +70,7 @@ class Local {
|
||||
this.finalToken = modifiers.find(m => m.source === 'final') || null;
|
||||
this.name = name;
|
||||
this.decltoken = decltoken;
|
||||
if (postnamearrdims > 0) {
|
||||
this.type = (type instanceof ArrayType)
|
||||
? new ArrayType(type.base, type.arrdims + postnamearrdims)
|
||||
: new ArrayType(type, postnamearrdims);
|
||||
} else {
|
||||
this.type = type;
|
||||
}
|
||||
this.type = postnamearrdims > 0 ? new ArrayType(type, postnamearrdims): type;
|
||||
this.init = null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -198,6 +198,13 @@ class SourceInitialiser extends MethodBase {
|
||||
this._decl = decl;
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns {SourceParameter[]}
|
||||
*/
|
||||
get parameters() {
|
||||
return [];
|
||||
}
|
||||
|
||||
get returnType() {
|
||||
return PrimitiveType.map.V;
|
||||
}
|
||||
|
||||
@@ -34,6 +34,7 @@ function typeIdentList(tokens, scope, imports, typemap) {
|
||||
* @param {Map<string,JavaType>} typemap
|
||||
*/
|
||||
function typeIdent(tokens, scope, imports, typemap) {
|
||||
/** @type {JavaType[]} */
|
||||
let types = [], package_name = '';
|
||||
switch(tokens.current.kind) {
|
||||
case 'ident':
|
||||
|
||||
Reference in New Issue
Block a user