Esempio n. 1
0
 public void addTypeSynonym(string name, TypeVariable[] typeParameters, IType type)
 {
     if (parentScope != null)
     {
         parentScope.addTypeSynonym(name, typeParameters, type);
     }
     else
     {
         typeMap[name] = new TypeSynonym(name, typeParameters, type);
     }
 }
Esempio n. 2
0
        protected ScopeImp(Scope parentScope)
        {
            this.parentScope   = parentScope;
            variableMap        = new Dictionary <string, ProgramVariable>();
            procedureMap       = new Dictionary <string, Procedure>();
            typeConstructorMap = new Dictionary <string, TypeConstructor>();
//            freshProgramVariableIndex = 0;

//            freshBoundVariableIndex = 0;

            myFunctionTemplates = new Dictionary <string, FunctionTemplate>();

            typeFactory       = new TypeFactory(this);
            expressionFactory = new ExpressionFactory(this);

            if (parentScope == null)
            {
                typeMap            = new Dictionary <string, TypeSynonym>();
                typeMap["Integer"] = new TypeSynonym("Integer", new TypeVariable[0], IntegerType.integerType);
                typeMap["Boolean"] = new TypeSynonym("Boolean", new TypeVariable[0], BooleanType.booleanType);

                standardFunctionTemplates = new Dictionary <string, FunctionTemplate>();
//                standardFunctionTemplates.Add("!=" , BasicFunctionTemplate.ne);
                standardFunctionTemplates.Add("==", BFunctionTemplate.eq);
                standardFunctionTemplates.Add("==<>", BFunctionTemplate.eqG);

                standardFunctionTemplates.Add(BFunctionTemplate.iteName, BFunctionTemplate.ite);

                standardFunctionTemplates.Add("<:", BFunctionTemplate.po);

                standardFunctionTemplates.Add("!", BFunctionTemplate.not);
                standardFunctionTemplates.Add("&&", BFunctionTemplate.and);
                standardFunctionTemplates.Add("||", BFunctionTemplate.or);
                standardFunctionTemplates.Add("==>", BFunctionTemplate.implication);
                standardFunctionTemplates.Add("<==>", BFunctionTemplate.equivalence);

                standardFunctionTemplates.Add("+", BFunctionTemplate.plus);
                standardFunctionTemplates.Add("-", BFunctionTemplate.minus);
                standardFunctionTemplates.Add("*", BFunctionTemplate.mul);
                standardFunctionTemplates.Add("div", BFunctionTemplate.div);
                standardFunctionTemplates.Add("mod", BFunctionTemplate.mod);

                standardFunctionTemplates.Add("<", BFunctionTemplate.lt);
                standardFunctionTemplates.Add(">", BFunctionTemplate.gt);
                standardFunctionTemplates.Add("<=", BFunctionTemplate.le);
                standardFunctionTemplates.Add(">=", BFunctionTemplate.ge);
            }
            else
            {
                typeMap = null;
            }
        }