]> Zhao Yanbai Git Server - acecode.git/commitdiff
learn go
authorAceVest <zhaoyanbai@126.com>
Tue, 8 Dec 2015 12:30:52 +0000 (20:30 +0800)
committerAceVest <zhaoyanbai@126.com>
Tue, 8 Dec 2015 12:30:52 +0000 (20:30 +0800)
17 files changed:
ish/Cmd.cc
ish/Common.cc
ish/Parser.cc
ish/Scanner.cc
learn/doc/ir.txt [deleted file]
learn/doc/linux [deleted file]
learn/doc/mac
learn/go/interfaces.go
learn/go/methods.go
learn/go/struct.go
learn/server/.Building.lock [deleted file]
learn/server/.sconsign.dblite [deleted file]
learn/server/BLADE_ROOT [deleted file]
learn/server/BUILD [deleted file]
learn/server/config.h [deleted file]
learn/server/server.cpp [deleted file]
tools/comm/cpuid.cc

index 1f4f481da09982d102ae6f4c3a1817145e142a73..eb3355f9acb91723d56a560dc3f388e7d5e7720d 100644 (file)
@@ -166,6 +166,7 @@ ExitCode cmd::ExecuteCommand(char **argv)
 
        //}
 
+       return 0;
 }
 
 #ifdef DEBUG_CMD
index b6384d4dc194130a334b4e09281d7e264c828144..bb7ee73d37136fe22c4845f6ff7d25465ac2b40c 100644 (file)
@@ -4,7 +4,7 @@
 
 void fatal(const char *err_msg, int n)
 {
-       fprintf(stderr,"Error: %s,%s\n",err_msg);
+       fprintf(stderr,"Error: %s\n",err_msg);
        exit(n);
 }
 void *my_malloc(size_t size)
index 58266c14ec3fb3f6edd6c85e614c804510864fa4..2b300aab678a56f29dddaca504cdf47d982a4fee 100644 (file)
@@ -244,7 +244,9 @@ ExitCode Parser::ExecuteCmd()
 
        g_redirectInFlag = g_redirectOutFlag = false;
 
+       return 0;
 }
