Mercurial > lcfOS
diff python/c3/scope.py @ 288:a747a45dcd78
Various styling work
author | Windel Bouwman |
---|---|
date | Thu, 21 Nov 2013 14:26:13 +0100 |
parents | e64bae57cda8 |
children |
line wrap: on
line diff
--- a/python/c3/scope.py Thu Nov 21 11:57:27 2013 +0100 +++ b/python/c3/scope.py Thu Nov 21 14:26:13 2013 +0100 @@ -1,5 +1,6 @@ from . import astnodes + class Scope: """ A scope contains all symbols in a scope """ def __init__(self, parent=None): @@ -49,6 +50,12 @@ return 'Scope with {} symbols'.format(len(self.symbols)) +def createBuiltins(scope): + for tn in ['u64', 'u32', 'u16', 'u8']: + scope.addSymbol(astnodes.BaseType(tn)) + for t in [intType, doubleType, voidType, boolType, stringType, byteType]: + scope.addSymbol(t) + # buildin types: intType = astnodes.BaseType('int') intType.bytesize = 4 @@ -58,12 +65,6 @@ stringType = astnodes.BaseType('string') byteType = astnodes.BaseType('byte') -def createBuiltins(scope): - for tn in ['u64', 'u32', 'u16', 'u8']: - scope.addSymbol(astnodes.BaseType(tn)) - for t in [intType, doubleType, voidType, boolType, stringType, byteType]: - scope.addSymbol(t) - +# Create top level scope: topScope = Scope() createBuiltins(topScope) -