Пример #1
0
 def __init__(self, genericArgs):
     super(GenericSetClassImpl, self).__init__(GenericSetClassImpl.genericParams, genericArgs)
     self.addDef(SimpleTypeFunc(self, 'size() => int'))
     self.addDef(SimpleTypeFunc(self, 'clear()'))
     self.addDef(CustomTypeFunc(self, makeFuncProto('add', ast.makePrimitiveType('void'), [self.createElementType()])))
     self.addDef(CustomTypeFunc(self, makeFuncProto('remove', ast.makePrimitiveType('void'), [self.createElementType()])))
     self.addDef(CustomTypeFunc(self, makeFuncProto('contains', ast.makePrimitiveType('bool'), [self.createElementType()])))
     self.addDef(GenericSetEachFunc(self))
Пример #2
0
 def __init__(self, genericArgs):
     super(GenericDictClassImpl, self).__init__(GenericDictClassImpl.genericParams, genericArgs)
     self.addDef(SimpleTypeFunc(self, 'size() => int', evaluator=len))
     self.addDef(SimpleTypeFunc(self, 'clear()', evaluator=lambda d:d.clear()))
     self.addDef(CustomTypeFunc(self, makeFuncProto('get', self.createValueType(), [self.createKeyType(), self.createValueType()])))
     self.addDef(CustomTypeFunc(self, makeFuncProto('set', ast.makePrimitiveType('void'), [self.createKeyType(), self.createValueType()])))
     self.addDef(CustomTypeFunc(self, makeFuncProto('add', ast.makePrimitiveType('void'), [self.createKeyType(), self.createValueType()])))
     self.addDef(CustomTypeFunc(self, makeFuncProto('remove', ast.makePrimitiveType('void'), [self.createKeyType()])))
     self.addDef(CustomTypeFunc(self, makeFuncProto('contains', ast.makePrimitiveType('bool'), [self.createKeyType()])))
     self.addDef(GenericDictEachFunc(self))
Пример #3
0
 def __init__(self, genericArgs):
     super(GenericListClassImpl, self).__init__(GenericListClassImpl.genericParams, genericArgs)
     self.addDef(SimpleTypeFunc(self, 'size() => int', evaluator=len))
     self.addDef(SimpleTypeFunc(self, 'empty() => bool', evaluator=lambda left:len(left)==0))
     self.addDef(SimpleTypeFunc(self, 'clear()', evaluator=del_list))
     self.addDef(CustomTypeFunc(self, makeFuncProto('set', ast.makePrimitiveType('void'), [ast.makePrimitiveType('int'), self.createElementType()])))
     self.addDef(CustomTypeFunc(self, makeFuncProto('flatten', self.createElementType(), [self.createCollectionType()])))
     self.addDef(CustomTypeFunc(self, makeFuncProto('swap', ast.makePrimitiveType('void'), [self.createCollectionType()])))
     self.addDef(CustomTypeFunc(self, makeFuncProto('append', ast.makePrimitiveType('void'), [self.createElementType()])))
     self.addDef(CustomTypeFunc(self, makeFuncProto('extend', ast.makePrimitiveType('void'), [self.createCollectionType()])))
     self.addDef(CustomTypeFunc(self, makeFuncProto('insert', ast.makePrimitiveType('void'), [ast.makePrimitiveType('int'), self.createElementType()])))
     self.addDef(CustomTypeFunc(self, makeFuncProto('remove', ast.makePrimitiveType('void'), [self.createElementType()])))
     self.addDef(CustomTypeFunc(self, 'removeAt(int)'))
     self.addDef(CustomTypeFunc(self, makeFuncProto('contains', ast.makePrimitiveType('bool'), [self.createElementType()])))
     self.addDef(GenericListEachFunc(self))
     self.ops = {'==' : operator.eq, '!=':operator.ne,
     '+':operator.add,'*':operator.mul}
Пример #4
0
 def __init__(self, cls):
     argtype = makeFuncSpec(ast.makePrimitiveType('void'), [cls.createType()])
     super(IntegerTimesFunc, self).__init__(cls, makeFuncProto('times', ast.makePrimitiveType('void'), [argtype]))
Пример #5
0
 def __init__(self, cls):
     argtype = makeFuncSpec(ast.makePrimitiveType('void'), [cls.createElementType(), ast.makePrimitiveType('int')])
     super(GenericArrayEachFunc, self).__init__(cls, makeFuncProto('each', ast.makePrimitiveType('void'), [argtype]))
Пример #6
0
 def __init__(self, cls):
     argtype = makeFuncSpec(ast.makePrimitiveType('void'), [cls.createKeyType(), cls.createValueType()])
     super(GenericDictEachFunc, self).__init__(cls, makeFuncProto('each', ast.makePrimitiveType('void'), [argtype]))