+
 ExitCode Parser::Exp()
 {
                /*if(m_token != STRING && m_token != GETVAR)
index bcd6c51cdfa04de40eab4a006605dc9c0aa4ebf9..b56fca1c0f0aa7ebbea8329fadcc5ebeaab8f7cf 100644 (file)
@@ -275,6 +275,7 @@ void Scanner::printToken(TokenType t) const
        case GE:        cout<<"GE"<<endl;break;
        case LT:        cout<<"LT"<<endl;break;
        case LE:        cout<<"LE"<<endl;break;
+       case DO:        cout<<"DO"<<endl;break;
        }
 }
 
diff --git a/learn/doc/ir.txt b/learn/doc/ir.txt
deleted file mode 100644 (file)
index 924c296..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-电扇 IR NEC
-807FE01F    风速
-807F32CD    静音
-807FF00F    风类
-807FC03F    开关
-807FD02F    定时
-807FF00F    摇头
diff --git a/learn/doc/linux b/learn/doc/linux
deleted file mode 100644 (file)
index 2b8a097..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-
-/etc/sysconfig/network-scripts/ifcfg-eth0
-
-# multi-user.target: analogous to runlevel 3
-ln -s /lib/systemd/system/multi-user.target /etc/systemd/system/default.target
-
-
-/etc/gdm/custom.conf
-[daemon]
-AutomaticLoginEnable=true
-AutomaticLogin=root
index 78854b3cc02fb98f0ff7c85e1a80ce86e29915e0..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 100644 (file)
@@ -1,13 +0,0 @@
-iterm2
-
-curl -L https://github.com/robbyrussell/oh-my-zsh/raw/master/tools/install.sh | sh
-
-git clone git://github.com/supermarin/powerline-fonts.git
-安装 Monaco fo Powerline.otf
-
-iterm2 设置字体为以上
-
-
-
-git clone git://github.com/jeremyFreeAgent/oh-my-zsh-powerline-theme
-cp oh-my-zsh-powerline-theme/powerline.zsh-them ~/.oh-my-zsh/theme/
index e038657d8b885ce0215ecd5a490554209354c279..304af7a7cfa7f47e13bd1562d3a0a9c89153343e 100644 (file)
@@ -10,9 +10,56 @@ package main
 
 import (
        "fmt"
+       "math"
 )
 
+type Shaper interface {
+       Area() float64
+}
+
+type Square struct {
+       slide float64
+}
+
+func (s *Square) Area() float64 {
+       return s.slide*s.slide
+}
+
+type Round struct {
+       radius float64
+}
+
+func (r *Round) Area() float64 {
+       return math.Pi*r.radius*r.radius
+}
+
+
+type Rectangular struct {
+       width   float64
+       height  float64
+}
+
+func (r *Rectangular) Area() float64 {
+       return r.width*r.height
+}
+
 func main() {
        defer fmt.Println("Program Exited...")
 
+       sq := Square{12.34}
+       rd := new(Round)
+       rd.radius = 9.99
+       rt := Rectangular{0.6, 0.8}
+
+       var shaper Shaper
+       shaper = &sq
+       fmt.Println("Square Slide", sq.slide, "Area", shaper.Area())
+
+
+       // rd is pointer
+       shaper = rd
+       fmt.Println("Round Radius", rd.radius, "Area", shaper.Area())
+
+       shaper = &rt
+       fmt.Println("Rectangular Width", rt.width, "Height", rt.height, "Area", shaper.Area())
 }
index 8ceec3f78a4858d3b86dea5c4f1ec8d1c7c46e14..9da225d0387559f21fa4a14b866a22ae80107ab1 100644 (file)
@@ -42,6 +42,7 @@ func (v Vector) String() string {
        return fmt.Sprintf("Vector{x:%.4f, y:%.4f}", v.x, v.y)
 }
 
+
 // 根据现有类型定义专用类型
 type FloatType float64
 
index 16191be60138ef1e8d316d7cca7965835c4ca10b..7989a396a7798ae80ad517f28e638c5e5f88796d 100644 (file)
@@ -3,18 +3,31 @@ package main
 import "fmt"
 import "time"
 import "math/rand"
+import "reflect"
+
+type Private struct {
+       data string
+}
 
 type Vertex struct {
        X int
-       Y int
+       Y int   "Y Pos" // 字段名可以带标签
+       string  "Anonymous Field"       // 匿名字段
+       Private "Anonymous Struct"      // 在一个结构体中对于每一种数据类型只能有一个匿名字段
+       s string
 }
 
 func main() {
        rand.Seed(time.Now().UnixNano())
 
-       v := Vertex{1, 2}
+       v := Vertex{X:1, Y:2}
+
+       v.string = "anonymouse string field"
+       v.data   = "anonymouse struct field data"
        fmt.Println(v)
-       fmt.Println(Vertex{0xABC, 0xCBA})
+       fmt.Println(Vertex{X:0xABC, Y:0xCBA})
+       //fmt.Println(Vertex{0xAA, 0xBB, "anonymous string", {"anonymous data"}, "dd", "FF"})
+       fmt.Println(Vertex{0xAA, 0xBB, "anonymous string", Private{"anonymous data"}, "a"})
 
        // 通过指针间隔访问的过程是透明的
        p := &v
@@ -23,4 +36,11 @@ func main() {
        fmt.Println(v)
        v.X, v.Y = p.Y, p.X
        fmt.Println(v.X, v.Y)
+
+       // 遍历结构
+       fmt.Printf("%10v %16v %16v %10v %10v %16v %10v\n", "Name", "Type", "Tag", "Offset", "Index", "PkgPath", "Anonymous")
+       for i := 0; i < reflect.TypeOf(v).NumField(); i++ {
+               Field := reflect.TypeOf(v).Field(i)
+               fmt.Printf("%10v %16v %16v %10v %10v %16v %10v\n", Field.Name, Field.Type, Field.Tag, Field.Offset, Field.Index, Field.PkgPath, Field.Anonymous)
+       }
 }
diff --git a/learn/server/.Building.lock b/learn/server/.Building.lock
deleted file mode 100644 (file)
index e69de29..0000000
diff --git a/learn/server/.sconsign.dblite b/learn/server/.sconsign.dblite
deleted file mode 100644 (file)
index 20d822c..0000000
Binary files a/learn/server/.sconsign.dblite and /dev/null differ
diff --git a/learn/server/BLADE_ROOT b/learn/server/BLADE_ROOT
deleted file mode 100644 (file)
index e69de29..0000000
diff --git a/learn/server/BUILD b/learn/server/BUILD
deleted file mode 100644 (file)
index 84769a6..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-cc_binary(
-    name = 'server',
-    srcs = [
-        'server.cpp',
-    ],
-)
diff --git a/learn/server/config.h b/learn/server/config.h
deleted file mode 100644 (file)
index 4c67455..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-/*
- * ------------------------------------------------------------------------
- *   File Name: config.h
- *      Author: Zhao Yanbai
- *              Tue May 12 15:31:22 2015
- * Description: none
- * ------------------------------------------------------------------------
- */
-
-#pragma once
diff --git a/learn/server/server.cpp b/learn/server/server.cpp
deleted file mode 100644 (file)
index 15547bb..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-/*
- * ------------------------------------------------------------------------
- *   File Name: server.cpp
- *      Author: Zhao Yanbai
- *              Tue May 12 15:30:58 2015
- * Description: none
- * ------------------------------------------------------------------------
- */
-#include<iostream>
-using namespace std;
-
-int main(int argc, char *argv[]) {
-
-       cout << "Server is Starting ... " << endl;
-       return 0;
-}
index 77bae5ca34e2d4e92e0c0176dc4007e507f6fb54..9ba8ae716900858710fe7f323cdc1053da486604 100644 (file)
@@ -108,17 +108,47 @@ int       main()
                                "CR4.OSFXSR is available)")
        TEST_FEATURE(fv, 25, "SSE: SSE Extensions")
        TEST_FEATURE(fv, 26, "SSE2: SSE2 Extensions")
