TemplateType(JSTypeRegistry registry, String name, Node typeTransformation) { super(registry, registry.getNativeObjectType(JSTypeNative.UNKNOWN_TYPE)); this.name = name; this.typeTransformation = typeTransformation; }
TemplateType(JSTypeRegistry registry, String name, Node typeTransformation) { super(registry, registry.getNativeObjectType(JSTypeNative.UNKNOWN_TYPE)); this.name = name; this.typeTransformation = typeTransformation; }
private JSType coerseToThisType(JSType type) { return type != null ? type : registry.getNativeObjectType( JSTypeNative.UNKNOWN_TYPE); }
@Override public ObjectType getImplicitPrototype() { return registry.getNativeObjectType(JSTypeNative.OBJECT_TYPE); }
@Override public ObjectType getImplicitPrototype() { return registry.getNativeObjectType(JSTypeNative.OBJECT_TYPE); }
private JSType getUnknownType() { return registry.getNativeObjectType(JSTypeNative.UNKNOWN_TYPE); }
@Override public ObjectType getImplicitPrototype() { return registry.getNativeObjectType(JSTypeNative.OBJECT_TYPE); }
/** * Create a named type based on the reference. */ NamedType(JSTypeRegistry registry, String reference, String sourceName, int lineno, int charno) { super(registry, registry.getNativeObjectType(JSTypeNative.UNKNOWN_TYPE)); Preconditions.checkNotNull(reference); this.reference = reference; this.sourceName = sourceName; this.lineno = lineno; this.charno = charno; }
/** Gets the type of {@code this} in this function. */ @Override public final JSType getTypeOfThis() { return typeOfThis.isEmptyType() ? registry.getNativeObjectType(JSTypeNative.UNKNOWN_TYPE) : typeOfThis; }
/** * Returns an `Iterable` type templated on {@code elementType}. * * <p>Example: `number' => `Iterable<number>`. */ static final JSType createIterableTypeOf(JSType elementType, JSTypeRegistry typeRegistry) { return typeRegistry.createTemplatizedType( typeRegistry.getNativeObjectType(JSTypeNative.ITERABLE_TYPE), elementType); }
/** * Gets the type of {@code this} in this function. */ @Override public JSType getTypeOfThis() { return typeOfThis.isEmptyType() ? registry.getNativeObjectType(JSTypeNative.UNKNOWN_TYPE) : typeOfThis; }
/** * Creates a record. Fails if any duplicate property names were added. * @return The record type. */ public JSType build() { // If we have an empty record, simply return the object type. if (isEmpty) { return registry.getNativeObjectType(JSTypeNative.OBJECT_TYPE); } return new RecordType(registry, properties.build(), isDeclared); }
/** * Resolve the referenced type within the enclosing scope. */ @Override JSType resolveInternal(ErrorReporter t, StaticTypedScope<JSType> enclosing) { warning(t, "Namespaces not supported yet (" + getReferenceName() + ")"); return registry.getNativeObjectType(JSTypeNative.UNKNOWN_TYPE); } }
@Override public TypeI convertMethodToFunction() { List<JSType> paramTypes = new ArrayList<JSType>(); paramTypes.add(getTypeOfThis()); for (Node param : getParameters()) { paramTypes.add(param.getJSType()); } return registry.createFunctionTypeWithInstanceType( registry.getNativeObjectType(JSTypeNative.UNKNOWN_TYPE), getReturnType(), paramTypes); }
TypedScopeCreator(AbstractCompiler compiler, CodingConvention codingConvention) { this.compiler = compiler; this.validator = compiler.getTypeValidator(); this.codingConvention = codingConvention; this.typeRegistry = compiler.getTypeRegistry(); this.typeParsingErrorReporter = typeRegistry.getErrorReporter(); this.unknownType = typeRegistry.getNativeObjectType(UNKNOWN_TYPE); }
private JSType convertMethodToFunction(FunctionType method) { List<JSType> paramTypes = new ArrayList<>(); paramTypes.add(method.getTypeOfThis()); for (Node param : method.getParameters()) { paramTypes.add(param.getJSType()); } ObjectType unknown = compiler.getTypeRegistry().getNativeObjectType(JSTypeNative.UNKNOWN_TYPE); return compiler.getTypeRegistry().createFunctionTypeWithInstanceType( unknown, method.getReturnType(), paramTypes); }
private void handleTypeCycle(ErrorReporter reporter) { setReferencedType( registry.getNativeObjectType(JSTypeNative.UNKNOWN_TYPE)); warning(reporter, "Cycle detected in inheritance chain of type " + reference); setResolvedTypeInternal(getReferencedType()); }
private void handleTypeCycle(ErrorReporter t) { setReferencedType( registry.getNativeObjectType(JSTypeNative.UNKNOWN_TYPE)); warning(t, "Cycle detected in inheritance chain of type " + reference); setResolvedTypeInternal(getReferencedType()); }
Node createArraylit(Node... elements) { Node result = IR.arraylit(elements); if (isAddingTypes()) { result.setJSType( registry.createTemplatizedType( registry.getNativeObjectType(JSTypeNative.ARRAY_TYPE), // TODO(nickreid): Use a reasonable template type. Remeber to consider SPREAD. getNativeType(JSTypeNative.UNKNOWN_TYPE))); } return result; }
TypedScopeCreator(AbstractCompiler compiler, CodingConvention codingConvention) { this.compiler = compiler; this.runsAfterNTI = compiler.getOptions().getNewTypeInference(); this.validator = compiler.getTypeValidator(); this.codingConvention = codingConvention; this.typeRegistry = compiler.getTypeRegistry(); this.typeParsingErrorReporter = this.runsAfterNTI ? NullErrorReporter.forOldRhino() : typeRegistry.getErrorReporter(); this.unknownType = typeRegistry.getNativeObjectType(UNKNOWN_TYPE); }