Exemple #1
0
        public void RegisterType(SynType sty)
        {
            if (this.typesDefs.ContainsKey(sty.typeName) == true)
            {
                throw new System.Exception("Attempting to register typename that is already assigned.");
            }

            this.typesDefs.Add(sty.typeName, sty);
        }
Exemple #2
0
        public SynVarValue AddVariable(string varName, SynType ty, VarDst dst, SynVarValue.VarLocation varLoc)
        {
            SynVarValue newVar = new SynVarValue();

            newVar.varLoc   = varLoc;
            newVar.varName  = varName;
            newVar.typeName = ty.typeName;
            newVar.type     = ty;

            this.AddVariable(newVar, dst);
            return(newVar);
        }
Exemple #3
0
        public AST(Token t, SynNestingBuilder builder, ASTOp ast, SynObj so, SynType sevty, bool hasAddress, DataManifest manifest, int ptrDepth, params AST [] branches)
        {
            this.builder        = builder;
            this.synthObj       = so;
            this.evaluatingType = sevty;
            this.token          = t;
            this.astType        = ast;
            this.hasAddress     = hasAddress;
            this.manifest       = manifest;
            this.ptrDepth       = ptrDepth;

            this.branches = new List <AST>(); // Should we always allocate this?
            if (branches != null && branches.Length > 0)
            {
                this.branches.AddRange(branches);
            }
        }
Exemple #4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="opName"></param>
        /// <param name="otherType"></param>
        /// <param name="reversible">If true, only reversible functions are </param>
        /// <returns></returns>
        public SynFuncDecl GetOperator(string opName, SynType otherType, OperatorReversing revMode)
        {
            string fullName = "operator" + opName;

            List <SynFuncDecl> fns;

            if (this.functions.TryGetValue(fullName, out fns) == false)
            {
                return(null);
            }

            foreach (SynFuncDecl sfc in fns)
            {
                if (sfc.parameterSet.Count != 1 || sfc.isStatic == true)
                {
                    continue;
                }

                switch (revMode)
                {
                case OperatorReversing.OnlyNonReversible:
                    if (sfc.isReversible == true)
                    {
                        continue;
                    }
                    break;

                case OperatorReversing.OnlyReversible:
                    if (sfc.isReversible == false)
                    {
                        continue;
                    }
                    break;
                }

                if (sfc.parameterSet.Get(0).type == otherType)
                {
                    return(sfc);
                }
            }

            return(null);
        }
Exemple #5
0
        WASM.Bin.TypeID GetTrueParamReturnType(SynType st)
        {
            if (st == null)
            {
                return(WASM.Bin.TypeID.Empty);
            }

            if (st.intrinsic == true)
            {
                switch (st.typeName)
                {
                case "uint8":
                case "int8":
                case "uint16":
                case "int16":
                case "uint":
                case "int":
                    return(WASM.Bin.TypeID.Int32);

                case "uint64":
                case "int64":
                    return(WASM.Bin.TypeID.Int64);

                case "float":
                    return(WASM.Bin.TypeID.Float32);

                case "double":
                    return(WASM.Bin.TypeID.Float64);
                }
            }
            else
            {
                // Return pointer back from memory stack
                return(WASM.Bin.TypeID.Int32);
            }

            throw new SynthExceptionImpossible("Could not convert synth type to true WASM type.");
        }
Exemple #6
0
 public void AddType(SynType type)
 {
     this.typesDefs.Add(type.typeName, type);
 }
Exemple #7
0
 public SynVarValue AddGlobalVar(string varName, SynType ty)
 {
     return(this.AddVariable(varName, ty, VarDst.Global, SynVarValue.VarLocation.Static));
 }
Exemple #8
0
 public SynVarValue AddLocalVariable(string varName, SynType ty)
 {
     return(this.AddVariable(varName, ty, VarDst.Local, SynVarValue.VarLocation.Local));
 }