-       //TEST_FEATURE(fv, 27, "Reserved")
+       TEST_FEATURE(fv, 27, "SS: CPU Cache Supports Self-Snoop")
        TEST_FEATURE(fv, 28, "Hyper Threading Technology")
        TEST_FEATURE(fv, 29, "TM: Thermal Monitor")
-       //TEST_FEATURE(fv, 30, "Reserved")
+       TEST_FEATURE(fv, 30, "IA64 Processor Emulating X86")
        TEST_FEATURE(fv, 31, "PBE: Pending Break Enable")
 
 
-
-       
-
-
+       fv = r.ecx;
+       printf("-------------\n");
+       TEST_FEATURE(fv, 0, "SSE3: Prescott New Instructions-SSE3 (PNI)")
+       TEST_FEATURE(fv, 1, "PCLMULQDQ Support")
+       TEST_FEATURE(fv, 2, "64Bit Debug Store (EDX Bit21)")
+       TEST_FEATURE(fv, 3, "MONITOR and MWAIT Instructions (SSE3)")
+       TEST_FEATURE(fv, 4, "CPL Qualified Debug Store")
+       TEST_FEATURE(fv, 5, "VMX: Virtual Machine eXtensions")
+       TEST_FEATURE(fv, 6, "SMX: Safer Mode Extensions")
+       TEST_FEATURE(fv, 7, "EST: Enhanced SpeedStep")
+       TEST_FEATURE(fv, 8, "TM2: Thermal Monitor 2")
+       TEST_FEATURE(fv, 9, "SSSE3: Supplemental SSE3 Instructions")
+       TEST_FEATURE(fv, 10, "L1 Context ID")
+       TEST_FEATURE(fv, 11, "SDBG: Silicon Debug Interface")
+       TEST_FEATURE(fv, 12, "FMA: Fused Multiply-add (FMA3)")
+       TEST_FEATURE(fv, 13, "CX16: CMPXCHG16B Instructions")
+       TEST_FEATURE(fv, 14, "XTPR: Can Disable Sending Task Priority Messages")
+       TEST_FEATURE(fv, 15, "PDCM: Perfmon & Debug Capability")
+       //TEST_FEATURE(fv, 16, "Reserved")
+       TEST_FEATURE(fv, 17, "PCID: Process Context Identifiers (CR4 bit 17)")
+       TEST_FEATURE(fv, 18, "DCA: Direct Cache Access for DMA Writes")
+       TEST_FEATURE(fv, 19, "SSE4.1: SSE4.1 Instructions")
+       TEST_FEATURE(fv, 20, "SSE4.2: SSE4.2 Instructions")
+       TEST_FEATURE(fv, 21, "X2APIC: x2APIC Support")
+       TEST_FEATURE(fv, 22, "MOVBE: MOVBE Instruction (big-endian)")
+       TEST_FEATURE(fv, 23, "POPCNT: POPCNT Instruction")
+       TEST_FEATURE(fv, 24, "TSC-DEADLINE: APIC Supports One-Shot Operation Using a TSC Deadline Value")
+       TEST_FEATURE(fv, 25, "AES: AES Instruction Set")
+       TEST_FEATURE(fv, 26, "XSAVE: XSAVE, XRESTOR, XSETBV, XGETBV")
+       TEST_FEATURE(fv, 27, "OSXSAVE: XSAVE Enabled by OS")
+       TEST_FEATURE(fv, 28, "AVX: Advanced Vector Extensions")
+       TEST_FEATURE(fv, 29, "F16C: F16C (Half-Precision) FP Support")
+       TEST_FEATURE(fv, 30, "RDRND: RDRAND (On-Chip Random Number Generator) Support")
+       TEST_FEATURE(fv, 31, "HYPERVISOR: Running on a Hypervisor (Always 0 on a Real CPU, But Also With Some Hypervisors")
 
 
        /**********************Get CPU's SERIAL Number*********************/