public static TypeSymbol MakeScalarTypeSymbol(string typeName, ITypeScope enclosingScope) { var type = new ScalarType(typeName); return new TypeSymbol(typeName, enclosingScope, type, TypeSymbolKind.Scalar); }
private IType DefineArrayType(ScalarType nodeScalarType) { var sym = TypeSymbol.MakeArrayTypeSymbol(nodeScalarType, _globalScope); sym.SuperClass = _globalScope.ResolveArrayType(MiniJavaInfo.AnyType); _globalScope.Define(sym); return sym.Type; }
public static TypeSymbol MakeArrayTypeSymbol(ScalarType elementType, ITypeScope enclosingScope) { var type = new ArrayType(elementType); return new TypeSymbol(type.Name, enclosingScope, type, TypeSymbolKind.Array); }
// Check implemented according to description in: // http://docs.oracle.com/javase/specs/jls/se7/html/jls-8.html#jls-8.1.4 private bool ClassDependsOnSelf(ScalarType classSymbol) { ScalarType currentClass = classSymbol; while (currentClass.SuperType != null && currentClass.SuperType != classSymbol) { currentClass = currentClass.SuperType; } return currentClass.SuperType == classSymbol; }
private IType BuildType(Declaration node, ScalarType nodeScalarType) { IType actualType; if (node.IsArray) { var arraySymbol = _globalScope.ResolveArrayType(node.TypeName); if (arraySymbol == null) { actualType = DefineArrayType(nodeScalarType); } else { actualType = arraySymbol.Type; } } else { actualType = nodeScalarType; } return actualType; }
public static string MakeArrayTypeName(ScalarType elementType) { return String.Format("{0}[]", elementType.Name); }
public ArrayType(ScalarType elementType) { Name = MakeArrayTypeName(elementType); ElementType = elementType; }
private bool IsDerivedFrom(ScalarType other) { if (other == null) { return false; } if (Equals(other)) { return true; } return SuperType != null && SuperType.IsDerivedFrom(other); }