| Commit message (Collapse) | Author | Age |
|
|
|
|
|
|
|
|
|
| |
This happens in for loops, list comprehensions and simple assigment.
e.g.
a, b = expr
[a for a, b in expr]
--
MOS_MIGRATED_REVID=89123977
|
|
|
|
|
|
|
| |
Also, use LValue in ForStatement.
--
MOS_MIGRATED_REVID=89122760
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
In Python, tuples normally don't need parens, e.g.
a, b = c, d
for i, j in e: pass
However, they are sometimes required to avoid ambiguity:
fct((x, y))
[(1, 2), (3, 4)]
This distinction is handled with parseExpression vs parseNonTupleExpression.
--
MOS_MIGRATED_REVID=89118478
|
|
|
|
|
|
|
|
| |
Move castList, castMap, toMap utilities away from SkylarkFunction to SkylarkType
where the cast utility already has been moved.
--
MOS_MIGRATED_REVID=89042835
|
|
|
|
|
| |
--
MOS_MIGRATED_REVID=89020190
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This CL is just moving code from AssignmentStatement to a new class. The goal
is to share code dealing with LValues.
LValues can be found here:
- lvalue = 2
- [for lvalue in exp]
- {a: b for lvalue in exp]
- for lvalue in exp: pass
The LValue itself can have different forms:
- a
- a, b
- a[0]
- a, (b, c)
- [a[0], (b, c)]
- a[1:5]
Although we may not handle everything, we need to make sure that the same
things can be used in variable assignment and in for loops.
--
MOS_MIGRATED_REVID=89015483
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* New hierarchy BaseFunction > UserModeFunction, BuiltinFunction.
The old hierarchy still exists for now, to be deleted after migration:
Function > AbstractFunction > MixedModeFunction >
(UserModeFunction, SkylarkFunction > SimpleSkylarkFunction)
(UserModeFunction is already migrated, and
BaseFunction implements Function, for now.)
* Function supports *args and **kwargs when calling functions, and
mandatory named-only parameters in the style of Python 3.
Notable difference with Python: *args binds the variable to a tuple,
because a Skylark list would have to be monomorphic.
* A better, simpler, safer FFI using reflection with BuiltinFunction.
Handles typechecking, passes parameters in a more Java style.
(Not used for now, will be used later.)
* A new annotation @SkylarkSignature, intended to replace @SkylarkBuiltin,
supports the full function call protocol, including default arguments.
* Support for annotating function Factory-s rather than functions.
--
MOS_MIGRATED_REVID=88958581
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
*** Reason for rollback ***
This CL broke []
*** Original change description ***
Skylark: New error message in the lexer when an unsupported Python keyword is used.
--
MOS_MIGRATED_REVID=88954426
|
|
|
|
|
|
|
| |
is used.
--
MOS_MIGRATED_REVID=88930203
|
|
|
|
|
|
|
| |
In particular, struct, dict and set addition work like in Skylark files.
--
MOS_MIGRATED_REVID=88929558
|
|
|
|
|
| |
--
MOS_MIGRATED_REVID=88924033
|
|
|
|
|
| |
--
MOS_MIGRATED_REVID=88857682
|
|
|
|
|
|
|
|
|
| |
e.g. def foo(x, y): print(x); print(y)
Bug found when adding the pass statement.
--
MOS_MIGRATED_REVID=88852710
|
|
|
|
|
|
|
|
|
|
| |
Like python, print singleton tuples with a terminating comma before the closing
parenthesis, so you can read them back as tuples.
Also, have toString() call the pretty-printer for Skylark lists and tuples.
--
MOS_MIGRATED_REVID=88831764
|
|
|
|
|
| |
--
MOS_MIGRATED_REVID=88830705
|
|
|
|
|
| |
--
MOS_MIGRATED_REVID=88813915
|
|
|
|
|
| |
--
MOS_MIGRATED_REVID=88727892
|
|
|
|
|
| |
--
MOS_MIGRATED_REVID=88726457
|
|
|
|
|
| |
--
MOS_MIGRATED_REVID=88713932
|
|
|
|
|
|
|
| |
Also add tests.
--
MOS_MIGRATED_REVID=88474801
|
|
|
|
|
| |
--
MOS_MIGRATED_REVID=88440711
|
|
|
|
|
| |
--
MOS_MIGRATED_REVID=88224368
|
|
|
|
|
| |
--
MOS_MIGRATED_REVID=88149329
|
|
|
|
|
|
|
|
|
|
| |
Classes of the same EvalUtils.getSkylarkType are once again the same for the
type inferencer.
Also, for debugging purposes, only print SkylarkClassObject as struct, not all classes that implement ClassObject yet are considered disjoint by the type engine.
--
MOS_MIGRATED_REVID=87933890
|
|
|
|
|
| |
--
MOS_MIGRATED_REVID=87858855
|
|
|
|
|
| |
--
MOS_MIGRATED_REVID=87821306
|
|
|
|
|
|
|
| |
SkylarkList#toList() behaves consistently for all implementations.
--
MOS_MIGRATED_REVID=87817550
|
|
|
|
|
|
|
|
|
| |
MethodLibraryTest#testEnumerate), it returns a SkylarkList of tuples.
MethodLibrary tests are cleaned up.
--
MOS_MIGRATED_REVID=87592639
|
|
|
|
|
| |
--
MOS_MIGRATED_REVID=87535290
|
|
|
|
|
| |
--
MOS_MIGRATED_REVID=87519507
|
|
|
|
|
|
|
|
|
|
|
| |
Fix race condition in SkylarkType.of(), whereby .equals() but not same (==) types were created, by making Simple.of() synchronized.
Also make SkylarkType#includes() more robust by using .equals() instead of == (it's a little bit slower in the case of Simple types once fixed, but also works on complex types that don't hash-cons their values).
Also, distinguish SkylarkList (printed as list) and java.util.List (printed as List) and similarly for tuple vs Tuple, when printing types in debugging messages.
--
MOS_MIGRATED_REVID=87490176
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Refactor SkylarkType, notably adding Union types and runtime typechecks.
These are pre-requisites to unifying all Skylark function calls to use the same
code path, that will check types (like SkylarkFunction currently does) as well
handle a more complete Python calling convention (like MixedModeFunction is
almost but not quite able to do).
A SkylarkType can be either
* a Simple type corresponding to a Java class, with special types TOP and BOTTOM
corresponding respectively to Object and EmptyType (similar to Void).
* a Combination of a generic class (LIST, MAP or SET) and an argument type
* a Union of a finite number of types
* a FunctionType associated with a name and a returnType (with ugly
validation-time side-effects that we should probably move out of the type)
Unions are necessary because:
1- the type of some builtin function arguments are actually the Union of some
type and a function type for a callback that computes the actual value.
2- the type of some builtin function arguments declared as "List" is actually
the Union of java List and SkylarkList.
3- instead of adding lots of special cases at the point of argument validation,
it's cleaner and more generally useful to have explicit Union types, that can
then be displayed to users for documentation or debugging purposes.
Validation-time "type inference" is re-expressed simply as type intersection.
None is treated specially as inferred into TOP instead of NoneType.
Combination types are printed as genericType of argTypes, e.g. "dict of ints". "type" and "generic1" become "genericType" and "argType". In SkylarkList and SkylarkNestedSet, genericType becomes contentType.
--
MOS_MIGRATED_REVID=87340881
|
|
|
|
|
|
|
| |
exactly one segment.
--
MOS_MIGRATED_REVID=87234901
|
|
|
|
|
| |
--
MOS_MIGRATED_REVID=87154772
|
|
|
|
|
|
|
| |
Make it not depend on the iteration order on the hash table of **kwargs.
--
MOS_MIGRATED_REVID=86986044
|
|
|
|
|
|
|
| |
This fixes the visit/accept protocol for Argument.Passed.
--
MOS_MIGRATED_REVID=86799044
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This is the first meaty cl in a series to refactor the Skylark function call protocol.
1- We introduce a first-class notion of FunctionSignature, that supports positional and named-only arguments, mandatory and optional, default values, type-checking, *stararg and **kwarg;
2- To keep things clean, we distinguish two different kinds of Argument's: Argument.Passed that appears in function calls, and Parameter, that appears in function definitions.
3- We refactor the Parser so it uses this infrastructure, and make minimal changes to MixedModeFunction so that it works with it (but don't actually implement *starparam and **kwparam yet).
4- As we modify FuncallExpression, we ensure that the args and kwargs arguments it passes to the underlying function are immutable, as a prerequisite to upcoming implementation of *starparam and **kwparam as being provided directly from a skylark list or dict.
Further changes under review will take advantage of this FunctionSignature to redo all our function call protocol, to be used uniformly for both UserDefinedFunction's and builtin function. The result will be a simpler inheritance model, with better type-checking, builtin functions that are both simpler and better documented, and many redundant competing functionality-limited codepaths being merged and replaced by something better.
NB: The changes to MixedModeFunction, SkylarkFunction and MethodLibrary are temporary hacks to be done away with in an upcoming CL. The rest is the actual changes.
--
MOS_MIGRATED_REVID=86704072
|
|
|
|
|
| |
--
MOS_MIGRATED_REVID=86436572
|
|
|
|
|
|
|
|
| |
These shouldn't affect the semantic of the program in any significant way,
but will hush the linter and other such metaprograms.
--
MOS_MIGRATED_REVID=86089271
|
|
|
|
|
| |
--
MOS_MIGRATED_REVID=86087783
|
|
|
|
|
| |
--
MOS_MIGRATED_REVID=85882605
|
|
|
|
|
|
|
| |
returned by the rule implementation function doesn't have the correct generic type. Error messages are unified.
--
MOS_MIGRATED_REVID=85874511
|
|
|
|
|
| |
--
MOS_MIGRATED_REVID=85874312
|
|
|
|
|
| |
--
MOS_MIGRATED_REVID=85722639
|
|
--
MOE_MIGRATED_REVID=85702957
|