示例#1
0
        public override void BeforeVisit(VariableDef def)
        {
            base.BeforeVisit(def);

            DebugAssert.IsFalse(this.IsInImportScope, "Cannot be in import scope while building symbols for a VariableDef");

            if(_scopeStack.Peek().Items.ContainsKey(def.Name.Text))
                _errorCollector.VariableAlreadyDefined(def.Name);

            if(this.IsInGlobalScope)
                def.GetExtension<SymbolExtension>().Symbol = _scopeStack.Peek().Add(new HappyNamedExpressionSymbol(def.Name.Text, _getGlobalGetter, _setGlobalGetter));
            else
                def.GetExtension<SymbolExtension>().Symbol = _scopeStack.Peek().Add(def.Name.Text);
        }
示例#2
0
 public override void AfterVisit(VariableDef node)
 {
     if (node.InitializerExpression != null)
         _expressionStack.Push(node, node.GetExtension<SymbolExtension>().Symbol.GetSetExpression(_expressionStack.Pop()));
     base.AfterVisit(node);
 }